Half-Pi Cycle CKB top indicator (insanely experimental)
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © BilzerianCandle

//@version=4
study("Half-Pi Cycle CKB top indicator", shorttitle="Half-Pi Cycle", overlay=true)

len_ma_long = input(175, minval=1, title="Long Moving Average")
len_ma_short = input(56, minval=1, title="Short Moving Average")
resolution = input('D', type=input.string, title="Time interval")
is_show_ma = input(false, type=input.bool, title="Show Moving Averages ?")
is_alert = input(true, type=input.bool, title="Send an alert on Half-Pi Cycle Top?")

ma_long = security(syminfo.tickerid, resolution, sma(close, len_ma_long)*2)
ma_short = security(syminfo.tickerid, resolution, sma(close, len_ma_short))
src = security(syminfo.tickerid, resolution, close)

plot(is_show_ma?ma_long:na, color=color.green)
plot(is_show_ma?ma_short:na, color=color.red)

PiCycleTop = crossunder(ma_long, ma_short) ? src + (src/100 * 10) : na

plotshape(PiCycleTop, style=shape.labeldown,size=size.normal, text="Half-Pi Cycle top", color=color.red, textcolor=color.white, location=location.absolute)
alertcondition(condition=PiCycleTop, title="Half-Pi Cycle", message="The Half-Pi Cycle Top has been reached, historically CKB tops within 3 days of reaching this ratio")