Your solution looks good Roberto.
IG sent smpaxton the wrong solution anyway as he never had a divide by zero error.
smpParticipant
Average
Roberto,
Thank you, now that makes sense 👍🏻
Steve
GraHal
I found this from ProRealTime documents. It says that the max PreLoadBars is 5000? So is it 5000, 10000? Or any other value?
I tried this code (results are in comments).
//DEFPARAM PreLoadBars = 0 //starts from 1000 (default value)
//DEFPARAM PreLoadBars = 500 //starts from 500
//DEFPARAM PreLoadBars = 5000 //starts from 5000
//DEFPARAM PreLoadBars = 10000 //starts from 10000
//DEFPARAM PreLoadBars = 11000 //starts from 10000 (any value > 10000 will be ignored)
ONCE TradeON = 1
SELL AT Market
IF IsLastBarUpdate AND Not OnMarket AND TradeON THEN
BUY at Market
TradeON = 0
ENDIF
graph BarIndex
The count is checked on the setup bar (the one BEFORE the arrow plotted by ProBackTest, the bar when the BUY order is placed).