停損反向進場一次後又停損出場怎寫
請問停損後反向進場(一次)~再停損出場(不要再反向進場)~可以提示一下怎麼編寫嗎?謝謝!! 本帖最後由 blj0511 於 15-9-3 00:36 編輯vars:stop_L(20),counter(0);
[出手條件]
if marketposition>0 and counter=0 then begin;
sellshort next bar at entryprice(0)-stop_L stop;
if L<entryprice(0)-stop_L then begin;
counter=1;
end;
end;
if marketposition<0 and counter=0 then begin;
buy next bar at entryprice(0)+stop_L stop;
if H>entryprice(0)+stop_L then begin;
counter=1;
end;
end;
if marketposition>0 and counter=1 then begin;
sell next bar at entryprice(0)-stop_L stop;
if L<entryprice(0)-stop_L then begin;
counter=0;
end;
end;
if marketposition<0 and counter=1 then begin;
buytocover next bar at entryprice(0)+stop_L stop;
if H>entryprice(0)+stop_L then begin;
counter=0;
end;
end;
不知道對不對,沒實際run過 試過上面的~還是出現停損後反向進場~之後又一次停損反向進場~沒有只要停損出場(不要再反向進場)~ 舒潔 發表於 15-9-3 01:11 static/image/common/back.gif
試過上面的~還是出現停損後反向進場~之後又一次停損反向進場~沒有只要停損出場(不要再反向進場)~ ...
vars:stop_L(20),counter(0);
[出手條件]
if marketposition>0 and counter=0 then begin;
sellshort next bar at entryprice(0)-stop_L stop;
if L<entryprice(0)-stop_L then begin;
counter=1;
end;
end;
if marketposition<0 and counter=0 then begin;
buy next bar at entryprice(0)+stop_L stop;
if H>entryprice(0)+stop_L then begin;
counter=1;
end;
end;
if marketposition>0 and counter=1 then begin;
sell next bar at entryprice(0)-stop_L stop;
if L<entryprice(0)-stop_L then begin;
counter=2;
end;
end;
if marketposition<0 and counter=1 then begin;
buytocover next bar at entryprice(0)+stop_L stop;
if H>entryprice(0)+stop_L then begin;
counter=2;
end;
end;
改這樣試試,不過停損第二次後要重新進場時,記得要把counter=0,因為我不知道你進場邏輯為何
頁:
[1]