def price = close;
input length = 3;
def displace = 0;
#input showBreakoutSignalss = no;
def AvgExp = ExpAverage(price[-displace], length);
#def UpSignal = price crosses above AvgExp;
#def DownSignal = price crosses below AvgExp;
def price2 = close;
input length2 = 9;
def displace2 = 0;
#input showBreakoutSignalss2 = no;
def AvgExp2 = ExpAverage(price2[-displace2], length2);
#def UpSignal2 = price2 crosses above AvgExp2;
#def DownSignal2 = price2 crosses below AvgExp2;
def price3 = close;
input length3 = 20;
def displace3 = 0;
#input showBreakoutSignalss3 = no;
def AvgExp3 = ExpAverage(price3[-displace3], length3);
#def UpSignal3 = price3 crosses above AvgExp3;
#def DownSignal3 = price3 crosses below AvgExp3;
def price4 = close;
input length4 = 30;
def displace4 = 0;
#input showBreakoutSignalss4 = no;
def AvgExp4 = ExpAverage(price4[-displace4], length4);
#def UpSignal4 = price4 crosses above AvgExp4;
#def DownSignal4 = price4 crosses below AvgExp4;
#input over_bought = 80;
#input over_sold = 20;
input KPeriod = 5;
input DPeriod = 3;
def priceH = high;
def priceL = low;
def priceC = close;
input slowing_period = 3;
def beyondType = AverageType.SIMPLE;
input showBreak = {default "No", "On FullK", "On FullD", "On FullK & FullD"};
def lowest_k = Lowest(priceL, KPeriod);
def c1 = priceC - lowest_k;
def c2 = Highest(priceH, KPeriod) - lowest_k;
def FastK = if c2 != 0 then c1 / c2 * 100 else 0;
def FullK = MovingAverage(beyondType, FastK, slowing_period);
def FullD = MovingAverage(beyondType, FullK, DPeriod);
#def OverBought = over_bought;
#def OverSold = over_sold;
#input over_bought2 = 80;
#input over_sold2 = 20;
#input KPeriod2 = 12;
#input DPeriod2 = 3;
#input priceH2 = high;
#input priceL2 = low;
#input priceC2 = close;
#input slowing_period2 = 6;
#input beyondType2 = AverageType.SIMPLE;
#input showBreak2 = {default "No", "On FullK2", "On FullD2", "On FullK2 & FullD2"};
#def lowest_k2 = Lowest(priceL2, KPeriod2);
#def c12 = priceC2 - lowest_k2;
#def c22 = Highest(priceH2, KPeriod2) - lowest_k2;
#def FastK2 = if c22 != 0 then c12 / c22 * 100 else 0;
#def FullK2 = MovingAverage(beyondType2, FastK2, slowing_period2);
#def FullD2 = MovingAverage(beyondType2, FullK2, DPeriod2);
#def OverBought2 = over_bought2;
#def OverSold2 = over_sold2;
input fastLength = 3;
input slowLength = 21;
input MACDLength = 5;
input averageType = AverageType.EXPONENTIAL;
#input showBreakoutSignals = no;
def Value = MovingAverage(averageType, close, fastLength) - MovingAverage(averageType, close, slowLength);
def Avg = MovingAverage(averageType, Value, MACDLength);
#def Diff = Value - Avg;
#def ZeroLine = 0;
# AvgExp [1] < AvgExp2 [1] and AvgExp > AvgExp2 and Value > Avg and FullK > FullD and AvgExp2 > AvgExp3 or
plot Bullish = AvgExp [1] < AvgExp4 [1] and AvgExp > AvgExp4 and Value > Avg;
plot sellBullish = AvgExp [1] > AvgExp2 [1] and AvgExp < AvgExp2 and Value < Avg and FullK < FullD and AvgExp2 < AvgExp3 or AvgExp [1] > AvgExp4 [1] and AvgExp < AvgExp4 and Value < Avg;
Bullish.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
sellBullish.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
Alert(Bullish, "paintingStrategy.BOOLEAN_ARROW_UP", Alert.BAR, Sound.Bell);
Alert(sellBullish,"paintingStrategy.BOOLEAN_Arrow_Down", Alert.BAR, Sound.Bell);
Bullish.SetLineWeight(5);
sellBullish.SetLineWeight(5);
Bullish.SetDefaultColor(GetColor(6));
sellBullish.SetDefaultColor(GetColor(5));