I need a label that can count the number of signals given from a chart overlay but I can't get the code to work and am wondering if it's possible. For example, I can overlay "LI" to my current chart, give it a 200sma, and plot a potential signal where the low is less than the 200sma but I can't get the total sum of signals. Any advice?
input Security = "LI";
input SecurityType = {"BAR", default"CANDLE", "LINE"};
AddChart(high = high(Security), low = low(Security),open = open(Security), close = close(Security), type = SecurityType);
input LengthMA = 200;
input AvgTypeMA = AverageType.SIMPLE;
plot MA = MovingAverage(AvgTypeMA, close(security), LengthMA);
plot lows = if Low(security) is less than MA then low(security) else double.NaN;
lows.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
lows.SetLineWeight(5);
lows.SetDefaultColor(Color.ORANGE);
AddLabel(yes, "Security Signals: " + TotalSum(Low(security) is less than MA), Color.MAGENTA);
This code works when applied to the current chart but not to chart overlays. When applied to the current chart it looks like
input LengthMA = 200;
input AvgTypeMA = AverageType.SIMPLE;
plot MA = MovingAverage(AvgTypeMA, close, LengthMA);
plot lows = if Low is less than MA then low else double.NaN;
lows.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
lows.SetLineWeight(5);
lows.SetDefaultColor(Color.ORANGE);
AddLabel(yes, "Signals2: " + TotalSum(low is less than MA), Color.MAGENTA);
input Security = "LI";
input SecurityType = {"BAR", default"CANDLE", "LINE"};
AddChart(high = high(Security), low = low(Security),open = open(Security), close = close(Security), type = SecurityType);
input LengthMA = 200;
input AvgTypeMA = AverageType.SIMPLE;
plot MA = MovingAverage(AvgTypeMA, close(security), LengthMA);
plot lows = if Low(security) is less than MA then low(security) else double.NaN;
lows.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
lows.SetLineWeight(5);
lows.SetDefaultColor(Color.ORANGE);
AddLabel(yes, "Security Signals: " + TotalSum(Low(security) is less than MA), Color.MAGENTA);
This code works when applied to the current chart but not to chart overlays. When applied to the current chart it looks like
input LengthMA = 200;
input AvgTypeMA = AverageType.SIMPLE;
plot MA = MovingAverage(AvgTypeMA, close, LengthMA);
plot lows = if Low is less than MA then low else double.NaN;
lows.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
lows.SetLineWeight(5);
lows.SetDefaultColor(Color.ORANGE);
AddLabel(yes, "Signals2: " + TotalSum(low is less than MA), Color.MAGENTA);