Thank you for your reply.
Yes, your loop does check the value of TrendMagicModified1 for the current bar with the values from 1, 2, 3, 4, and 5 bars ago. If any of those values do not equal the current bar's value, 1 is added to notEqual. If notEqual is 0, that means the value has been the same for the current bar and the 5 bars before it.
notEqual is only one part of your condition. Your condition is checking for 3 different things to be true all at the same time. Not only does notEqual need to be 0, it is also checking that TrendMagicModified1.BullOrBear[1] is 0 and TrendMagicModified1.BullOrBear[2] is 1. If all three of those things are not met at the same time, the logic of that condition will not be executed. From your prints and the screenshots you have shared, it does not appear that all three parts of the condition have all been met at the same time.
You will need to evaluate your condition and determine if it makes logical sense for all three parts of the condition to be true at the same time or not. So far, in the examples you have shown with prints, all three parts of the condition have not been met.
Please let us know if we may be of further assistance.
Comment