Hi, basic question: are exit code executed on the next bar? it seems yes when using probactest.
If yes, how can I make it exit right away when the price hits that exitprice
If LongOnMarket AND LongExit THEN
SELL AT MARKET
ENDIF
thanks for anyone that can advice.
Strategy code is read through at the close of a bar and any orders or market instructions sent through and actioned at the opening of the next bar.
Use multi time frame in your code or use STOP and LIMIT orders to exit at a price.
STOP (pending)
LIMIT
Thanks Vonasi, so it will be happen on the next bar unless it is a stop. I see 2 option based on your reply:
- Add a stop: Can I add the exit/stop as a moving exit (not trailing since i dont want to be limited by the minimum distance required by IG/guaranteed stop)?
for example: the LongExit is calculated based on an event (EventTrigger). This normally happens multiple times after I go long, so multiple times the Long Exit will change and it will be near the price.
EventTrigger = close crosses over donchianMiddle
DCDatEVENT = DonchianDown
if EventTrigger then
LongExit=DCDatEVENT
mybarindex=BARINDEX
endif
2. can you elaborate on the mulitframe. thanks.
SET orders are placed on the market at the open of a candle and remain there until cancelled or their distance is changed by another SET order or until they are hit by price.
Pending STOP and LIMIT orders have to be placed at the close of every bar (and are applied at the open of the next bar) because they last for one bar only.
Multi time frame allows you to make decisions on say a 1 hour time frame but then control the trade on say a 1 minute time frame so you can adjust your orders regularly at the close of every minute throughout the hour candle. Using MTF does however limit the data available to back test on as faster time frames cover a shorter period for the same number of bars.
Plenty more elaboration on MTF in the sticky topic about it:
Multi timeframe – MTF indicators for ProRealTime