For further information on this - here is the detailed discussion on this topic:
viewtopic.php?f=1&t=8810
- The main issue - When the first target is filled - the second/third target orders get cancelled and then re-submitted again at the same price.
- This is with allow unlimited orders in the same direction setting in strategy properties.
Code: Select all
[IntrabarOrderGeneration = true]
Vars: intrabarpersist MktPosition(0);
Vars: intrabarpersist AEP(0);
Vars: intrabarpersist CC(0);
Vars: OneTick(MinMove/PriceScale);
MktPosition=Marketposition;
if LastBarOnChart_s and barstatus(1)=2 and MktPosition=0 then begin
buy ("LE") 3 contracts next bar market;
end else begin
CC=CurrentContracts;
AEP=AvgEntryPrice;
if CC>=1 then sell ("TT") 1 contract next bar at AEP+(6*OneTick) limit; // Third Target
if CC>=2 then sell ("ST") 1 contract next bar at AEP+(4*OneTick) limit; // Second Target
if CC>=3 then sell ("FT") 1 contract next bar at AEP+(2*OneTick) limit; // First Target
end;