iBullsPower and iBearsPower are returning the same value per period in Tester - any reason why my code would be doing this?
Tester limitation: You can not get bar zero of other timeframes/pairs
I've backtested this code, and I do get different values for bullsPwr and bearsPwr provided that the timeframe being tested (the "Period" field in the Strategy Tester) is lower than M15. If I run the backtesting on e.g. H1, then I do get the same value for bullsPwr and bearsPwr - and it's not a zero value.
The problem is not that you can't get bar zero of other timeframes. The problem is as follows:
- The calculation is being done at the start of a new bar in the tester.
- If the timeframe of the tester is higher than M15, then a new M15 bar has also just started.
- At this point, bar 0 on M15 consists of a single tick, and the bar's open, high, low, and close are all the same value.
- The formula for bulls/bears power is current high/low minus exponential moving average.
- Therefore, if you calculate bulls and bear power on the first tick of a bar, you get the same value for each, because the current high and low are the same.
In your code it would therefore seem to make more sense to use a bar offset of 1, not zero.
any reason why the following code would print out the same value for iBullsPower and iBearsPower in the following code? -