Calculation of a TP trough RSI Divergence
Forums › ProRealTime English forum › General trading discussions › Calculation of a TP trough RSI Divergence
- This topic has 26 replies, 2 voices, and was last updated 2 years ago by Zigo.
-
-
12/21/2020 at 5:28 PM #154753
I note that in most cases, and speaking of more than 75%, of cases, the calculated Target price (TP) is met. The chart shows both the purchase price and the TP. A green rectangle, for upward rates and a red rectangle for downward rates, indicates the 2 candles where the divergence ends. The TP (line) is printed in the graph, green for upward calculation and orange for downward calculation.
Depending on the timeframe, purchased (OB) and sold (OS) are adjusted. The period for the RSI is usually 11 and not 14. The variables are for period (n) for overbought (OB) and for over sold (OS). If someone feels called to test these kinds of parameters in a backtest. In that case, I would kindly like to know the results.
12/21/2020 at 5:35 PM #15475512/21/2020 at 5:53 PM #154757The coding for RSI TP is based on a lookback period of 29 (see line 53 and 73), if you change this value, for example to the first top (bottom) the calculation becomes different so as the results. Maybe if backtest there would be a variable number instead of 29 it could be optimised.
Here is the coding:
RSI with TP123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384// --- settings//Zigo 21/12/2020RSIp=n //RSI periodonce obLevel=ob //overbought levelonce osLevel=os //oversold levelminimalBars=5 //minimal count of bars where RSI is ob or os// --- end of settingsirsi = rsi[RSIp]ob = irsi>obLevelos = irsi<osLevelif ob thenif not ob[1] thenmaxrsi = 0maxprice = 0firstobbar = barindexendifmaxrsi=max(maxrsi,irsi)maxprice=max(maxprice,high)if maxrsi<>maxrsi[1] thenmaxrsibar=barindexendifendifif os thenif not os[1] thenminrsi = 100minprice = close*100firstosbar = barindexendifminrsi=min(minrsi,irsi)minprice=min(minprice,low)if minrsi<>minrsi[1] thenminrsibar=barindexendifendifOnce divsell=0if irsi crosses under obLevel then//verif divergencediv = maxprice>oldmaxprice and maxrsi<oldmaxrsi and (barindex-firstobbar)>=minimalBarsif div thens=(High[0]+low[0])/2drawsegment(oldmaxrsibar,oldmaxRSI,maxrsibar,maxRSI) coloured(255,255,0, 255)DRAWRECTANGLE(barindex, low-AverageTrueRange[14](close), barindex[1], low[1]-3*AverageTrueRange[14](close))coloured(255,55,25,255)DRAWTEXT("Start Div RSI Down", barindex, High+2.5*AverageTrueRange[14](close),dialog, standard, 15)coloured(205,170,120,255)DRAWTEXT("Enter Short = #s#", barindex, High+ 1.5*AverageTrueRange[14](close),dialog, standard, 15)coloured(205,170,120,255)TPSh= (Lowest[29](low)+ (maxprice-oldmaxprice))DRAWHLINE(TPsh)coloured(255,0,0,35)DRAWTEXT("TargetLine = #TPSh#", barindex, TPSh-0.5*AverageTrueRange[14](close),dialog, standard, 12)coloured(205,205,0)divsell=sendifoldmaxrsi = maxrsioldmaxprice = maxpriceoldmaxrsibar = maxrsibarendifOnce divbuy=0if irsi crosses over osLevel then//verif divergencediv = minprice<oldminprice and minrsi>oldminrsi and (barindex-firstosbar)>=minimalBarsif div thenb=(open)drawsegment(oldminrsibar,oldminrsi,minrsibar,minrsi) coloured(0,200,0)DRAWRECTANGLE(barindex, High+AverageTrueRange[14](close), barindex[1], high[1]+4*AverageTrueRange[14](close))coloured(0,125,175,255)DRAWTEXT("Start Div RSI Up", barindex, Low-2*AverageTrueRange[14](close), dialog, standard,15)coloured(125,255,125,255)DRAWTEXT("Enter Long <= #b#", barindex, low-1.5*AverageTrueRange[14](close),dialog, standard, 15)coloured(0,255,0,255)TPL=(Highest[29](High)- (minprice - oldminprice))DRAWHLINE(TPL)coloured(0,255,0,35)DRAWTEXT("TargetLine = #TPL#", barindex, TPL+0.5*AverageTrueRange[14](close),dialog, standard, 12)coloured(0,255,0,255)divbuy=bendifoldminrsi = minrsioldminprice = minpriceoldminrsibar = minrsibarendifreturn12/21/2020 at 6:05 PM #15475812/21/2020 at 6:09 PM #15476112/23/2020 at 12:23 PM #15497312/23/2020 at 1:03 PM #15498212/25/2020 at 3:00 PM #155192At stagnant rates it is sometimes easier to make determinations. Today I looked at the Dow Jones on day chart and established a double “negative divergence” for the RSI (14), albeit with the OB and OS settings 60, 40.
It is nice that the SMI (14,3,5) with OB and OS settings of 40 and -40 respectively shows a similar “negative divergence”. The CCI(18) with the OB and OS settings of 100, -100 closes, also the row with a “negative divergence”.
The future will show whether these divergences will have an impact on the rates.
12/25/2020 at 3:03 PM #15519301/05/2021 at 9:15 PM #15652001/06/2021 at 10:07 AM #156560Thanks Zigo, ive been wondering how to calculate a TP from an indicator for a while as im just using fixed values at the moment.
is the general consensus that RSI is the “best” way to do TPs? Have you tried others?
Also for Stops I was playing with the idea of using ichimoku cloud breakouts/breakthrus, but couldnt get it to work, have you worked on any indicator based stop ideas?
thanks again. Awesome code.
01/06/2021 at 10:20 PM #15667701/07/2021 at 8:41 AM #15669301/07/2021 at 8:55 AM #15670001/07/2021 at 9:37 AM #156716 -
AuthorPosts
Find exclusive trading pro-tools on