close

 
上次談完是停利的用途,這禮拜剛好多單又停利在最高點。
之前發生好幾次,這不是好運,這是做程式交易必然會得到的結果,
當下一根再度進場多單,不禁讓人聯想上一次空單停利後下一筆空單停損;
那這一次多單停利後這筆多單會不會歷史重演?
說真的你不知道,我不知道,獨眼龍眼不知道……

程式碼如下:
if  MarketPosition = 0 and EntriesToday(date) <1 then begin
    Buy next bar at 頂線 stop;
    Sellshort next bar at 底線 stop;
    Setstoploss(10000);
    SetProfitTarget(100000);
end;
if marketposition = 1 then begin
    Setstoploss(10000);
    SetProfitTarget(100000);
end;
if marketposition = -1 then begin
    Setstoploss(10000);
    SetProfitTarget(100000);
end;
 

4/8當程式停利後,即你手上沒有部位(MarketPosition = 0)
下一根仍在頂線之上故當然進場,這是你自己寫程式的選擇,
如果你寫的不是你要求的,那表示是你的邏輯不清楚。
 

好,如果你以為你想要空單停利之後只要做多,多單停利後只要做空,
只要加兩個變數,並將多、空、停利、停損分開處理:

var:a1(0),b1(0);
if a1=0 and MarketPosition = 0 and EntriesToday(date) <1 then begin
    Buy next bar at 頂線 stop;
    Setstoploss(10000);
    SetProfitTarget(100000);
end;
if b1=0 and MarketPosition = 0 and EntriesToday(date) <1 then begin
    Sellshort next bar at 底線 stop;
    Setstoploss(10000);
    SetProfitTarget(100000);
end;
if marketposition<> 0 then begin
    Setstoploss(10000);    
end;
if marketposition = 1 then begin
    SetProfitTarget(100000);
    a1=1;
    b1=0;
end;
if marketposition = -1 then begin
    SetProfitTarget(100000);
    b1=1;
    a1=0;
end;


停利之後,只做反向單

arrow
arrow
    全站熱搜

    trading16888 發表在 痞客邦 留言(1) 人氣()