0% found this document useful (0 votes)
189 views4 pages

CPR Dhaval

This document contains source code for generating daily, weekly, and monthly pivot point levels and plotting them on a chart. It defines functions for calculating pivot points, support and resistance levels from high, low, and close prices. It requests historical pivot point data and plots the levels, along with EMAs and shaded regions between them to indicate buy/sell signals. Input options allow displaying different time frame pivot points and changing EMA lengths.

Uploaded by

garbage Dump
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
189 views4 pages

CPR Dhaval

This document contains source code for generating daily, weekly, and monthly pivot point levels and plotting them on a chart. It defines functions for calculating pivot points, support and resistance levels from high, low, and close prices. It requests historical pivot point data and plots the levels, along with EMAs and shaded regions between them to indicate buy/sell signals. Input options allow displaying different time frame pivot points and changing EMA lengths.

Uploaded by

garbage Dump
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 4

// This source code is subject to the terms of the Mozilla Public License 2.

0 at
https://mozilla.org/MPL/2.0/
// © D_CryptoKnight
// 🆂🆄🅿🅻🅴🆇 🅲🅸🆃🆈 EDIT 5/2/2023

//@version=5

daily_cpr = input.int(title='Number of Daily CPR Back', defval=5, minval=0)

new_bar(res) =>
ta.change(time(res)) != 0
new_period(condition, src) =>
result = 0.0
result := condition ? src : result[1]
result

pivot = (high + low + close) / 3.0


bc = (high + low) / 2.0
tc = pivot - bc + pivot
R1 = 2 * pivot - low
S1 = 2 * pivot - high
R2 = pivot + high - low
S2 = pivot - (high - low)
R3 = high + 2 * (pivot - low)
S3 = low - 2 * (high - pivot)
PH = high
PL = low

//Daily Central Pivot Range

sd = input(false, title='Show Daily Pivots?')

dpp = request.security(syminfo.tickerid, 'D', pivot[1],


lookahead=barmerge.lookahead_on)
dbc = request.security(syminfo.tickerid, 'D', bc[1],
lookahead=barmerge.lookahead_on)
dtc = request.security(syminfo.tickerid, 'D', tc[1],
lookahead=barmerge.lookahead_on)
dR1 = request.security(syminfo.tickerid, 'D', R1[1],
lookahead=barmerge.lookahead_on)
dS1 = request.security(syminfo.tickerid, 'D', S1[1],
lookahead=barmerge.lookahead_on)
dR2 = request.security(syminfo.tickerid, 'D', R2[1],
lookahead=barmerge.lookahead_on)
dS2 = request.security(syminfo.tickerid, 'D', S2[1],
lookahead=barmerge.lookahead_on)
dR3 = request.security(syminfo.tickerid, 'D', R3[1],
lookahead=barmerge.lookahead_on)
dS3 = request.security(syminfo.tickerid, 'D', S3[1],
lookahead=barmerge.lookahead_on)
dPH = request.security(syminfo.tickerid, 'D', PH[1],
lookahead=barmerge.lookahead_on)
dPL = request.security(syminfo.tickerid, 'D', PL[1],
lookahead=barmerge.lookahead_on)

one_day = 1000 * 60 * 60 * 24
new_day = daily_cpr > 0 and timenow - time < one_day * daily_cpr and new_bar('D')
dpp_ = new_period(new_day, dpp)
dtc_ = new_period(new_day, dtc)
dbc_ = new_period(new_day, dbc)
dR1_ = new_period(new_day, dR1)
dS1_ = new_period(new_day, dS1)
dR2_ = new_period(new_day, dR2)
dS2_ = new_period(new_day, dS2)
dR3_ = new_period(new_day, dR3)
dS3_ = new_period(new_day, dS3)
dPH_ = new_period(new_day, dPH)
dPL_ = new_period(new_day, dPL)

