COCO研究院

 找回密碼
 註冊
搜索
查看: 2515|回復: 3

[其他程式語言] 停損反向進場一次後又停損出場怎寫

[複製鏈接]
發表於 15-9-2 17:08 | 顯示全部樓層 |閱讀模式
請問停損後反向進場(一次)~再停損出場(不要再反向進場)~可以提示一下怎麼編寫嗎?謝謝!!
發表於 15-9-3 00:34 | 顯示全部樓層
本帖最後由 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 | 顯示全部樓層
試過上面的~還是出現停損後反向進場~之後又一次停損反向進場~沒有只要停損出場(不要再反向進場)~
發表於 15-9-3 14:17 | 顯示全部樓層
舒潔 發表於 15-9-3 01:11
試過上面的~還是出現停損後反向進場~之後又一次停損反向進場~沒有只要停損出場(不要再反向進場)~ ...

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,因為我不知道你進場邏輯為何
您需要登錄後才可以回帖 登錄 | 註冊

本版積分規則

手機版|Archiver|站長信箱|廣告洽詢|COCO研究院

GMT+8, 24-4-24 04:01

Powered by Discuz! X3.4

Copyright © 2001-2023, Tencent Cloud.

快速回復 返回頂部 返回列表
理財討論網站 | AI繪圖AI超擬真美女AI beauty AI Stable DiffusionAI正妹AI Lookbook