How to calculate positive and negative divergences

Optuma Forums Optuma Scripting How to calculate positive and negative divergences

Tagged: 

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #45539
    Darren
    • Topics: 66
    • Replies: 680
    • Posts: 746

    Divergences between the trend of prices and an indicator are often used as a signal for a change in price trend:

    Positive (Bullish) Divergence: prices are falling but the indicator is rising

    Negative (Bearish) Divergence: prices are rising but the indicator is falling

    This example compares RSI values at their highs with the closing price of the stock at the time of those highs. If the RSI high is lower than the previous high but the price is higher between those points then it gives a signal for negative divergence.

    This example uses a 10 bar pivot for the RSI(14) ie there are at least 10 lower days either side (this can be increased – the higher the number the more important the peak).

    For positive divergence:

    As in this example, use the above in two separate Show View tools and drag one over the other to display the signals:

    Capture

    At point B the RSI peak is lower than A, but the share price is higher (negative divergence), whereas at point D the RSI low is higher than at C but the share price is lower (positive divergence).

     

     

    • This topic was modified 2 years ago by Darren.
    1 user thanked author for this post.
    #46779
    Luke
    • Topics: 3
    • Replies: 3
    • Posts: 6

    Hi Darren, what show bar scripts are you using on the RSI indicator to create the arrows?

    #46815
    Luke
    • Topics: 3
    • Replies: 3
    • Posts: 6

    Also why does this script not return any results for a daily scan of last bar but shows results one day after? Thanks

    #46819
    Darren
    • Topics: 66
    • Replies: 680
    • Posts: 746

    Hi Luke,

    The scripts used are in the initial post.

    Because the scripts use pivot levels we have to wait until the pivot is confirmed so there will always be a delay. Do you have an example?

    #54077
    Darren
    • Topics: 66
    • Replies: 680
    • Posts: 746
    2 users thanked author for this post.
    #57607
    Karen
    • Topics: 21
    • Replies: 32
    • Posts: 53

    Hi Darren,

    I’m trying to get the vertical green and red bars over the RSI indicator as opposed to having a separate show view for the Positive and Negative Divergences.  Is this possible?

    Please see attached workbook which shows that different result are obtained. Can you please assist with this.

    Thanks,

    Karen

    #57625
    Mandeep
    • Topics: 45
    • Replies: 22
    • Posts: 67

    Hi Darren,

    On the back of your signal test above – can you please confirm the Pivot() function is now ok to use to support signal / backtesting.  Last time I checked I found that it looks ahead of time and cheats.

    cheers

    Mandeep

    #57989
    Darren
    • Topics: 66
    • Replies: 680
    • Posts: 746

    Hi Mandeep,

    You should not use the Pivot() function in any tests, because future data coming in can affect the position of previous labels, thus making the tests unrealistic.

    #63297
    Steve
    • Topics: 15
    • Replies: 20
    • Posts: 35

    Is it possible to use the TIMESINCESIGNAL command in the following way?

    TIMESINCESIGNAL (Sig1 and Sig2) <3

    (I would like to find divergence that has occurred on the current bar or the previous two bars.)

    I assume I’m not able to do this as I’m not getting correct results. Is there a better way to do this?

    Thanks
    Steve

Viewing 9 posts - 1 through 9 (of 9 total)
  • You must be logged in to reply to this topic.

Pin It on Pinterest