How To Trade With CPR

How To Trade With CPR

    CPR (Central Pivot Range) is a trading indicator used in technical analysis to identify potential support and resistance levels in financial markets. It is derived from the calculation of the central pivot point, which is the average of the high, low, and close prices of the previous trading session. The CPR indicator then constructs upper and lower boundaries around the central pivot point, forming a range. Traders use this range to determine potential areas of price reversal or continuation. By analyzing price action within the CPR, traders can make informed decisions about entry and exit points, setting stop-loss and take-profit levels for their trades.

    The calculation for the traditional Central Pivot Range (CPR) involves three key components: the central pivot point (PP), the upper range (R1), and the lower range (S1). Here's how you can calculate them:

            pivot = (High + Low + Close) / 3
            BC = (High + Low) / 2
            TC = pivot - BC + pivot

            R1 = pivot * 2 - Low
            R2 = pivot + High - Low
            R3 = High + 2 * (pivot - Low)

            S1 = pivot * 2 - High
            S2 = pivot - (High - Low)
            S3 = Low - 2 * (High - pivot)

    In the above calculations, "High" refers to the highest price of the previous trading session, "Low" represents the lowest price, and "Close" denotes the closing price. The central pivot point acts as a reference level, while the upper and lower ranges provide potential resistance and support levels, respectively, for traders to consider when analyzing price movements.


CODE :- 

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

//@version=5
indicator(title='CPR + VWAP', overlay=true)
tfi = input.string("D",options=["D","W","M"])

// tf = timeframe.isintraday ? 'D' : timeframe.isdaily ? 'W' : timeframe.isweekly ? 'M' : ''
tf = tfi
nr = input.float(0.50,title="Narrow Range",minval=0.01, step=0.01)

d_high = request.security(syminfo.tickerid, tf, high[1], barmerge.gaps_off, barmerge.lookahead_on)
d_low = request.security(syminfo.tickerid, tf, low[1], barmerge.gaps_off, barmerge.lookahead_on)
d_close = request.security(syminfo.tickerid, tf, close[1], barmerge.gaps_off, barmerge.lookahead_on)

pivot = (d_high + d_low + d_close) / 3
BC = (d_high + d_low) / 2
TC = pivot - BC + pivot

R1 = pivot * 2 - d_low
R2 = pivot + d_high - d_low
R3 = d_high + 2 * (pivot - d_low)

S1 = pivot * 2 - d_high
S2 = pivot - (d_high - d_low)
S3 = d_low - 2 * (d_high - pivot)

colb = pivot == pivot[1] ? color.blue : na
colg = pivot == pivot[1] ? color.green : na
colr = pivot == pivot[1] ? color.red : na

plot(pivot, title='CP', color=colb)
bc = plot(BC, title='BC', color=colb)
tc = plot(TC, title='TC', color=colb)

fill(bc, tc, color=colb, transp=90)
plot(R1, title='R1', color=colg)
plot(R2, title='R2', color=colg)
plot(R3, title='R3', color=colg)

plot(S1, title='S1', color=colr)
plot(S2, title='S2', color=colr)
plot(S3, title='S3', color=colr)

plot(ta.vwap, color=color.new(color.white, 0), linewidth=2)

buy = (TC-BC)*100/close < nr and ta.crossover(close,R1) and close > ta.vwap
sell = (TC-BC)*100/close < nr and ta.crossunder(close,S1) and close < ta.vwap
plot(TC-BC)
plotshape(buy , style = shape.triangleup , location = location.belowbar , color = #035e07 , size = size.small)
plotshape(sell , style = shape.triangledown , location = location.abovebar , color = #b92ad8 , size = size.small)

Video Tutorial :-


       


Comments

Popular posts from this blog

How to develop Screener in Pine Script TradingView

Import Chartink data into Python

Import Nifty Option Chain With Python