I have a problem / question regarding a simple break out strategy I am working on. The logic is somewhat like:
Code: Select all
if myCondition then begin
buy ("ENTRY L") 1 contracts next bar H + myOffset stop;
sellshort ("ENTRY S") 1 contracts next bar L - myOffset stop;
if MarketPosition = 1 then begin
sell ("LX") 1 contracts next bar myLongTarget limit;
sell ("LS") 1 contracts next bar myLongStop stop;
if MarketPosition = -1 then begin
buytocover ("SX") 1 contracts next bar myShortTarget limit;
buytocover ("SS") 1 contracts next bar myShortStop stop;
My problem is that the stop loss and profit target orders are filled too late. It seems that the sell / buycover orders are sent on the close of the next bar, so I do not have a stop loss for the time of 1 bar. As far as I understand I cannot use SetProfitTarget nor SetStoploss, since my targets / stoplosses are dynamic and I could use the two Set* methods to set a fixed value once.
Is there a simple solution to this problem or do I have to reimplement the strategy using IntraBarOrderGeneration ?