Hi All,
Can anyone help with a coding question? I would like the also to exit the position after a certain time, ie on the 5 minutes chart, i would like the position to close 20 minutes after entry.
thank you
20 minutes is 4 bars, si you can write:
IF BarIndex >= (TradeIndex + 4) THEN
SELL AT MARKET
EXITSHORT AT MARKET
ENDIF
Hi Gokzma,
Remember using the proper forum. ProBuilder is for indicators and ProOrder for strategies. I have already moved your topic to ProOrder. Read the forum rules in case you have any doubt.
Regarding your question, I attached a piece of code that you can use:
IF condition AND NOT ONMARKET THEN
BUY 1 CONTRACT AT MARKET // Once your condition is met, the code will buy at market
x = barindex // x = number of the candle in which we have opened the operation
ENDIF
IF barindex = x + n THEN // n is the number of candles after the opening. Since you are in a 5 m TF, and want to close after 20 m, then n=4
SELL AT MARKET
ENDIF
I hope it is ok,
Juan
Roberto,
You are too fast for me :)))
Much appreciate, apologies for posting it in the wrong forum in the first place.
@Juan Salas
it’s good to have two different working approaches!
….and I would have done it like this:
if barindex - tradeindex = 4 then
…so that’s three ways.