You are on page 1of 4

instrument {

name = "Supreme",
short_name = "SUPR", overlay = true, icon="indicators:BB"
}
input_group {
"MACD",
"Slow and fast EMA periods, used in MACD calculation",
fast = input (12, "front.platform.fast period", input.integer, 1, 250),
slow = input (26, "front.platform.fast period", input.integer, 1, 250)
}
input_group {
"front.platform.signal-line",
"Reference signal series period",
signal_period = input (9, "front.period", input.integer, 1, 250)
}
input_group {
"front.newind.emaperiod",
ema_period = input (13, "front.period", input.integer, 1, 250)
}
input_group {
"front.newind.barcolors",
positive = input { default = "#2CAC40", type = input.color },
neutral = input { default = "#C7CAD1", type = input.color },
negative = input { default = "#DB4931", type = input.color },
}
function prev(s,i)
y=abs(round(i))
return s[y]
end
length = input(5, "Numero de Velas")
extTop = input(12, "Extreme Level Top")
extBot = input(-12, "Extreme Level Bottom")
sigTop = input(8, "Significant Level Top")
sigBot = input(-8, "Significant Level Bottom")
fairTop = input(4, "Fair Value Top")
fairBot = input(-4, "Fair Value Bottom")
input_group { "CALL", call_color = input{ default="blue", type = input.color} }
input_group { "PUT", put_color = input{ default="orange", type = input.color} }
fastMA = ema(close, fast)
slowMA = ema(close, slow)
macd = fastMA - slowMA
signal = sma(macd, signal_period)
hist = macd - signal
ema13 = ema (close, ema_period)
local bar_color
varp = round(length/5)
h_f = length > 7
vara= h_f and highest(high,varp)-lowest(low,varp) or 0
varr1 = h_f and iff(vara==0 and varp==1,abs(close-prev(close,-varp)),vara) or 0
varb=h_f and prev(highest(high,varp),-varp+1)-prev(lowest(low,varp),-varp) or 0
varr2 = h_f and iff(varb==0 and varp==1,abs( prev(close,-varp)-prev(close,-
varp*2) ),varb) or 0
varc=h_f and prev(highest(high,varp),-varp*2)-prev(lowest(low,varp),-varp*2) or 0
varr3 = h_f and iff(varc == 0 and varp==1,abs(prev(close,-varp*2)-prev(close,-
varp*3)),varc) or 0
vard = h_f and prev(highest(high,varp),-varp*3)-prev(lowest(low,varp),-varp*3) or 0
varr4 = h_f and iff(vard == 0 and varp==1,abs(prev(close,-varp*3)-prev(close,-
varp*4)),vard) or 0
vare = h_f and prev(highest(high,varp),-varp*4)-prev(lowest(low,varp),-varp*4) or 0
varr5 = h_f and iff(vare == 0 and varp==1,abs(prev(close,-varp*4)-prev(close,-
varp*5)),vare) or 0
cdelta = abs(close - prev(close,-1))
var0 = (not h_f) and iff((cdelta > (high-low)) or (high==low),cdelta,(high-low)) or
0
lrange=h_f and ((varr1+varr2+varr3+varr4+varr5)/5)*.2 or sma(var0,5)*.2
mba = sma( (high+low)/2,length)
vopen = (open- mba)/lrange
vhigh = (high-mba)/lrange
vlow = (low-mba)/lrange
vclose = (close-mba)/lrange
colorr = open > close and "red" or "green"
plot_candle {
open = vopen,
high = vhigh,
low = vlow,
close = vclose,
candle_color = colorr
}
hline(extTop,"","red")
hline(extBot,"","green")
hline(sigTop,"","red")
hline(sigBot,"","green")
hline(fairTop,"","red")
hline(fairBot,"","green")
if ema13 > ema13 [1] and hist > hist [1] then
bar_color = positive
plot_shape((ema13 > ema13 [1]), "CALL", shape_style.triangleup,
shape_size.large, call_color, shape_location.belowbar, 0)
elseif ema13 < ema13 [1] and hist < hist [1] then
bar_color = negative
plot_shape((ema13 < ema13 [1]), "PUT", shape_style.triangledown, shape_size.large,
put_color, shape_location.abovebar, 0)
else
bar_color = neutral
end
plot_candle (open, high, low, close, "ES", bar_color)

You might also like