龙听期货论坛's Archiver

C
+
+


 微信: QQ:

龙听 发表于 2020-5-5 07:54

金字塔趋势跟踪指标源码[金字塔模型]

[code]
runmode:0;



input:length(20,5,60,5);

input:ratio(4,1,5,1);



variable:trend=0;

variable:stopprice=0;



prebarhigh:=ref(high,1);

prebarlow:=ref(low,1);



atr:=trimprice(ref(ema(high-low,length),1));

trailingstop:=ratio*atr;



if barpos>length and trend=0 then begin

trend:=1;

stopprice:=prebarlow-trailingstop;

drawicon(1,prebarlow-trailingstop,8,0);

drawtext(1,prebarlow-trailingstop,\'开多\',colorred,1);

end



if trend=1 then begin

if prebarlow-trailingstop>stopprice then

stopprice:=prebarlow-trailingstop;

  

if low<=stopprice then begin

  trend:=-1;

stopprice:=prebarhigh+trailingstop;

drawicon(1,prebarhigh+trailingstop,9,0);

drawtext(1,prebarhigh+trailingstop,\'开空\',colorgreen,1);  

end



stickline(close>=open,high,close,1,1,colorred);

stickline(close>=open,close,open,10,1,colorred);

stickline(close>=open,open,low,1,1,colorred);

stickline(close

stickline(close

stickline(close

end



if trend=-1 then begin

if prebarhigh+trailingstop

stopprice:=prebarhigh+trailingstop;

  

if high>=stopprice then begin

  trend:=1;  

stopprice:=prebarlow-trailingstop;

drawicon(1,prebarlow-trailingstop,8,0);

drawtext(1,prebarlow-trailingstop,\'开多\',colorred,1);  

end



stickline(close>=open,high,close,1,1,colorgreen);

stickline(close>=open,close,open,10,1,colorgreen);

stickline(close>=open,open,low,1,1,colorgreen);

stickline(close

stickline(close

stickline(close

end



drawicon(trend=1,stopprice,10);

drawicon(trend=-1,stopprice,11);
[/code]

页: [1]