#//@version=3
#study(title="Magic Clouds MMD & Ersoy", overlay=true)
# Converted by Sam4Cok@Samer800 - Request from UsethinkScript.com member - 11/2022
#///////////////////////// ERSOY //////////////////////////////////////
#///Private Fibonachi-14///
input length14 = 14; # "Moment-14"
input offset14 = 0;
def na = Double.NaN;
def lsma14 = inertia(open[offset14], length14);
plot e14= lsma14;
e14.SetDefaultColor(Color.WHITE);
#///Private Fibonachi-35///
input length35 = 35; # "Resistance-35"
input offset35 = 0;
def lsma35 = inertia(open[offset35], length35);
plot e35= lsma35;
e35.SetDefaultColor(Color.RED);
def CrossOpen = lsma14 crosses lsma35;
plot OpenCross = if CrossOpen then lsma14 else na;
OpenCross.SetStyle(Curve.POINTS);
OpenCross.SetDefaultColor(Color.MAGENTA);
OpenCross.SetLineWeight(3);
def lsma14Close = inertia(close[offset14], length14);
def lsma35Close = inertia(close[offset35], length35);
def CrossClose = lsma14Close crosses lsma35Close;
plot CloseCross = if CrossClose then lsma14Close else na;
CloseCross.SetStyle(Curve.POINTS);
CloseCross.SetDefaultColor(Color.CYAN);
CloseCross.SetLineWeight(3);
#///////////////////////// MMD //////////////////////////////////////
input ziuum_term_period = 12; # "Ultra Short Term Period"
input short_term_period = 48; # "Short Term Period"
input mid_term_period = 288; # "Mid Term Period"
input long_term_period = 1440; # "Long Term Period"
def us1 = SimpleMovingAvg(open, ziuum_term_period);#'Ultra Short Term SMA'
def us2 = ExpAverage(open, ziuum_term_period); #'Ultra Short Term EMA'
AddCloud(us1, us2, Color.LIGHT_GRAY,Color.LIGHT_GRAY,yes);
def s1 = SimpleMovingAvg(open, short_term_period); # 'Short Term SMA'
def s2 = ExpAverage(open, short_term_period); # 'Short Term EMA'
AddCloud(s1, s2, Color.DARK_ORANGE,Color.DARK_ORANGE,yes);
def m1 = SimpleMovingAvg(open, mid_term_period); # 'Mid Term SMA'
def m2 = ExpAverage(open, mid_term_period); # 'Mid Term EMA'
AddCloud(m1, m2, CreateColor(0, 108, 216),CreateColor(0, 108, 216), yes);
def l1 = SimpleMovingAvg(open, long_term_period); # 'Long Term SMA'
def l2 = ExpAverage(open, long_term_period); # 'Long Term EMA'
AddCloud(l1, l2, Color.DARK_GREEN,Color.DARK_GREEN,yes);
#--END Code