Hello
I would like to Open a trade at the start of a bar and close it at the end of the same bar i.e. my exit criteria is the end of the time period.
Example:
I wish to go long on a 15 min bar – I would like to buy 1 lot at 11:00 and exit my position at 11:15.
Thanks
K12an
Hi K12AN, do you want something like this?
IF TIME=110000 THEN
BUY AT MARKET
ENDIF
IF TIME=111500 THEN
SELL AT MARKET
ENDIF
Or
IF LONGONMARKET THEN // Next bar will be closed no matter what time
SELL AT MARKET
ENDIF
IF YOURCONDITIONS THEN
BUY AT MARKET NEXTBAROPEN
ENDIF
IF LONGONMARKET THEN
SELL AT MARKET
ENDIF
Hope it helps you 😉
Thanks Adolfo – will give it a try 🙂
NEXTBAROPEN is depreciated. Each conditions are tested at close of the bar and then trade are launched at the next bar open.
Not having much luck with this I’m afraid.
I wanted to open a trade every day at 7am and close it at 5pm – but haven’t been able to make it work.
Even when using the function in beta version 10.3 it doesn’t generate any trades in backtesting
What is the timeframe used for your conditions? May I ask you to put here your entire code for a better comprehension? Thanks! 🙂