number of bars

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #238007 quote
    LivJoJade
    Participant
    New

    Hi all again

    Attached a RSI/Price divergence with added Bolly Bands criteria indicator for your perusal. First of all could someone double check the code for me as my knowledge is somewhat limited and secondly I wish to limit the number of bars used to build the divergence, possibly only the last 20 bars? Hope that makes sense.

    #238014 quote
    robertogozzi
    Moderator
    Master

    Ever tried using:

    myDIV = DivergenceRSI[5,30,70,20](close)

    from https://www.prorealcode.com/documentation/divergencersi/ ?

    Iván González and LivJoJade thanked this post
    #238016 quote
    LivJoJade
    Participant
    New

    Hi Robert

    In the indicator you post is 5 the number of RSI periods ?

    and the figure 20 I assume is the number of bars for the formation of a divergence, however, does that mean any divergence has to be formed on exactly 20 bars or any number of bars up to 20 ?

    many thanks for your help.

    #238021 quote
    robertogozzi
    Moderator
    Master

    Divergence is calculated between the HIGHEST and the LOWEST prices within the last 20 bars (the bars in between can be as little as 2 and up to 20).
    You can read all detail at https://www.prorealcode.com/documentation/divergencersi/

    LivJoJade thanked this post
    #238023 quote
    LivJoJade
    Participant
    New

    Again many thanks Robert

    If I could trouble you for one more thing. What code would include the added requirement for a close above or below the bolly bands at the time of the RSI divergence signal delivery..

    #238037 quote
    Iván González
    Moderator
    Master

    Hi!
    Just add this:

    cond=close>BollingerUp[20](close)
    robertogozzi and LivJoJade thanked this post
    #238106 quote
    LivJoJade
    Participant
    New

    Good afternoon Ivan

    For some reason that isn’t having the desired affect. The original code is this………….

    i = DivergenceRSI[14,30,70,5](close)

    return i style(histogram)

    But I wish to add extra criteria that being a close > BB for a bearish divergence……..

    1
    cond=close>BollingerUp[20](close)

    and a close < BB for a bullish divergence……..

    1
    cond=close<BollingerUp[20](close)

     

    Hoping I’m making some kind of sense and really appreciative of your help.

    #238213 quote
    robertogozzi
    Moderator
    Master

    There you go:

    i = DivergenceRSI[14,30,70,5](close)
    Signal = 0
    IF i = 1 THEN
       IF close<BollingerUp[20](close) THEN    //isn't it BollingerDown?
          Signal = 1
       ENDIF
    ELSIF i = -1 THEN
       IF close>BollingerUp[20](close) THEN
          Signal = -1
       ENDIF
    ENDIF
    return Signal style(histogram)
    LivJoJade thanked this post
    #238245 quote
    LivJoJade
    Participant
    New

    Hi Robert

    Yes sir you are indeed correct, it should have been BollingerDown. Many thanks to yourself and all of the coding experts which help those of us who need it.

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

number of bars


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
LivJoJade @livjojade Participant
Summary

This topic contains 8 replies,
has 3 voices, and was last updated by LivJoJade
1 year, 4 months ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 09/25/2024
Status: Active
Attachments: 1 files
Logo Logo
Loading...