奇狐社區論壇
在這個頁面顯示本主題全部的 3 個文章

奇狐社區論壇 (http://www.chiefox.com.tw/bbs/index.php)
- 問題交流 (http://www.chiefox.com.tw/bbs/forumdisplay.php?forumid=28)
-- [公式]IFF指令請益 (http://www.chiefox.com.tw/bbs/showthread.php?threadid=23747)


由 8QptCEM9 在 2023-09-08 17:57 發表:

[公式]IFF指令請益

在TradingView的Pine語言中,up1 = nz(up[1],up),其中nz表示以系列中的零(或指定值)替換NaN值。
語法:
nz(x, y) → integer
nz(x, y) → float
nz(x, y) → color
nz(x, y) → bool
nz(x, y) → series[integer]
nz(x, y) → series[float]
nz(x, y) → series[color]
nz(x, y) → series[bool]
nz(x) → integer
nz(x) → float
nz(x) → color
nz(x) → bool
nz(x) → series[integer]
nz(x) → series[float]
nz(x) → series[color]
nz(x) → series[bool]
參數:
x (series) 待執行的系列值。
y (float) 將插入的值代替x系列中的所有NaN值。

請問如果我想用奇狐語法實現up1 = nz(up[1],up),我可以怎麼做呢?感覺是用IFF指令但是IFF是返回零值,而前述nz指令則可以返回零值與na值。


由 cgjj 在 2023-09-08 19:28 發表:

回覆: [公式]IFF指令請益

引用:
最初由 8QptCEM9 發表
在TradingView的Pine語言中,up1 = nz(up[1],up),其中nz表示以系列中的零(或指定值)替換NaN值。
語法:
nz(x, y) → integer
nz(x, y) → float
nz(x, y) → color
nz(x, y) → bool
nz(x, y) → series[integer]
nz(x, y) → series[float]
nz(x, y) → series[color]
nz(x, y) → series[bool]
nz(x) → integer
nz(x) → float
nz(x) → color
nz(x) → bool
nz(x) → series[integer]
nz(x) → series[float]
nz(x) → series[color]
nz(x) → series[bool]
參數:
x (series) 待執行的系列值。
y (float) 將插入的值代替x系列中的所有NaN值。

請問如果我想用奇狐語法實現up1 = nz(up[1],up),我可以怎麼做呢?感覺是用IFF指令但是IFF是返回零值,而前述nz指令則可以返回零值與na值。



不同軟體語言的運算基礎架構未必相同
架構不同要算相同的東西
在程式語言撰寫處理上,就可能會有很大的差異~~
我想以下可能是您想要的答案吧,請參考!!!

以均線舉例來說~~

MM:MA(C,30);
MM 這個均線其數列的有效起始位置是 30,也就是 lbound(MM)=30
MM 這個數列在K棒第1根~第29根為無效區域
若要將 MM 無效的區域設為零值,做法如下:
MM:=if(barpos>=LBOUND(MM) and LBOUND(MM)>0,MM,0);

較好的做法,是理解原理後,重新用奇狐寫過
而非一行一行想去轉換翻譯為奇狐的語法


由 8QptCEM9 在 2023-09-08 19:52 發表:

好的,我來試試😉


全部時間均為台灣時間, 現在時間為12:35
在這個頁面顯示本主題全部的 3 個文章


Powered by: vBulletin Version 2.3.0 - Copyright©2000-, Jelsoft Enterprises Limited.

簡愛洋行 製作 Copyright 2003-. All Rights Reserved.