MACD Divergence setup

Forums ProRealTime English forum ProOrder support MACD Divergence setup

Viewing 3 posts - 1 through 3 (of 3 total)
  • #172660

    I know there have been plenty of indicators written for divergence in this forum, but having looked through all of them I still can’t quite grasp how to adapt them for my purposes, so I wonder if anyone can help me with this scenario?

    I want to capture the bar that contains the previous lowest low in the range (in this case it would be the 9th bar – see screengrab), and then calculate whether or not the MACD at that bar is lower than the MACD at current bar close.

    Currently my code is only able to calculate divergence of the MACD based on current bar close versus the bar that is defined by the static lookback range (in this case 15).

    Does anyone know how I could query the MACD with a lookback bar that is derived from a previous low?

    Thank you in advance…

     

    #172706

    1. assume the current LOW is the lowest within back bars
    2. scan the previous back bars for a previous low, starting from back-1 bars, for another back bars
    3. us a FOR…NEXT iteration to find the bar where that happened, THAT will be the bar when you can check MACD for a divergence

    Not tested.

    1 user thanked author for this post.
    #172722

    Thank you very much Roberto. I think this is close but there is still something I am doing incorrectly. The only way I could get my whole code to work was by querying the MACD with this: CurMACD > PriorMACD…….. but that is only doing a static read of [back], as before.

    I’ve attached a screengrab of where there should be an entry at 15:00, based on a rising MACD from the low at 14:05. My “macconf” needs to be true for there to be an entry at 15:00. I’m guessing that maybe I need to use PriorBAR somewhere else in the code? But I’m not sure how. Would you mind helping me here?

    Thank you 🙂

     

Viewing 3 posts - 1 through 3 (of 3 total)

Create your free account now and post your request to benefit from the help of the community
Register or Login