Pi Cycle Bottom Indicator
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Doncic on TradingView

//@version=5
indicator('Pi Cycle Bottom Indicator', shorttitle=' Pi Cycle Bottom', overlay=true)

ln_ma_bottomlong = input.int(471, minval=1, title='Long SMA')
ln_ma_bottomshort = input.int(150, minval=1, title='Short EMA')
long_multiple = input(0.745, title='Long MA Multiple')
short_multiple = input(1.0, title='Short MA Multiple')
resolution = input('D', title='Time interval')
is_show_ma = input(true, title='Display Moving Averages')
is_show_diff = input(false, title='Display Difference between MAs')
is_alert = input(false, title='Send an alert at Pi Cycle Bottom')


ma_bottomlong = request.security(syminfo.tickerid, resolution, ta.sma(close, ln_ma_bottomlong) * long_multiple)
ma_bottomshort = request.security(syminfo.tickerid, resolution, ta.ema(close, ln_ma_bottomshort) * short_multiple)
ma_diff = ma_bottomshort - ma_bottomlong

src = request.security(syminfo.tickerid, resolution, close)

plot(is_show_ma ? ma_bottomlong : na, color=color.new(color.red, 0), title='Long MA')
plot(is_show_ma ? ma_bottomshort : na, color=color.new(color.green, 0), title='Short MA')
plot(is_show_diff ? ma_diff : na, color=color.new(color.white, 0), title='MA Difference')


PiCycleBottom = ta.crossunder(ma_bottomshort, ma_bottomlong) ? src + src / 100 * 10 : na

plotshape(PiCycleBottom, style=shape.triangleup, size=size.small, text='Pi Cycle Bottom', color=color.new(color.green, 0), textcolor=color.new(color.white, 0), location=location.belowbar)


