alexwang7777 發表於 10-6-11 16:37

Ensign Volatility Stop

_SECTION_BEGIN("Ensign Volatility Stop");

// Ensign Volatility Stop
// get the multiple of 9 period EMA of ATR_Ensign
k=Param("multiplication factor", 1,0.5,5,0.1);

period=k*9;
VS_raw = 2.5 * EMA(ATR(1), period);

// for longs, VS line is below price
loline = VS_below_price = HHV(Close, period) - VS_raw;

// for shorts, VS line is above price
hiline = VS_above_price = LLV(Close, period) + VS_raw;
between = IIf (C < hiline AND C > loline, 1, 0);
up = IIf(C > hiline OR (H > Ref(H, -1) AND H > hiline), 1, 0);
dn = IIf(C < loline OR (L < Ref(L, -1) AND L < loline), 1, 0);
upcond = IIf(between AND BarsSince(up) < BarsSince(dn) , 1, 0);
dncond = IIf(between AND BarsSince(dn) < BarsSince(up) , 1, 0);
upline = IIf(up OR upcond, loline, Null);
dnline = IIf(dn OR dncond, hiline, Null);

Plot(C, "", colorLightGrey, styleBar);
Plot(upline, "", colorRed, styleStaircase) ;
Plot(dnline, "", colorGreen, styleStaircase) ;

Buy=upline;
Sell=dnline;
Buy=ExRem(Buy,Sell);
Sell=ExRem(Sell,Buy);

PlotShapes(Buy*shapeUpArrow,colorGreen);
PlotShapes(Sell*shapeDownArrow,colorRed);





金双盈 發表於 10-6-11 16:51

回復 1# alexwang7777


   建議把最下面兩行的語法顏色修改成適合台灣使用的箭頭顏色




PlotShapes(Buy*shapeUpArrow,colorRed);
PlotShapes(Sell*shapeDownArrow,colorGreen);

alexwang7777 發表於 10-6-11 17:30

^^忘了改顏色{:4_186:}

aaqqww93 發表於 10-6-11 19:41

呵~改一下比較習慣
不錯呢謝謝分享
頁: [1]
查看完整版本: Ensign Volatility Stop