Andrew cardwell Strategy on RSI

Forums ProRealTime English forum ProBuilder support Andrew cardwell Strategy on RSI

Viewing 13 posts - 1 through 13 (of 13 total)
  • #241048
    yas

    Hi

    I need some help to code the following Andrew Cardwell Strategy using RSI

    According to Andrew RSI oscilates in phases if the RSI in 80-40 Range then thats Bullish

    if its in 60-20 its in Bearish Phase  And in Sideway range it oscilates between 40 to 60-65

    Trend Change Condition

    when Rsi in Buillish phase i.e 80-40 i.e when Rsi Drops to 40 during the Uptrend and then Tries to go back up but stops at 60 Level and then makes it way down that indicates trend Range is Shifting to the downside

    For Bearish Rsi oscilates between 20-60 Level when RSI on 60 Level and drops back down but stops at 40 Level and then makes it way up that indicates Trend is shifiting to the upside.

    So basically if someone can code the above Andrew’s Method then that will be a great help

    many thanks

     

    #241061

    Hi yas,

    I myself am not a fan of these “indicators”, but shouldn’t you add the period over which this is to be taken ? Thus, timeframe and number of bars ?
    This should be a guideline for someone who may make this for you. But also to yourself because of the expectations.

    We should be aware that you’re not talking about a normal RSI, but one which indicates Trend. Now a period to observe this over, is applicable – am I right ?

    #241082
    JS

    Hi,

    Here is the RSI with the relevant levels:

    What you can do is combine the RSI with the “DivergenceRSI” available on the platform.

    Another possibility is to calculate how often the RSI is within a certain range and potentially combine this with the “DivergenceRSI.” For example:

    • Range2040 = Summation[N](myRSI > 20 AND myRSI < 40)
    • Range4060 = Summation[N](myRSI > 40 AND myRSI < 60)
    • Range6080 = Summation[N](myRSI > 60 AND myRSI < 80)
    1 user thanked author for this post.
    #241087

    Basing the code on what you passed to JS here is an example strategy to get you started testing.

    Please note that if you want us to program a strategy you cannot be ambiguous, you have to declare all the variables involved and clearly describe the entry and exit conditions.

    1 user thanked author for this post.
    avatar JS
    #241096
    yas

    hi eveyone thanks for the reply’s much appreciated what i was looking for on the lines of an indicator that will sit on pro real time someone in tradingview have develop simliar one here is the link for info

    https://www.tradingview.com/script/Doy0cEgE/

    i am  not looking for automated strategy its more like an indicator if you can develop please

    many thanks

     

    #241097
    JS

     The code on TradingView is blocked and therefore cannot be used or read…

    #241116

    First of all this tradingview indicator is repainting for sure.

    Look at the small red box in the middle, the one which start on monday 16 or tuesday 17th of february 2020 : rsi has not reached levels under 40, so it is impossible to know if rsi will fall under 40, how low and how long it will stay under 50. So that red box was drawn after (repainted).

    If you want to use Andrew Cardwell ranges, you will have to wait some times to know the range where rsi is, and you will not have accurate signals when the trend change, only late signals…

    Also note that the range are not accurate (most of the time RSI can go to 70 but does not stay long even in a downtrend) and depend on the time frame you are looking at…

    #241127
    yas

    here is the code i found someone in tradingview have developed an indicator if that can be converted to PRO REAL TIME PLEASE

    // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
    // © TJ_667

    // Concept developed from RSI : The Complete Guide by John Hayden

    // RSI is regarded as a momentum indicator. 2:1 momentum is associated with RSI values of 66.67 and 33.33 respectfully. In an Uptrend an RSI value of 40 should not be broken and in a downtrend
    // a RSI value of 60 should not be exceeded. 4:1 momentum (RSI values of 80/20) can be associated with extreme market conditions, typically thought of as being Overbought or Oversold.

    // Simple divergence provides a strong indication that the preceding trend will resume as soon as the retracement is completed. Multiple long-term divergences (not shown in this indicator)
    // increase the likelihood that the preceding trend has ended.

    // An Uptrend is indicated when:
    // 1. RSI values remain in an 80/40 range
    // 2. Presence of bearish divergences
    // 3. Hidden bullish divergences are seen
    // A Downtrend is indicated when:
    // 1. RSI values remain in a 60/20 range
    // 2. Presence of bullish divergence
    // 3. Hidden bearish divergence is seen

    // Personal additions to John Haydens concepts are horizontal pivot breaks and diagonal trendline breaks. The 80/20 line color shows the last break of horizontal pivot points, while the rsi
    // line changes color with diagonal breaks. Additional support/resistance is shown by 66.67 and 33.33 lines.

    //@version=4
    study(“Koalafied RSI”, overlay=false)

    //——————– INPUTS ——————– //

    len = input(14, minval=1, title=”RSI Length”)
    showTS = input(true, ‘Show Trend State’)
    showTM2 = input(true, ‘Show Trend Momentum (2:1)’)
    showTM3 = input(true, ‘Show Trend Momentum (3:1)’)
    showOBS = input(true, ‘Show OB/OS’)
    showDiags = input(true, title = “Show Diag Breaks”)
    HZB = input(true, “Show Horizontal Pivot Initial Break”)

    ShowPivots = input(false, title=”Show Pivot Points”)
    left = input(10, minval=1, title=”Pivot Length Left Hand Side”)
    right = input(10, minval=1, title=”Pivot Length Right Hand Side”)

    // RSI
    rsi = rsi(close, len)

    // Trend State
    var state = 0
    if crossover(rsi, 66.67)
    state := 1
    if crossunder(rsi, 33.33)
    state := 2
    if state == 1 and crossunder(rsi, 40)
    state := 3
    if state == 2 and crossover(rsi, 60)
    state := 3
    state := state

    state_col = state == 1 ? color.blue : state == 2 ? color.red : state == 3 ? color.black : na
    state_col2 = state == 1 ? color.blue : state == 2 ? color.red : state == 3 ? color.silver : na

    // Trend
    bgcolor(showTS ? state_col : na, title = ‘Trend State’, transp = 95)

    // 2:1 Momentum
    BG_col = rsi > 66.67 ? color.blue : rsi < 33.33 ? color.red : na
    bgcolor(showTM2 ? BG_col : na, title = ‘Trend Momentum’, transp = 95)

    // 3:1 Momentum
    fillH_col = rsi > 75 ? color.aqua : na
    fillL_col = rsi < 25 ? color.fuchsia : na

    // 4:1 Momentum
    OB = rsi > 80 ? color.red : na
    OS = rsi < 20 ? color.blue : na

    bgcolor(showOBS ? OB : na, title = ‘Overbought’, transp = 90)
    bgcolor(showOBS ? OS : na, title = ‘Oversold’, transp = 90)

    // Support/Resistance
    support = state == 3 and rsi < 40 ? color.blue : na
    resistance = state == 3 and rsi > 60 ? color.red : na

     

    //——————– PIVOTS ——————– //
    // Adapted from ‘Pivot Points High Low (HH/HL/LH/LL)’ – Mohamed3nan

    // Determine pivots
    pvtLenL = left
    pvtLenR = right

    // Get High and Low Pivot Points
    pvthi = pivothigh(rsi, pvtLenL, pvtLenR)
    pvtlo = pivotlow(rsi, pvtLenL, pvtLenR)

    // Get HH, LH, LL, HL
    valuewhen_1 = valuewhen(pvthi, rsi[pvtLenR], 1)
    valuewhen_2 = valuewhen(pvthi, rsi[pvtLenR], 0)
    higherhigh = na(pvthi) ? na : valuewhen_1 < valuewhen_2 ? pvthi : na
    valuewhen_3 = valuewhen(pvthi, rsi[pvtLenR], 1)
    valuewhen_4 = valuewhen(pvthi, rsi[pvtLenR], 0)
    lowerhigh = na(pvthi) ? na : valuewhen_3 > valuewhen_4 ? pvthi : na
    valuewhen_5 = valuewhen(pvtlo, rsi[pvtLenR], 1)
    valuewhen_6 = valuewhen(pvtlo, rsi[pvtLenR ], 0)
    higherlow = na(pvtlo) ? na : valuewhen_5 < valuewhen_6 ? pvtlo : na
    valuewhen_7 = valuewhen(pvtlo, rsi[pvtLenR], 1)
    valuewhen_8 = valuewhen(pvtlo, rsi[pvtLenR ], 0)
    lowerlow = na(pvtlo) ? na : valuewhen_7 > valuewhen_8 ? pvtlo : na

    plot(ShowPivots ? rsi[pvtLenR] : na, “HH”, style = plot.style_circles, linewidth = 2, color = higherhigh ? color.new(color.aqua,0) : na, offset=-pvtLenR)
    plot(ShowPivots ? rsi[pvtLenR] : na, “HL”, style = plot.style_circles, linewidth = 2, color = higherlow ? color.new(color.aqua,0) : na, offset=-pvtLenR)
    plot(ShowPivots ? rsi[pvtLenR] : na, “LH”, style = plot.style_circles, linewidth = 2, color= lowerhigh ? color.new(color.red,0) : na, offset=-pvtLenR)
    plot(ShowPivots ? rsi[pvtLenR] : na, “LL”, style = plot.style_circles, linewidth = 2, color= lowerlow ? color.new(color.red,0) : na, offset=-pvtLenR)

    //Count How many candles for current Pivot Level, If new reset.
    counthi = 0
    countlo = 0
    counthi := na(pvthi) ? nz(counthi[1]) + 1 : 0
    countlo := na(pvtlo) ? nz(countlo[1]) + 1 : 0

    pvthis = 0.0
    pvtlos = 0.0
    pvthis := na(pvthi) ? pvthis[1] : rsi[pvtLenR]
    pvtlos := na(pvtlo) ? pvtlos[1] : rsi[pvtLenR]

    // Horizontal Pivot State
    var stateHB = 0
    if crossover(rsi, pvthis)
    stateHB := 1
    if crossunder(rsi, pvtlos)
    stateHB := 2
    stateHB := stateHB

    statechangeL = crossover(rsi, pvthis) and stateHB[1] == 2
    statechangeS = crossunder(rsi, pvtlos) and stateHB[1] == 1
    stateHB_col = stateHB == 1 ? color.blue : stateHB == 2 ? color.red : na

     

    //——————– DIAGONALS ——————– //
    // Adapted from ‘Trendlines’ – BacktestRookies

    ph = pvthi
    pl = pvtlo

    phv1 = valuewhen(ph, rsi[right], 0)
    phb1 = valuewhen(ph, bar_index[right], 0)
    phv2 = valuewhen(ph, rsi[right], 1)
    phb2 = valuewhen(ph, bar_index[right], 1)

    plv1 = valuewhen(pl, rsi[right], 0)
    plb1 = valuewhen(pl, bar_index[right], 0)
    plv2 = valuewhen(pl, rsi[right], 1)
    plb2 = valuewhen(pl, bar_index[right], 1)

    // TRENDLINE CODE
    // ————–
    get_slope(x1,x2,y1,y2)=>
    m = (y2-y1)/(x2-x1)

    get_y_intercept(m, x1, y1)=>
    b=y1-m*x1

    get_y(m, b, ts)=>
    Y = m * ts + b

    int res_x1 = na
    float res_y1 = na
    int res_x2 = na
    float res_y2 = na

    int sup_x1 = na
    float sup_y1 = na
    int sup_x2 = na
    float sup_y2 = na

    // Resistance
    res_x1 := ph ? phb1 : res_x1[1]
    res_y1 := ph ? phv1 : res_y1[1]
    res_x2 := ph ? phb2 : res_x2[1]
    res_y2 := ph ? phv2 : res_y2[1]

    res_m = get_slope(res_x1,res_x2,res_y1,res_y2)
    res_b = get_y_intercept(res_m, res_x1, res_y1)
    res_y = get_y(res_m, res_b, bar_index)

    // Support
    sup_x1 := pl ? plb1 : sup_x1[1]
    sup_y1 := pl ? plv1 : sup_y1[1]
    sup_x2 := pl ? plb2 : sup_x2[1]
    sup_y2 := pl ? plv2 : sup_y2[1]

    sup_m = get_slope(sup_x1,sup_x2,sup_y1,sup_y2)
    sup_b = get_y_intercept(sup_m, sup_x1, sup_y1)
    sup_y = get_y(sup_m, sup_b, bar_index)

    // Breaks
    long_break = rsi > res_y ? color.blue : na
    short_break = rsi < sup_y ? color.red : na
    no_break = rsi < res_y and rsi > sup_y ? color.gray : na

     

    //——————– Plots ——————– //

    r = plot(rsi, “RSI”, color = not showDiags ? color.gray : na, linewidth = 1, transp = 0)
    rl = plot(showDiags ? rsi : na, color = long_break, title=”RSI Long Diag”, style = plot.style_line, transp = 10, linewidth = 2)
    rs = plot(showDiags ? rsi : na, color = short_break, title=”RSI Short Diag”, style = plot.style_line, transp = 10, linewidth = 2)
    rnb = plot(showDiags ? rsi : na, color = no_break, title=”RSI No Diag”, style = plot.style_line, transp = 0, linewidth = 1)

    h = plot(80, “High”, color = stateHB_col, style = plot.style_circles, transp = 40)
    mhh = plot(66.67, “Resistance”, color = resistance, linewidth = 2, transp = 25)
    mh = plot(60, “Mid-High Band”, color = state == 2 or state == 3 ? state_col2 : na, style = plot.style_circles, linewidth = 1, transp = 50)
    ml = plot(40, “Mid-Low Band”, color = state == 1 or state == 3 ? state_col2 : na, style = plot.style_circles, linewidth = 1, transp = 50)
    mll = plot(33.33, “Support”, color = support, linewidth = 2, transp = 25)
    l = plot(20, “Low”, color = stateHB_col, style = plot.style_circles, transp = 40)

    fill(mh, ml, state_col2, title = “Trend State”, transp = 92)
    fill(ml, r, showTM3 ? fillH_col : na, title = “Bull 3:1 Momentum”, transp = 85)
    fill(mh, r, showTM3 ? fillL_col : na, title = “Bear 3:1 Momentum”, transp = 85)

    plotshape(HZB ? statechangeL : na, style=shape.triangleup,
    location=location.bottom, color=color.blue, transp = 25)
    plotshape(HZB ? statechangeS : na, style=shape.triangledown,
    location=location.top, color=color.red, transp = 25)

     

    //——————– RSI Divergences ——————– //
    // Adapted from built-in Divergences Script

    lbR = input(title=”Pivot Lookback Right”, defval=3)
    lbL = input(title=”Pivot Lookback Left”, defval=3)
    rangeUpper = input(title=”Max of Lookback Range”, defval=10)
    rangeLower = input(title=”Min of Lookback Range”, defval=3)
    plotBull = input(title=”Plot Bullish”, defval=true)
    plotHiddenBull = input(title=”Plot Hidden Bullish”, defval=true)
    plotBear = input(title=”Plot Bearish”, defval=true)
    plotHiddenBear = input(title=”Plot Hidden Bearish”, defval=true)
    bearColor = color.red
    bullColor = color.blue
    hiddenBullColor = color.new(color.blue, 25)
    hiddenBearColor = color.new(color.red, 25)
    textColor = color.white
    noneColor = color.new(color.white, 100)

    osc = rsi

    plFound = na(pivotlow(osc, lbL, lbR)) ? false : true
    phFound = na(pivothigh(osc, lbL, lbR)) ? false : true
    _inRange(cond) =>
    bars = barssince(cond == true)
    rangeLower <= bars and bars <= rangeUpper

    //——————————————————————————
    // Regular Bullish
    // Osc: Higher Low

    oscHL = osc[lbR] > valuewhen(plFound, osc[lbR], 1) and _inRange(plFound[1])

    // Price: Lower Low

    priceLL = close[lbR] < valuewhen(plFound, close[lbR], 1)
    bullCond = plotBull and priceLL and oscHL and plFound

    ///plot(
    /// plFound ? rsi[lbR] : na,
    // offset=-lbR,
    // title=”Regular Bullish”,
    // linewidth=2,
    // color=(bullCond ? bullColor : noneColor),
    // transp=50
    // )

    plotshape(
    bullCond ? rsi[lbR] : na,
    offset=-lbR,
    title=”Regular Bullish Label”,
    text=”D”,
    style=shape.labelup,
    location=location.absolute,
    color=bullColor,
    textcolor=textColor,
    transp=65
    )

    //——————————————————————————
    // Hidden Bullish
    // Osc: Lower Low

    oscLL = osc[lbR] < valuewhen(plFound, osc[lbR], 1) and _inRange(plFound[1])

    // Price: Higher Low

    priceHL = close[lbR] > valuewhen(plFound, close[lbR], 1)
    hiddenBullCond = plotHiddenBull and priceHL and oscLL and plFound

    plot(
    plFound ? rsi[lbR] : na,
    offset=-lbR,
    title=”Hidden Bullish”,
    linewidth=1,
    color=(hiddenBullCond ? hiddenBullColor : noneColor),
    transp=15
    )

    //plotshape(
    // hiddenBullCond ? rsi[lbR] : na,
    // offset=-lbR,
    // title=”Hidden Bullish Label”,
    // text=” H “,
    // style=shape.labelup,
    // location=location.absolute,
    // color=bullColor,
    // textcolor=textColor,
    // transp=75
    // )

    //——————————————————————————
    // Regular Bearish
    // Osc: Lower High

    oscLH = osc[lbR] < valuewhen(phFound, osc[lbR], 1) and _inRange(phFound[1])

    // Price: Higher High

    priceHH = close[lbR] > valuewhen(phFound, close[lbR], 1)

    bearCond = plotBear and priceHH and oscLH and phFound

    //plot(
    // phFound ? rsi[lbR] : na,
    // offset=-lbR,
    // title=”Regular Bearish”,
    // linewidth=2,
    // color=(bearCond ? bearColor : noneColor),
    // transp=50
    // )

    plotshape(
    bearCond ? rsi[lbR] : na,
    offset=-lbR,
    title=”Regular Bearish Label”,
    text=”D”,
    style=shape.labeldown,
    location=location.absolute,
    color=bearColor,
    textcolor=textColor,
    transp=65
    )

    //——————————————————————————
    // Hidden Bearish
    // Osc: Higher High

    oscHH = osc[lbR] > valuewhen(phFound, osc[lbR], 1) and _inRange(phFound[1])

    // Price: Lower High

    priceLH = close[lbR] < valuewhen(phFound, close[lbR], 1)

    hiddenBearCond = plotHiddenBear and priceLH and oscHH and phFound

    plot(
    phFound ? rsi[lbR] : na,
    offset=-lbR,
    title=”Hidden Bearish”,
    linewidth=1,
    color=(hiddenBearCond ? hiddenBearColor : noneColor),
    transp=15
    )

    //plotshape(
    // hiddenBearCond ? rsi[lbR] : na,
    // offset=-lbR,
    // title=”Hidden Bearish Label”,
    // text=” H “,
    // style=shape.labeldown,
    // location=location.absolute,
    // color=bearColor,
    // textcolor=textColor,
    // transp=75
    // )

    #241152
    JS

    Hi Yas,

    Still no good indicator found after 16 conversions from Trading View???

    #241153

    When you look at the result on the graph. It just does not worth loosing any time translating it…

    https://id.tradingview.com/script/XLgAKsWs-Koalafied-RSI

    #241164

    Without too much complexity, here is what you can do with RSI in relationship with trend…

    The best would be to use accurate trendlines or/and channels applied on RSI

    1 user thanked author for this post.
    #241179

    As you can see here below, the use of trend lines supports/resistances give more accurate information, rather than Cardwell ranges, because not only the range (level) of RSI have its importance, but also the direction torwards where it is moving…
    When the support will break, that does not mean price will go down : If the slope of the new direction of the RSI is moving slowly down and the RSI does move up and down upside a support which move slowly down => RSI will “reload” for an other move up ; while price can stay horizontale, or move slowly down, or even move slowly up (case of strong bull trend, if RSI have reached very high levels)

    #241181

    Price moving up while RSI “reloading” in a descending channel, because of the high level of the descending channel… Then an other shift up occurs, pumping the price even faster

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

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