TC=plot(timeframe.isintraday ? dtc_ >= dbc_ ? dtc_ : dbc_ : na, title='Daily TC',


style=plot.style_circles, color=color.new(#ab47bc, 0), linewidth=1)
plot(timeframe.isintraday ? dpp_ : na, title='Daily PP', style=plot.style_circles,
color=color.new(#ab47bc, 0), linewidth=1)
BC=plot(timeframe.isintraday ? dtc_ >= dbc_ ? dbc_ : dtc_ : na, title='Daily BC',
style=plot.style_circles, color=color.new(#ab47bc, 0), linewidth=1)

fill(TC, BC, title=' CPR BG', color=color.rgb(226, 59, 255, 85))

HR1=plot(dR1_, title='R1', title='Daily TC', style=plot.style_circles,


color=color.new(#ca1d1d, 0), linewidth=1)
HR2=plot(dR2_, title='R2', title='Daily TC', style=plot.style_circles,
color=color.new(#ca1d1d, 0), linewidth=1)
HR3=plot(dR3_, title='R3', title='Daily TC', style=plot.style_circles,
color=color.new(#ca1d1d, 0), linewidth=1)
LS1=plot(dS1_, title='S1', title='Daily TC', style=plot.style_circles,
color=color.new(#4CAF50, 0), linewidth=1)
LS2=plot(dS2_, title='S2', title='Daily TC', style=plot.style_circles,
color=color.new(#4CAF50, 0), linewidth=1)
LS3=plot(dS3_, title='S3', title='Daily TC', style=plot.style_circles,
color=color.new(#4CAF50, 0), linewidth=1)
fill(TC, HR1, title=' TC-R1 BG', color=#f8a3a333)
fill(HR2, HR1, title=' R1-R2 BG', color=#f8a3a333)
fill(HR2, HR3, title=' R2-R3 BG', color=#f8a3a333)

fill(BC, LS1, title=' BC-S1 BG', color=#c9f8a333)


fill(LS2, LS1, title=' S1-S2 BG', color=#c9f8a333)
fill(LS2, LS3, title=' S2-S3 BG', color=#c9f8a333)

plot(dPH_, title='Previous Day High', style=plot.style_circles,


color=color.new(#1353a7, 0), linewidth=1)
plot(dPL_, title='Previous Day Low', style=plot.style_circles,
color=color.new(#1353a7, 0), linewidth=1)

//Weekly

sw = input(false, title='Show Weekly Pivots?')

wtime_pvt = request.security(syminfo.tickerid, 'W', pivot[1],


lookahead=barmerge.lookahead_on)
wtime_R1 = request.security(syminfo.tickerid, 'W', R1[1],
lookahead=barmerge.lookahead_on)
wtime_S1 = request.security(syminfo.tickerid, 'W', S1[1],
lookahead=barmerge.lookahead_on)
wtime_R2 = request.security(syminfo.tickerid, 'W', R2[1],
lookahead=barmerge.lookahead_on)
wtime_S2 = request.security(syminfo.tickerid, 'W', S2[1],
lookahead=barmerge.lookahead_on)

plot(sw and wtime_pvt ? wtime_pvt : na, title='Weekly pvt',


style=plot.style_circles, color=color.rgb(189, 75, 0), linewidth=2)
plot(sw and wtime_R1 ? wtime_R1 : na, title='Weekly R1', style=plot.style_circles,
color=color.rgb(189, 75, 0), linewidth=2)
plot(sw and wtime_S1 ? wtime_S1 : na, title='Weekly S1', style=plot.style_circles,
color=color.rgb(189, 75, 0), linewidth=2)
plot(sw and wtime_R2 ? wtime_R2 : na, title='Weekly R2', style=plot.style_circles,
color=color.rgb(189, 75, 0), linewidth=2)
plot(sw and wtime_S2 ? wtime_S2 : na, title='Weekly S2', style=plot.style_circles,
color=color.rgb(189, 75, 0), linewidth=2)

//Monthly pvts

sm = input(true, title='Show Monthly Pivots?')

mtime_pvt = request.security(syminfo.tickerid, 'M', pivot[1],


lookahead=barmerge.lookahead_on)
mtime_R1 = request.security(syminfo.tickerid, 'M', R1[1],
lookahead=barmerge.lookahead_on)
mtime_S1 = request.security(syminfo.tickerid, 'M', S1[1],
lookahead=barmerge.lookahead_on)
mtime_R2 = request.security(syminfo.tickerid, 'M', R2[1],
lookahead=barmerge.lookahead_on)
mtime_S2 = request.security(syminfo.tickerid, 'M', S2[1],
lookahead=barmerge.lookahead_on)

plot(sm and mtime_pvt ? mtime_pvt : na, title='Monthly pvt',


style=plot.style_circles, color=color.rgb(147, 74, 196, 17), linewidth=2)
plot(sm and mtime_R1 ? mtime_R1 : na, title='Monthly R1', style=plot.style_circles,
color=color.rgb(147, 74, 196, 17), linewidth=2)
plot(sm and mtime_S1 ? mtime_S1 : na, title='Monthly S1', style=plot.style_circles,
color=color.rgb(147, 74, 196, 17), linewidth=2)
plot(sm and mtime_R2 ? mtime_R2 : na, title='Monthly R2', style=plot.style_circles,
color=color.rgb(147, 74, 196, 17), linewidth=2)
plot(sm and mtime_S2 ? mtime_S2 : na, title='Monthly S2', style=plot.style_circles,
color=color.rgb(147, 74, 196, 17), linewidth=2)

//study(title="Colored EMA", shorttitle="Intraday Strategy-Dhavs", overlay=true)

// Script settings
emaLength = input.int(title='EMA Length', defval=200, minval=2)
emaSource = input(title='EMA Source', defval=close)

// Get EMA and plot it


ema = ta.ema(emaSource, emaLength)
plot(ema, color=close[1] > ema and close > ema ? color.rgb(11, 138, 16) :
color.rgb(187, 13, 13), linewidth=4)

// This source code is subject to the terms of the Mozilla Public License 2.0 at
https://mozilla.org/MPL/2.0/
// © D_CryptoKnight
indicator(title='𝗜𝗻𝘁𝗿𝗮𝗱𝗮𝘆-𝗗𝗵𝗮𝘃𝘀', shorttitle='𝗜𝗻𝘁𝗿𝗮𝗱𝗮𝘆-𝗗𝗵𝗮𝘃𝘀', overlay=true)

// === INPUTS ===


src = input(close)

ema1 = input(20, title='EMA-20')


ema2 = input(50, title='EMA-50')

pema1 = ta.ema(src, ema1)


pema2 = ta.ema(src, ema2)

//fil

ema1plot = plot(pema1, color=color.new(#059440, 0), style=plot.style_line,


linewidth=2, title='EMA-20')
ema2plot = plot(pema2, color=color.new(#c00d0d, 0), style=plot.style_line,
linewidth=2, title='EMA 50')

fill(ema1plot, ema2plot, color=pema1 > pema2 ? #056e31 : #970909, editable=true,


transp=70)

You might also like