0% found this document useful (0 votes)
14 views2 pages

Pop Magic

The document is a TradingView Pine Script strategy named 'POP_Magic' that implements various technical indicators including EMA (Exponential Moving Average) and VWAP (Volume Weighted Average Price). It allows users to visualize buy and sell signals based on trend changes and provides options to display different EMAs and highlight trends. The script also includes alert conditions for buy, sell, and direction change signals.

Uploaded by

Parvej Makandar
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)
14 views2 pages

Pop Magic

The document is a TradingView Pine Script strategy named 'POP_Magic' that implements various technical indicators including EMA (Exponential Moving Average) and VWAP (Volume Weighted Average Price). It allows users to visualize buy and sell signals based on trend changes and provides options to display different EMAs and highlight trends. The script also includes alert conditions for buy, sell, and direction change signals.

Uploaded by

Parvej Makandar
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/ 2

//@version=4

strategy("POP_Magic", overlay = true, format=format.price, precision=2)


showEMA9 = input(title="Show EMA-9", type=input.bool, defval=true)
showEMA20 = input(title="Show EMA-20", type=input.bool, defval=true)
showEMA50 = input(title="Show EMA-50", type=input.bool, defval=true)
showVWAP = input(title="Show VWAP", type=input.bool, defval=true)
Periods = input(title="ATR Period", type=input.integer, defval=2)
src = input(hl2, title="Source")
Multiplier = input(title="ATR Multiplier", type=input.float, step=0.1, defval=2.0)
changeATR= input(title="Change ATR Calculation Method ?", type=input.bool,
defval=true)
showsignals = input(title="Show Buy/Sell Signals ?", type=input.bool, defval=true)
highlighting = input(title="Highlighter On/Off ?", type=input.bool, defval=true)
atr2 = sma(tr, Periods)
atr= changeATR ? atr(Periods) : atr2
up=src-(Multiplier*atr)
up1 = nz(up[1],up)
up := close[1] > up1 ? max(up,up1) : up
dn=src+(Multiplier*atr)
dn1 = nz(dn[1], dn)
dn := close[1] < dn1 ? min(dn, dn1) : dn
trend = 1
trend := nz(trend[1], trend)
trend := trend == -1 and close > dn1 ? 1 : trend == 1 and close < up1 ? -1 : trend
upPlot = plot(trend == 1 ? up : na, title="Up Trend", style=plot.style_linebr,
linewidth=2, color=color.green)
buySignal = trend == 1 and trend[1] == -1
plotshape(buySignal ? up : na, title="UpTrend Begins", location=location.absolute,
style=shape.circle, size=size.tiny, color=color.green, transp=0)
plotshape(buySignal and showsignals ? up : na, title="Buy", text="Buy",
location=location.absolute, style=shape.labelup, size=size.tiny, color=color.green,
textcolor=color.white, transp=0)
dnPlot = plot(trend == 1 ? na : dn, title="Down Trend", style=plot.style_linebr,
linewidth=2, color=color.red)
sellSignal = trend == -1 and trend[1] == 1
plotshape(sellSignal ? dn : na, title="DownTrend Begins",
location=location.absolute, style=shape.circle, size=size.tiny, color=color.red,
transp=0)
plotshape(sellSignal and showsignals ? dn : na, title="Sell", text="Sell",
location=location.absolute, style=shape.labeldown, size=size.tiny, color=color.red,
textcolor=color.white, transp=0)
mPlot = plot(ohlc4, title="", style=plot.style_circles, linewidth=0)
longFillColor = highlighting ? (trend == 1 ? color.green : color.white) :
color.white
shortFillColor = highlighting ? (trend == -1 ? color.red : color.white) :
color.white
fill(mPlot, upPlot, title="UpTrend Highligter", color=longFillColor)
fill(mPlot, dnPlot, title="DownTrend Highligter", color=shortFillColor)
alertcondition(buySignal, title="SuperTrend Buy", message="SuperTrend Buy!")
alertcondition(sellSignal, title="SuperTrend Sell", message="SuperTrend Sell!")
changeCond = trend != trend[1]
alertcondition(changeCond, title="SuperTrend Direction Change", message="SuperTrend
has changed direction!")

//////////////////////////////////////////////// EMA -
5/20/50 ///////////////////////////////////////////////
EMA9_Len = input(9, minval=1, title="EMA9_Length")
//EMA5_src = input(close, title="EMA9_Source")
//EMA5_offset = input(title="EMA9_Offset", type=input.integer, defval=0, minval=-
500, maxval=500)
EMA9_out = ema(close, EMA9_Len)
plot(showEMA9 ? EMA9_out:na, title="EMA9", color=color.maroon,
offset=0,linewidth=2)

EMA20_Len = input(20, minval=1, title="EMA20_Length")


//EMA20_src = input(close, title="EMA20_Source")
//EMA20_offset = input(title="EMA20_Offset", type=input.integer, defval=0,
minval=-500, maxval=500)
EMA20_out = ema(close, EMA20_Len)
plot(showEMA20 ? EMA20_out:na, title="EMA20", color=color.olive,
offset=0,linewidth=2)

EMA50_Len = input(50, minval=1, title="EMA50_Length")


//EMA50_src = input(close, title="EMA50_Source")
//EMA50_offset = input(title="EMA50_Offset", type=input.integer, defval=0,
minval=-500, maxval=500)
EMA50_out = ema(close, EMA50_Len)
plot(showEMA50 ? EMA50_out:na, title="EMA50", color=color.blue,
offset=0,linewidth=2)

///////////////////////////////////////////////////
VWAP /////////////////////////////////////////////////////////

//vwaplength = input(title="VWAP Length", type=input.integer, defval=1)


//cvwap = ema(vwap,vwaplength)
cvwap1 = vwap(hlc3)
plotvwap = plot(showVWAP ? cvwap1 : na,title="VWAP",color=color.black,
transp=0, linewidth=2)

You might also like