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

Pull Back Strategy

The document is a TradingView script for an indicator called 'EMA STOCK BURNER' that utilizes two Exponential Moving Averages (EMAs) to generate buy and sell signals based on price crossovers. It includes customizable parameters for EMA sources, periods, and colors, along with options for displaying signal labels and alerts. Additionally, it features a Gaussian smoothing function and a dashboard for displaying repainting mode status.

Uploaded by

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

Pull Back Strategy

The document is a TradingView script for an indicator called 'EMA STOCK BURNER' that utilizes two Exponential Moving Averages (EMAs) to generate buy and sell signals based on price crossovers. It includes customizable parameters for EMA sources, periods, and colors, along with options for displaying signal labels and alerts. Additionally, it features a Gaussian smoothing function and a dashboard for displaying repainting mode status.

Uploaded by

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

//@version=5

indicator("EMA STOCK BURNER", overlay=true, max_labels_count=500)

gr0 = 'Pullback'
pbStep = input(5, 'Backstep of Pullback', group=gr0)

gr1 = 'Double EMA'


emaSrc = input.source(close, 'EMA 1 Source', group=gr1)
emaLen = input(50, 'EMA 1 Period', group=gr1)
emaCol = input.color(color.blue, 'EMA 1 Color', group=gr1)
ema1 = ta.ema(emaSrc, emaLen)
plot(ema1, 'EMA 1', color=emaCol)

emaSrc1 = input.source(close, 'EMA 2 Source', group=gr1)


emaLen1 = input(200, 'EMA 2 Period', group=gr1)
emaCol1 = input.color(color.red, 'EMA 2 Color', group=gr1)
ema2 = ta.ema(emaSrc1, emaLen1)
plot(ema2, 'EMA 2', color=emaCol1)

buySignal = ta.crossover (close, ema1) and ema1>ema2 and


close[pbStep]>ema1
sellSignal = ta.crossunder(close, ema1) and ema1<ema2 and
close[pbStep]<ema1

gr4 = 'Styling'
showPattern = input(true, 'Show Pattern Name', group=gr4)
textCol = input.color(color.white, 'Text Color', group=gr4)
bullText = input.string('Buy', 'Buy Signal', inline='ul', group=gr4)
bullCol = input.color(color.green, '', '', 'ul', gr4)
bearText = input('Sell', 'Sell Signal', '', 'ms', gr4)
bearCol = input.color(color.red, '', '', 'ms', gr4)

fLabel(x, y)=>
labelStyle = y==high? label.style_label_down : label.style_label_up
labelCol = y==high? bearCol : bullCol
labelText = y==high? bearText : bullText
//labelText = showPattern? labelText_ + pn : labelText_
if x
label.new(bar_index, y, labelText, style=labelStyle,
color=labelCol, size=size.small, textcolor=textCol)

fLabel(buySignal , low )
fLabel(sellSignal, high)

alertcondition(buySignal, 'Buy Signal', 'Buy!!')


alertcondition(sellSignal, 'Sell Signal', 'Sell!!')

//-------------------------------------------------------------------------
-----
//Settings
//-------------------------------------------------------------------------
----{
h = input.float(8.,'Bandwidth', minval = 0)
mult = input.float(3., minval = 0)
src = input(close, 'Source')

repaint = input(true, 'Repainting Smoothing', tooltip = 'Repainting is an


effect where the indicators historical output is subject to change over
time. Disabling repainting will cause the indicator to output the endpoints
of the calculations')

//Style
upCss = input.color(color.teal, 'Colors', inline = 'inline1', group =
'Style')
dnCss = input.color(color.red, '', inline = 'inline1', group = 'Style')

//-------------------------------------------------------------------------
----}
//Functions
//-------------------------------------------------------------------------
----{
//Gaussian window
gauss(x, h) => math.exp(-(math.pow(x, 2)/(h * h * 2)))

//-------------------------------------------------------------------------
----}
//Append lines
//-------------------------------------------------------------------------
----{
n = bar_index

var ln = array.new_line(0)

if barstate.isfirst and repaint


for i = 0 to 499
array.push(ln,line.new(na,na,na,na))

//-------------------------------------------------------------------------
----}
//End point method
//-------------------------------------------------------------------------
----{
var coefs = array.new_float(0)
var den = 0.

if barstate.isfirst and not repaint


for i = 0 to 499
w = gauss(i, h)
coefs.push(w)

den := coefs.sum()
out = 0.
if not repaint
for i = 0 to 499
out += src[i] * coefs.get(i)
out /= den
mae = ta.sma(math.abs(src - out), 499) * mult

upper = out + mae


lower = out - mae

//-------------------------------------------------------------------------
----}
//Compute and display NWE
//-------------------------------------------------------------------------
----{
float y2 = na
float y1 = na

nwe = array.new<float>(0)
if barstate.islast and repaint
sae = 0.
//Compute and set NWE point
for i = 0 to math.min(499,n - 1)
sum = 0.
sumw = 0.
//Compute weighted mean
for j = 0 to math.min(499,n - 1)
w = gauss(i - j, h)
sum += src[j] * w
sumw += w

y2 := sum / sumw
sae += math.abs(src[i] - y2)
nwe.push(y2)

sae := sae / math.min(499,n - 1) * mult


for i = 0 to math.min(499,n - 1)
if i%2
line.new(n-i+1, y1 + sae, n-i, nwe.get(i) + sae, color = upCss)
line.new(n-i+1, y1 - sae, n-i, nwe.get(i) - sae, color = dnCss)

if src[i] > nwe.get(i) + sae and src[i+1] < nwe.get(i) + sae


label.new(n-i, src[i], '▼', color = color(na), style =
label.style_label_down, textcolor = dnCss, textalign = text.align_center)
if src[i] < nwe.get(i) - sae and src[i+1] > nwe.get(i) - sae
label.new(n-i, src[i], '▲', color = color(na), style =
label.style_label_up, textcolor = upCss, textalign = text.align_center)

y1 := nwe.get(i)
//-------------------------------------------------------------------------
----}
//Dashboard
//-------------------------------------------------------------------------
----{
var tb = table.new(position.top_right, 1, 1
, bgcolor = #1e222d
, border_color = #373a46
, border_width = 1
, frame_color = #373a46
, frame_width = 1)

if repaint
tb.cell(0, 0, 'Repainting Mode Enabled', text_color = color.white,
text_size = size.small)

//-------------------------------------------------------------------------
----}
//Plot
//-------------------------------------------------------------------------
----}
plot(repaint ? na : out + mae, 'Upper', upCss)
plot(repaint ? na : out - mae, 'Lower', dnCss)

//Crossing Arrows
plotshape(ta.crossunder(close, out - mae) ? low : na, "Crossunder",
shape.labelup, location.absolute, color(na), 0 , text = '▲', textcolor =
upCss, size = size.tiny)
plotshape(ta.crossover(close, out + mae) ? high : na, "Crossover",
shape.labeldown, location.absolute, color(na), 0 , text = '▼', textcolor =
dnCss, size = size.tiny)

//-------------------------------------------------------------------------
----}

You might also like