可以解釋一下SetBarMode的用法嗎?
simple跟series函數從哪裡可以看出差別?
幣須賺 您好
SetBarMode主要是用在您撰寫函數時
最後想產出什麼樣的 simple or series
simple= 單純數值 像是1 2 3 4 5
series = 一連串的數字 close high low open 這種
像是 average 最後是經過計算回傳一個數字 就是 simple 那就是setbarmode(1)
SetBarMode(1);
input:thePrice(numericseries); //"價格序列"
input:Length(numericsimple); //"計算期間"
if Length > 0 then
Average = Summation(thePrice, Length) / Length
else
Average =0;
是不是 如下的test函數
if time=090000 then
test=0
else
test=test[1]+1;
就要用SetBarMode(2)?
幣須賺 您好
簡單來說判斷式可以用SetBarMode(2) 沒錯
--------
您可以看一下我們常用的指標 像是 RSI KD 這種
會經過一連串運算後,前後數值會互相呼應的數列
就要用SetBarMode(2)
SetBarMode(2);
// RSI function (for RSI指標)
//
input: price(numericseries), length(numericsimple);
variable: sumUp(0), sumDown(0), up(0), down(0);
if CurrentBar = 1 then
begin
sumUp = Average(maxlist(price - price[1], 0), length);
sumDown = Average(maxlist(price[1] - price, 0), length);
end
else
begin
up = maxlist(price - price[1], 0);
down = maxlist(price[1] - price, 0);
sumUp = sumUp[1] + (up - sumUp[1]) / length;
sumDown = sumDown[1] + (down - sumDown[1]) / length;
end;
if sumUp + sumDown = 0 then
RSI = 0
else
RSI = 100 * sumUp / (sumUp + sumDown);
3 評論