程式碼
Input: Price2(MedianPrice of Data1);
Input: Length2(60),
ChanWid2(3);
Input: CompMode(0);
Input: StopDate(0);
Vars: ChanHi2(0), ChanLo2(0), WidChan2(Iff(ChanWid2>0,ChanWid2,-ChanWid2*.001)),
Ave2(0), ATR2(0),
SetBack2(IntPortion((Length2-1)/2)+1);
Vars: DateStop(iff(stopdate<=0,1211231,StopDate)),Ipass( 0);
{Now for second channel}
If Length2>0 and Ipass=0 then begin
Ave2 = Average(Price2,Length2);
If ChanWid2>0
then ATR2 = AvgTrueRange(Length2)
else ATR2 = C;
ChanHi2= Ave2+ATR2*WidChan2;
ChanLo2= Ave2-ATR2*WidChan2;
Plot3[SetBack2](ChanHi2,"HH2");
Plot4[SetBack2](ChanLo2,"HL2");
If LastBarOnChart or Date>=DateStop then Begin
Value5 = (Ave2-Ave2[SetBack2])/SetBack2;
For Value1 = SetBack2-1 downto 0 begin
Value3=0;
Value4=Value1*2;
For Value2=0 to Value4 begin
Value3=Value3+Price2[Value2];
End;
Ave2=Value3/(Value4+1);
If CompMode>0 then Ave2=Ave2*.33+(Ave2[1]+Value5*(SetBack2-Value1))*.67;
ChanHi2= Ave2+ATR2*WidChan2;
ChanLo2= Ave2-ATR2*WidChan2;
Plot3[Value1](ChanHi2,"HH2");
Plot4[Value1](ChanLo2,"HL2");
End;
End;
End;
後記:
這個指標有很多值得學的,應該可以很容易轉成不錯的策略,尤其是外期策略。
1 留言:
傳說中的 ghost indicator
張貼留言
如果有私人問題想請教,請透過網站右方『與站長聯絡』之表單,謝謝!