I need to project a horizontal ray, 5 bars out(to the right) every time a condition is triggered. Let's say two moving averages cross. I work mostly on intraday charts. I've seen the lookbacks but I need this ray generated in real time. Looked at Halcyon's work on lines but nothing seems to fit. My horizontal lines project out one bar at a time so are practically useless as a visual level, while I need a fixed short line drawn all at once when the indicators are triggered. How do I do this? TIA.
input price = close;
input length1 = 9;
input length2 = 14;
input averageType1 = AverageType.SIMPLE;
input averageType2 = AverageType.SIMPLE;
def avg1 = MovingAverage(averageType1, price, length1);
def avg2 = MovingAverage(averageType2, price, length2);
def sigtestLine1 = if avg1 crosses above avg2 then avg1 else sigtestLine1[1];
def sigtestLine2 = if avg1 crosses below avg2 then avg1 else sigtestLine2[1];
plot signalup = sigtestLine1;
signalup.setDefaultColor(color.green);
signalup.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Plot signaldown = sigtestLine2;
signaldown.setDefaultColor(color.red);
signaldown.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
input price = close;
input length1 = 9;
input length2 = 14;
input averageType1 = AverageType.SIMPLE;
input averageType2 = AverageType.SIMPLE;
def avg1 = MovingAverage(averageType1, price, length1);
def avg2 = MovingAverage(averageType2, price, length2);
def sigtestLine1 = if avg1 crosses above avg2 then avg1 else sigtestLine1[1];
def sigtestLine2 = if avg1 crosses below avg2 then avg1 else sigtestLine2[1];
plot signalup = sigtestLine1;
signalup.setDefaultColor(color.green);
signalup.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Plot signaldown = sigtestLine2;
signaldown.setDefaultColor(color.red);
signaldown.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);