I'm wondering if it is possible to essentially check for a divergence between the price and an indicator since a specific event (i.e., a change in price direction that started on the other side of a moving average and then cuts through that moving average and continues to run with no pullback) until the point that the strategy would have otherwise executed a trade but for identifying a divergence during that period.
In effect, I'm trying to get the strategy to not execute a trade (a long for example) it would have otherwise executed if the bars (recently) changed direction (from short to long) on the other side of a moving average, then crossed up through the moving average with no pullbacks, and since that change in direction another indicator was essentially flat.
I've tried using a variable (bool) that turns to true when the bars change direction on the other side of a moving average, and which stays true until any subsequent change in direction of the bars. My thought was that if a trade was otherwise going to be executed by the strategy, but the variable is true, and since turning true the other indicator has essentially remained flat, a condition will not be satisfied and the trade won't be executed. The problem I'm facing is I'm not sure how to have the other indicator's slope checked since the variable changed to true so that if the slope of that indicator is essentially flat since the variable changed a condition won't be satisfied and the trade won't be executed.
Any help with this would be much appreciated.
Thank you.
Comment