#Original Script: https://www.tradingview.com/v/VKrOeaxA/
#Converted by FunTrade
declare lower;
plot h1 = 2;
plot h5 = -5;
def nrsi = RSI(price = close,length = 14).RSI;
def hrsi = highest(nrsi, 10);
def lrsi = lowest(nrsi, 10);
def mac = MACD(fastLength = 12, slowLength = 26, MACDLength = 9).Value;
input mo_g = 21; #Range minval=1, maxval=500
input mo_r = 34; #Range minval=1, maxval=500
input h_k = 144; #Range minval=1, maxval=500
def ma21 = SimpleMovingAvg(close,mo_g);
def ma34 = SimpleMovingAvg(close,mo_r);
def ma144 = SimpleMovingAvg(close,h_k);
input src = close;
def b3 = ma21>ma34 and src>ma144 and ma144[1]<ma144;
def b2 = (ma21>ma34 and src>ma144 and ma144[1]>ma144) or (ma21>ma34 and ma144[1]<ma144 and src<ma144) or (src>ma144 and ma144[1]<ma144 and ma21<ma34);
def bsh = (ma21>ma34 and src>ma144) or (ma21>ma34 and ma144[1]<ma144) or (src>ma144 and ma144[1]<ma144);
def s3 = ma21<ma34 and src<ma144 and ma144[1]>ma144;
def s2 = (ma21<ma34 and src<ma144 and ma144[1]<ma144) or (ma21<ma34 and src>ma144 and ma144[1]>ma144) or (ma21>ma34 and src<ma144 and ma144[1]>ma144);
def ssh = (ma21<ma34 and src<ma144) or (ma21<ma34 and ma144[1]>ma144) or ( src<ma144 and ma144[1]>ma144);
def tf = if (lrsi<nrsi and nrsi>50) or (hrsi>nrsi and nrsi<50) then 0 else 1;
def ft = if (mac>0 and ma21>ma34) or (mac<0 and ma34>ma21) then 0 else 1;
#histogram
plot a1 = if b3 then 2 else double.nan;
a1.SetDefaultColor(color.green);
a1.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
plot a2 = if b2 then 1 else double.nan;
a2.SetDefaultColor(color.light_green);
a2.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
plot a3 = if s3 then -2 else double.nan;
a3.SetDefaultColor(color.red);
a3.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
plot a4 = if s2 then -1 else double.nan;
a4.SetDefaultColor(color.light_red);
a4.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
#lines
plot a5 = if lrsi<nrsi and nrsi>50 then -3 else double.nan;
a5.SetDefaultColor(color.green);
a5.SetPaintingStrategy(PaintingStrategy.line);
plot a6 = if hrsi>nrsi and nrsi<50 then -3 else double.nan;
a6.SetDefaultColor(color.DARK_red);
a6.SetPaintingStrategy(PaintingStrategy.line);
plot a7 = if mac>0 and ma21>ma34 then -4 else double.nan;
a7.SetDefaultColor(color.green);
a7.SetPaintingStrategy(PaintingStrategy.line);
plot a8 = if mac<0 and ma34>ma21 then -4 else double.nan;
a8.SetDefaultColor(color.DARK_red);
a8.SetPaintingStrategy(PaintingStrategy.line);
plot a9 = if ft==1 then -4 else double.nan;
a9.SetDefaultColor(color.white);
a9.SetPaintingStrategy(PaintingStrategy.line);
plot a10 = if tf==1 then -3 else double.nan;
a10.SetDefaultColor(color.white);
a10.SetPaintingStrategy(PaintingStrategy.line);