lmr and volume
Mon Nov 18 2024 19:08:49 GMT+0000 (Coordinated Universal Time)
Saved by @pk20
/@version=5
indicator("LMR with Bullish and Bearish Arrows", overlay=true)
// --- Price and Volume Definitions for Previous Days ---
price1 = close[1]
price2 = close[2]
price3 = close[3]
volume1 = volume[1]
volume2 = volume[2]
volume3 = volume[3]
// --- LMR Calculations ---
MR1 = (price1 - close) / volume1 // Price change relative to previous volume
LMR2 = (price2 - price1) / (volume2 + volume1) // Price change relative to combined volume of last two days
LMR3 = (price3 - price2) / (volume3 + volume2 + volume1) // Price change relative to combined volume of last three days
// --- Plot Raw LMR Values ---
plot(MR1, color=color.green, title="MR1 (Raw)")
plot(LMR2, color=color.orange, title="LMR2 (Raw)")
plot(LMR3, color=color.purple, title="LMR3 (Raw)")
// --- Simplified Bullish Signal Condition ---
bullishSignal = (close > price1 and volume > ta.sma(volume, 20)) // Bullish if current price is higher than previous and volume is above average
// --- Simplified Bearish Signal Condition ---
bearishSignal = (close < price1 and volume > ta.sma(volume, 20)) // Bearish if current price is lower than previous and volume is above average
// --- Plot Bullish Signal as Background Color ---
bgcolor(bullishSignal ? color.new(color.green, 90) : na, title="Bullish Signal") // Green: Bullish Signal
// --- Plot Bullish Arrow (Below Bar) ---
plotshape(bullishSignal, title="Bullish Signal Arrow", location=location.belowbar, color=color.green, style=shape.arrowup, size=size.small)
// --- Plot Bearish Arrow (Above Bar) ---
plotshape(bearishSignal, title="Bearish Signal Arrow", location=location.abovebar, color=color.red, style=shape.arrowdown, size=size.small)
// --- Optional: Adding Alerts for Bullish and Bearish Signals ---
alertcondition(bullishSignal, title="Bullish Signal Alert", message="Bullish signal detected!")
alertcondition(bearishSignal, title="Bearish Signal Alert", message="Bearish signal detected!")
// --- Optional: Smoothed LMR Values for Reduced Noise ---
LMR1_smooth = ta.sma(MR1, 10) // Smooth MR1 over 10 periods
LMR2_smooth = ta.sma(LMR2, 10) // Smooth LMR2 over 10 periods
LMR3_smooth = ta.sma(LMR3, 10) // Smooth LMR3 over 10 periods
// --- Plot Smoothed LMR Values ---
plot(LMR1_smooth, color=color.green, title="Smoothed MR1")
plot(LMR2_smooth, color=color.orange, title="Smoothed LMR2")
plot(LMR3_smooth, color=color.purple, title="Smoothed LMR3")



Comments