201302221011CDP Daytrade System - Source Code

input : stoploss(0.01),LengthL(30),LengthS(30);

variables : cdp(0),ah(0),nh(0),nl(0),al(0),longcount(0),shortcount(0);

 

 

if d<>d[1] then begin

    cdp = (highD(1)+lowD(1)+2*CloseD(1))/4;

    ah = cdp+(highD(1)-LowD(1));

    //nh = cdp*2-LowD(1);  no use this !

    //nl = 2*cdp-highD(1); no use this !

    al = cdp-(highD(1)-LowD(1));

    longcount = 0;

    shortcount = 0;

end;

 

 

condition1 = time > 0850 and time < 1340 and Close > Highest(high,LengthL)[1] and Longcount = 0;

condition2 = time > 0850 and time < 1340 and Close < Lowest(low,LengthS)[1] and shortcount = 0;

 

if condition1 then begin

    Buy("CDP_B") 1 contracts next bar at ah+1 stop;

end;

 

if condition2 then begin

    Sellshort("CDP_S") 1 contracts next bar at al-1 stop;

   end;

 

 

if marketposition = 1 then begin

    longcount = 1;

end;

 

 

if marketposition = -1 then begin

    shortcount = -1;

end;

 

 

if marketposition = 1 then begin

    Sell("S1L") 1 contracts next bar at entryprice*(1-stoploss) stop;

end;

 

if marketposition = -1 then begin

    BuytoCover("S1S") 1 contracts next bar at entryprice*(1+stoploss) stop;

end;

 

 

{ ----- TSTS Original code -----}

if time = 1340 then begin

    Sell("exitL") 1 contracts this bar at close;

    Buytocover("exitS") 1 contracts this bar at close;

    cdp = 0;

    ah = 0;

    nh = 0;

    nl = 0;

    al = 0;

end;

 

沒有上一則|日誌首頁|沒有下一則
回應
    沒有新回應!