Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 3

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

0 at
https://mozilla.org/MPL/2.0/
// © D_CryptoKnight

//@version=4
//study(title="CPR + Pivots+ EMA by Dhavs ", shorttitle="CPR+Pivots+EMA by Dhavs",
overlay=true)

daily_cpr = input (title="Number of Daily CPR Back", type= input.integer ,


defval=5, minval=0)

new_bar(res) => 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 = security( syminfo.tickerid , 'D', pivot[1], lookahead=barmerge.lookahead_on)


dbc = security( syminfo.tickerid , 'D', bc[1], lookahead=barmerge.lookahead_on)
dtc = security( syminfo.tickerid , 'D', tc[1], lookahead=barmerge.lookahead_on)
dR1= security( syminfo.tickerid , 'D', R1[1], lookahead=barmerge.lookahead_on)
dS1 = security( syminfo.tickerid , 'D', S1[1], lookahead=barmerge.lookahead_on)
dR2 = security( syminfo.tickerid , 'D', R2[1], lookahead=barmerge.lookahead_on)
dS2 = security( syminfo.tickerid , 'D', S2[1], lookahead=barmerge.lookahead_on)
dR3 = security( syminfo.tickerid , 'D', R3[1], lookahead=barmerge.lookahead_on)
dS3 = security( syminfo.tickerid , 'D', S3[1], lookahead=barmerge.lookahead_on)
dPH = security( syminfo.tickerid , 'D', PH[1], lookahead=barmerge.lookahead_on)
dPL = 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)
plot( timeframe.isintraday ? (dtc_ >= dbc_ ? dtc_ : dbc_) : na, title="Daily TC",
style= plot.style_circles , color=#ffffff, linewidth=1)
plot( timeframe.isintraday ? dpp_ : na, title="Daily PP", style=
plot.style_circles, color=#ffffff, linewidth=1)
plot( timeframe.isintraday ? (dtc_ >= dbc_ ? dbc_ : dtc_) : na, title="Daily BC",
style= plot.style_circles, color=#ffffff, linewidth=1)

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


color=#ca1d1d, linewidth=1)
plot(dR2_ , title='R2', title="Daily TC", style= plot.style_circles ,
color=#ca1d1d, linewidth=1)
plot(dR3_ , title='R3', title="Daily TC", style= plot.style_circles ,
color=#ca1d1d, linewidth=1)
plot(dS1_ , title='S1', title="Daily TC", style= plot.style_circles ,
color=#4CAF50, linewidth=1)
plot(dS2_ , title='S2', title="Daily TC", style= plot.style_circles ,
color=#4CAF50, linewidth=1)
plot(dS3_ , title='S3', title="Daily TC", style= plot.style_circles ,
color=#4CAF50, linewidth=1)

plot(dPH_ , title='Previous Day High', style= plot.style_circles , color=#1353a7,


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

//Weekly

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

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


lookahead=barmerge.lookahead_on)
wtime_R1 = security(syminfo.tickerid, 'W', R1[1], lookahead=barmerge.lookahead_on)
wtime_S1 = security(syminfo.tickerid, 'W', S1[1], lookahead=barmerge.lookahead_on)
wtime_R2 = security(syminfo.tickerid, 'W', R2[1], lookahead=barmerge.lookahead_on)
wtime_S2 = 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 = security(syminfo.tickerid, 'M', pivot[1],


lookahead=barmerge.lookahead_on)
mtime_R1 = security(syminfo.tickerid, 'M', R1[1], lookahead=barmerge.lookahead_on)
mtime_S1 = security(syminfo.tickerid, 'M', S1[1], lookahead=barmerge.lookahead_on)
mtime_R2 = security(syminfo.tickerid, 'M', R2[1], lookahead=barmerge.lookahead_on)
mtime_S2 = 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)

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

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

// Get EMA and plot it


ema = 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
//@version=2
study(title="Intraday-Dhavs", shorttitle="Intraday-Dhavs", overlay=true)

// === INPUTS ===


src = input(close)

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

pema1 = ema(src, ema1)


pema2 = ema(src, ema2)

//fil

ema1plot = plot(pema1, color=#059440,style=plot.style_line , linewidth=2,


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

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


editable=true)

You might also like