Hello folks
Long story short I'm stuck. The way i've cobbled this together has resulted in more signals (up arrows) than i want and i can't work out how to just get the signal to fire when the histogram starts to move back in a positive direction.
How do I amend the Upsignal instruction to only show on the first bar when momentum switches from negative to positive? It continues to fire until momentum turns negative.
I'd very much appreciate some advice from those of you with more experience if you have time please
Long story short I'm stuck. The way i've cobbled this together has resulted in more signals (up arrows) than i want and i can't work out how to just get the signal to fire when the histogram starts to move back in a positive direction.
How do I amend the Upsignal instruction to only show on the first bar when momentum switches from negative to positive? It continues to fire until momentum turns negative.
I'd very much appreciate some advice from those of you with more experience if you have time please
Code:
declare upper;
input fastLength = 6;
input slowLength = 13;
input MACDLength = 5;
input averageType = AverageType.EXPONENTIAL;
def Value = MACD(fastLength, slowLength, MACDLength, averageType).Value;
def Avg = MACD(fastLength, slowLength, MACDLength, averageType).Avg;
def ZeroLine = 0;
def pos = Value >= 0;
def neg = Value < 0;
def up = Value >= Value[1];
def dn = Value < Value[1];
def PosUp = pos and up;
def PosDn = pos and dn;
def NegDn = neg and dn;
def NegUp = neg and up;
def pos1 = Avg >= 0;
def neg1 = Avg < 0;
def up1 = Avg >= Avg[1];
def dn1 = Avg < Avg[1];
def PosUp1 = pos1 and up1;
def PosDn1 = pos1 and dn1;
def NegDn1 = neg1 and dn1;
def NegUp1 = neg1 and up1;
#cloud
AddCloud(if Value < 0 then Double.POSITIVE_INFINITY else Double.NaN, if Value < 0 then Double.NEGATIVE_INFINITY else Double.NaN, Color.RED);
#AddCloud(if Value >= 0 then Double.POSITIVE_INFINITY else Double.NaN, if Value < 0 then Double.NEGATIVE_INFINITY else Double.NaN, Color.GREEN);
#Labels
#AddLabel (yes, if pos or up then " BULL " else "", Color.GREEN);
#AddLabel (yes, if pos1 or up1 then " BULL " else "", Color.GREEN);
#signals
input Klength = 10;
input price = close;
def K = (Highest(high, Klength) + Lowest(low, Klength)) /
2 + ExpAverage(close, Klength);
def Momo = Inertia(price - K / 2, Klength);
plot Upsignal = if Momo > Momo[1] and up then Momo else double.NaN;
Upsignal.SetDefaultColor(Color.WHITE);
upsignal.SetPaintingStrategy(PaintingStrategy.boolean_points);
upsignal.SetLineWeight(5);