Hi, a very very basic question, what happens with the sell order when the buy order it hit? if it remains can I get rid of it?
IF NOT OnMarket AND c1 THEN
BUY 1 CONTRACT AT HIGH STOP
SELL 1 CONTRACT AT LOW STOP
ENDIF
It remains till the bar closes.
When a bar closes ALL pending orders are cancelled and you need to place them again, if needed.
Be warned that SELL does not open a Short position, it closes a Long one.
To go short use SELLSHORT and to close it use EXITSHORT.
Thanks, I think the problem I have is that the buy get hits in the beginning of the bar, then I want to get rid of the sell but in the in the _same bar it hits the sell before the next opens.
Is it possible to do the following in the same bar?
SELL AT MARKET
SELLSHORT AT MARKET
No wait! Hahaha, I was using sell instead of Sellshort in one place! 😀
Still as Roberto said it is possible for your buy order to get filled and then price reverse and hit your sellshort order which will then close your long position for a loss and then open a short position all in the space of one bar.
You could do something using MTF like this on a faster time frame such as the 1 second time frame. This will however seriously limit the amount of data available for your backtest.
timeframe(1 second)
if not onmarket then
buy 1 contract at LongPrice stop
sellshort 1 contract ShortPrice stop
endif