FinancialWisdom Breakout Indicator
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © FittestTrader

//@version=5
indicator("FW Breakout Indicator", overlay=true)
//INPUTS
Bars = input (6)
minimum  = input.int(1, "Min Breakout %")
maximum  = input.int(20, "Max Breakout %")
min  = input.int(5, "Min Breakout Size %")
max  = input.int(20, "Max Breakout Size %")
Volume = input.int(30, "Min Volume Breakout %")
Consolidation  = input.int(15, "Consolidation Range")
Stoploss = input.int(20, "Stoploss Percentage")
MovingAverage = input (20)
atrlength = input(title="NATR Length", defval=14)
atrval = input(title="Max NATR Value", defval=8)

//MACD
fastLength = input(12)
slowlength = input(26)
MACDLength = input(9)
MACD = ta.ema(close, fastLength) - ta.ema(close, slowlength)
aMACD = ta.ema(MACD, MACDLength)
delta = MACD - aMACD
//MACD

//INPUTS

//Calculation
highest=ta.highest(high, Bars)[1]
change=ta.change(close,Bars)[1]
lowest=ta.lowest(low,Bars) [1]
diff= ((highest/lowest) - 1)*100
minbo =  highest * ((minimum/100)+1)
maxbo = highest * ((maximum/100)+1)
Vol = ((volume / volume[1]) - 1) * 100
SL = ((close/lowest) - 1) * 100
MA = ta.sma(close,MovingAverage)
minbos =  close[1] * ((min/100)+1)
maxbos = close[1] * ((max/100)+1)
natr = 100 * ta.atr(atrlength) / close

//Calculation

Breakout = diff < Consolidation and close > minbo and close < maxbo and MACD>aMACD and Vol > Volume  and SL < Stoploss and close > MA and natr < atrval and close >= minbos and close < maxbos
plotshape(Breakout,"Breakout",shape.labelup ,location.belowbar ,#26a69a,text="B",textcolor=color.white,size=size.normal) 
alertcondition(Breakout,'Upper Breakout','Price broke upper trendline')

