# Median Average line showing colored changes from previous bar (green,neutral,red) and state change buy/sell signals with audio alerts; default period for 4-hour lookback on a 5 min chart is 48 periods; - 9-24-26
# After seeing how Back Quant on TV uses medians vs averages and how the median line is less affected by extremes and outliers, going flat during pullbacks, I created this indicator for 5m NQ. It does a good job of staying with the trend through some deep pullbacks and will continue to signal when it comes out of a neutral (flat) period. W. Kalvin
# After seeing how Back Quant on TV uses medians vs averages and how the median line is less affected by extremes and outliers, going flat during pullbacks, I created this indicator for 5m NQ. It does a good job of staying with the trend through some deep pullbacks and will continue to signal when it comes out of a neutral (flat) period. W. Kalvin
Code:
input period = 48;
plot Median = MedianAverage(close, period);
Median.AssignValueColor(if Median > Median[1] then Color.GREEN else if Median < Median[1] then Color.RED else Color.GRAY);
Median.SetLineWeight(3);
# Determine State/Direction
def isUP = Median > Median[1];
def isDown = Median < Median[1];
# Define Signal Conditions
def buyCondition = isUp and !isUP[1]; # Median turns up
def sellCondition = isDown and !isDown[1]; # Median turns down
# Plot Buy/Sell arrows
plot BuySignal = if buyCondition then low else Double.NaN;
BuySignal.SetPaintingStrategy(PaintingStrategy.Arrow_Up);
BuySignal.SetDefaultColor(Color.GREEN);
BuySignal.SetLineWeight(3);
plot SellSignal = if sellCondition then high else Double.NaN;
SellSignal.SetPaintingStrategy(PaintingStrategy.Arrow_Down);
SellSignal.SetDefaultColor(Color.RED);
SellSignal.SetLineWeight(3);
# Audio alerts
Alert(buyCondition, "Buy", Alert.BAR, Sound.Chimes);
Alert(sellCondition, "Sell", Alert.BAR, Sound.Ding);
Last edited by a moderator: