I am attempting to set my stop level, which I want to calculate at the end of each intraday bar, to be the level at which I enter the trade (either long or short) should this level be breached.
At this point I am certain that my end-of-bar calculations are correct however I am not certain that when I backtest the strategy it is not performing a continuos calculation of the desired ("end of bar") level. Would this be cleared up by the calculation being set to compute on close? This may be why I am not seeing any trades. (where would I place setComputeOnClose? -- should I assign these entry and exit levels, ie.stop entries, to a variable? not sure how to proceed...)
If that is not the case then something is wrong with my code's logic. I want to compute the stop for the next bar on the close of this bar. I want to enter a trade on this next bar if the level calculated from the last bar is breached. This level would remain set until it is recalculated on the close of the next bar. I have experimented with different offsets but I am still not seeing any trades.
Here is the code I am using to enter a long trade. I want to enter a long trade if it reaches the long stop level which was calc'd on the close of the prior bar:
if(high(1)>= LE && !Strategy.isLong())
Strategy.doLong("LE",Strategy.STOP,Strategy.NEXTBA R);
thank you,
sidenote:
?Is the +1 relative offset a postdictive backtesting error?
At this point I am certain that my end-of-bar calculations are correct however I am not certain that when I backtest the strategy it is not performing a continuos calculation of the desired ("end of bar") level. Would this be cleared up by the calculation being set to compute on close? This may be why I am not seeing any trades. (where would I place setComputeOnClose? -- should I assign these entry and exit levels, ie.stop entries, to a variable? not sure how to proceed...)
If that is not the case then something is wrong with my code's logic. I want to compute the stop for the next bar on the close of this bar. I want to enter a trade on this next bar if the level calculated from the last bar is breached. This level would remain set until it is recalculated on the close of the next bar. I have experimented with different offsets but I am still not seeing any trades.
Here is the code I am using to enter a long trade. I want to enter a long trade if it reaches the long stop level which was calc'd on the close of the prior bar:
if(high(1)>= LE && !Strategy.isLong())
Strategy.doLong("LE",Strategy.STOP,Strategy.NEXTBA R);
thank you,
sidenote:
?Is the +1 relative offset a postdictive backtesting error?
Comment