Andrew cardwell Strategy on RSI
Forums › ProRealTime English forum › ProBuilder support › Andrew cardwell Strategy on RSI
- This topic has 12 replies, 5 voices, and was last updated 6 days ago by LucasBest.
-
-
12/03/2024 at 6:40 PM #241048
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
12/04/2024 at 1:40 AM #241061Hi 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 ?
12/04/2024 at 11:20 AM #241082Hi,
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)
PRT RSI12345678910111213N=14 //LookBack PeriodUP = MAX(0, close - close[1])DOWN = MAX(0, close[1] - close)upMA = WilderAverage[N](UP)downMA = WilderAverage[N](DOWN)RS = upMA / downMAmyRSI = 100 - 100 / (1 + RS)Return myRSI, 20,40,60,80RSI Andrew Cardwell123456789101112131415161718N=14 //LookBack PeriodUP = MAX(0, close - close[1])DOWN = MAX(0, close[1] - close)upMA = WilderAverage[N](UP)downMA = WilderAverage[N](DOWN)RS = upMA / downMAmyRSI = 100 - 100 / (1 + RS)Range2040=Summation[N](myRSI>0 and myRSI<40)Range4060=Summation[N](myRSI>40 and myRSI<60)Range6080=Summation[N](myRSI>60 and myRSI<100)RETURN Range6080 as "60-80"style(histogram)Coloured("green"),Range2040 as "20-40"style(histogram)coloured("Red"), Range4060 as "40-60"style(histogram)coloured("Yellow")1 user thanked author for this post.
12/04/2024 at 1:36 PM #241087Basing the code on what you passed to JS here is an example strategy to get you started testing.
123456789101112131415161718192021222324252627N=14 //LookBack PeriodUP = MAX(0, close - close[1])DOWN = MAX(0, close[1] - close)upMA = WilderAverage[N](UP)downMA = WilderAverage[N](DOWN)RS = upMA / downMAmyRSI = 100 - 100 / (1 + RS)Range2040=Summation[N](myRSI>0 and myRSI<40)Range4060=Summation[N](myRSI>40 and myRSI<60)Range6080=Summation[N](myRSI>60 and myRSI<100)if Range2040 crosses over Range4060 and Range6080=0 thensellshort 1 contract at marketset target $profit 800set stop $loss 400endifif Range6080 crosses over Range4060 and Range2040=0 thenbuy 1 contract at marketset target $profit 800set stop $loss 400endifPlease 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.
12/04/2024 at 2:57 PM #241096hi 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
12/04/2024 at 3:24 PM #24109712/04/2024 at 7:20 PM #241116First 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…
12/05/2024 at 7:31 AM #241127here 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 := statestate_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 : nabgcolor(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 : naplot(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 : 0pvthis = 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 := stateHBstatechangeL = 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’ – BacktestRookiesph = pvthi
pl = pvtlophv1 = 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*x1get_y(m, b, ts)=>
Y = m * ts + bint res_x1 = na
float res_y1 = na
int res_x2 = na
float res_y2 = naint 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 ScriptlbR = 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 LowoscHL = 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 LowoscLL = 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 plFoundplot(
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 HighoscLH = 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 HighoscHH = 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
// )12/05/2024 at 3:04 PM #24115212/05/2024 at 3:28 PM #241153When you look at the result on the graph. It just does not worth loosing any time translating it…
12/05/2024 at 11:37 PM #24116412/06/2024 at 11:52 AM #241179As 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)12/06/2024 at 12:22 PM #241181 -
AuthorPosts
Find exclusive trading pro-tools on