//@version=4
//Bo Novecento M5
//author: anhnguyen14
strategy(title="Bo Novecento M5", overlay=true, pyramiding=14)
// === INPUTS
setup1=input(true, title="Novecentas Setup")
// - /INPUTS
//The Vostro Indicator
period156 = 100
level = input(8, title="Vostro Level")
gd120 = sum(hl2, 5)
gd128 = gd120 * .2
gd121 = sum(high - low, 5)
gd136 = gd121 * .2 * .2
ibuff116 = (low - gd128) / gd136
ibuff112 = (high - gd128) / gd136
ibuff108 = iff(ibuff112 > level and high > wma(hl2, period156), 90, iff(ibuff116 < -level and low < wma(hl2, period156), -90, 0))
ibuff109 = iff(ibuff112 > level and ibuff112[1] > level or ibuff116 < -level and ibuff116[1] < -8, 0, ibuff108)
//plot(ibuff109, color=color.blue, linewidth=2)
//plot(80)
//plot(-80)
//Trend Direction Force Index
filterHigh = 0.5
filterMid = 0
filterLow = -0.5
price = close
//TFD5
lookback5 = input(5, title="TDF Fast")
mma5 = ema(price * 1000, lookback5)
smma5 = ema(mma5, lookback5)
impetmma5 = mma5 - mma5[1]
impetsmma5 = smma5 - smma5[1]
divma5 = abs(mma5 - smma5)
averimpet5 = (impetmma5 + impetsmma5) / 2
number5 = averimpet5
pow5 = 3
result5 = float(na)
for i = 1 to pow5 - 1 by 1
if i == 1
result5 := number5
result5
result5 := result5 * number5
result5
tdf5 = divma5 * result5
ntdf5 = tdf5 / highest(abs(tdf5), lookback5 * 3)
//c = ntdf5 > filterHigh ? color.green : ntdf < filterLow ? color.red : color.gray
//plot(ntdf5, linewidth=3, color=color.red)
//TFD20
lookback20 = input(20, title="TDF Slow")
mma20 = ema(price * 1000, lookback20)
smma20 = ema(mma20, lookback20)
impetmma20 = mma20 - mma20[1]
impetsmma20 = smma20 - smma20[1]
divma20 = abs(mma20 - smma20)
averimpet20 = (impetmma20 + impetsmma20) / 2
number20 = averimpet20
pow20 = 3
result20 = float(na)
for i = 1 to pow20 - 1 by 1
if i == 1
result20 := number20
result20
result20 := result20 * number20
result20
tdf20 = divma20 * result20
ntdf20 = tdf20 / highest(abs(tdf20), lookback20 * 3)
//c = ntdf5 > filterHigh ? color.green : ntdf < filterLow ? color.red : color.gray
//plot(ntdf20, linewidth=3, color=color.yellow)
//hline(filterHigh, color=color.black)
//hline(filterMid, color=color.black)
//hline(filterLow, color=color.black)
//Barry Support & Resistance
FractalLen=3
isFractal(x) => highestbars(x,FractalLen*2+1)==-FractalLen
sF=isFractal(-low), support=low, support:=sF ? low[FractalLen] : support[1]
rF=isFractal(high), resistance=high, resistance:=rF ? high[FractalLen] : resistance[1]
//plot(series=support, title="Support", color=color.blue, offset=-FractalLen)
//plot(series=resistance, title="Resistance", color=color.red, offset=-FractalLen)
plotshape(sF, title="Lower fractal", style=shape.diamond, location=location.belowbar, color=color.black, offset=-FractalLen, size=size.tiny)
plotshape(rF, title="Upper fractal", style=shape.diamond, location=location.abovebar, color=color.black, offset=-FractalLen, size=size.tiny)
//Put Condition
//Novecento M5 - Put Condition - Novecentas Setup
x1=
setup1?
ibuff109>80
and ntdf5==1
and ntdf20<0.5
:false
//Novecento M5 - Call Condition - Novecentas Setup
y1=
setup1?
ibuff109<-80
and ntdf5==-1
and ntdf20>-0.5
: false
// - /FUNCTIONS
x=
x1
y=
y1
//--------------------------------------\\
// Alert
putcol = x ? color.red : na
callcol = y ? color.blue : na
bgcolor(putcol, transp=70, offset=1, title="Put Signal For Macro (A)")
bgcolor(callcol, transp=70, offset=1, title="Call Signal For Macro (A)")
strategy.entry("Call", strategy.long, when=(y))
strategy.entry("Put", strategy.short, when=(x))
strategy.close_all(when=barstate.isnew)
//EOF