Porto Portugal
Posts: 16 since May 2018
Thanks Given: 1
Thanks Received: 1
|
I would like to set a simple code to place up to 5 orders sequencially, not in the same bar but the number of orders would be a changeable input, that is, a range of maximum orders could be defined.
I designed the code below but it doesnt work nor does any counting...Can someone help me on this?
Thanks
Inputs:
Price( Close ), PositionBasis( False ),Entrysize (1000),
Ci(12),
ptsROC(0.5), MaxROC(3) ;
variables:
EntryCondition1(false),
CountROC (0);
EntryCondition1= Close > Ci ;
if MarketPosition = 0 then begin
CountROC = 0 ;
end ;
if CurrentBar > 1 then begin
if EntryCondition1 then
Switch( CurrentContracts )
begin
Case 0:
Buy ("MACDLE1") this bar at Close;
if CountROC < MaxROC then
begin
CountROC += 1 ;
end;
Buy ("MACDLE2") this bar at Close;
if CountROC < MaxROC then
begin
CountROC += 1 ;
end;
Case EntrySize*2:
Buy ("MACDLE3") this bar at Close;
if CountROC < MaxROC then
begin
CountROC += 1 ;
end;
Case EntrySize*3:
Buy ("MACDLE4") this bar at Close;
if CountROC < MaxROC then
begin
CountROC += 1 ;
end;
Case EntrySize*4:
Buy ("MACDLE5") this bar at Close;
end;
end;
sell ("MACDLX1") from entry ("MACDLE1") next bar AT$ Close + PTSroc Limit ;
sell ("MACDLX2") from entry ("MACDLE2") next bar AT$ Close + PTSroc Limit ;
sell ("MACDLX3") from entry ("MACDLE3") next bar AT$ Close + PTSroc Limit ;
sell ("MACDLX4") from entry ("MACDLE4") next bar AT$ Close + PTSroc Limit ;
sell ("MACDLX5") from entry ("MACDLE5") next bar AT$ Close + PTSroc Limit ;
|