Hi All, any expert on here that can tell me how to change the displace input of an indicator into a conditional one. For example, I wanted the moving average to plot based on displace as when the close crosses above another indicator or like 200 weightedMovAvg and not based on "0" or numbers. The script below is for example to show the displace input but not the code i wanted to create.
# TD Ameritrade IP Company, Inc. (c) 2017-2023
#
input price = close;
input length = 9;
input displace = 0;
input showBreakoutSignals = no;
plot AvgExp = ExpAverage(price[-displace], length);
plot UpSignal = price crosses above AvgExp;
plot DownSignal = price crosses below AvgExp;
UpSignal.SetHiding(!showBreakoutSignals);
DownSignal.SetHiding(!showBreakoutSignals);
AvgExp.SetDefaultColor(GetColor(1));
UpSignal.SetDefaultColor(Color.UPTICK);
UpSignal.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
DownSignal.SetDefaultColor(Color.DOWNTICK);
DownSignal.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
# TD Ameritrade IP Company, Inc. (c) 2017-2023
#
input price = close;
input length = 9;
input displace = 0;
input showBreakoutSignals = no;
plot AvgExp = ExpAverage(price[-displace], length);
plot UpSignal = price crosses above AvgExp;
plot DownSignal = price crosses below AvgExp;
UpSignal.SetHiding(!showBreakoutSignals);
DownSignal.SetHiding(!showBreakoutSignals);
AvgExp.SetDefaultColor(GetColor(1));
UpSignal.SetDefaultColor(Color.UPTICK);
UpSignal.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
DownSignal.SetDefaultColor(Color.DOWNTICK);
DownSignal.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);