Alts/USDT.D ratio
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © alex.crown.jr
import boitoki/ma_function/3 as ma

nonRepaintingSecurity(sym, tf, src) =>
    request.security(sym, tf, src[1], lookahead = barmerge.lookahead_on)
    
//@version=5
indicator("Alts/USDT.D ratio", overlay=false)
sym_a = input.symbol("CRYPTOCAP:USDT.D", "Symbol A")
sym_b = input.symbol("CRYPTOCAP:OTHERS.D", "Symbol B")

ma_type = input.string("EMA", options=["EMA", "SMA", "RMA", "WMA", "VWMA", "HMA", "TMA", "DEMA", "TEMA", "MAV", "KAMA", "ZLEMA"])
length = input(50, "MA length")

ma_ratio = ma.ma_function(ma_type, close, length)

ratio = nonRepaintingSecurity(sym_a+"/"+sym_b, "D", close)
ma_ratio_sec = nonRepaintingSecurity(sym_a+"/"+sym_b, "D", ma_ratio)

f1 = plot(ma_ratio_sec, color=color.new(color.red, 0))
f2 = plot(ratio, color=color.new(color.green, 0))
fill(f1, f2, color = ma_ratio_sec > ratio ? color.new(color.green, 50)  : color.new(color.red, 50))
