// Identify Accumulation and Distribution accumulation = ta.crossover(fastMA, slowMA) // Bullish crossover distribution = ta.crossunder(fastMA, slowMA) // Bearish crossover
// Plot Accumulation and Distribution Zones bgcolor(accumulation ? color.new(color.green, 90) : na, title="Accumulation Zone") bgcolor(distribution ? color.new(color.red, 90) : na, title="Distribution Zone")
// Draw Boxes for Accumulation var float accumulationStart = na var float accumulationEnd = na
if accumulation accumulationStart := low // Start of accumulation candle accumulationEnd := na // Reset end on new accumulation
if not na(accumulationStart) and not distribution accumulationEnd := high // Keep updating the end of the accumulation candle
if not na(accumulationEnd) box.new(bar_index - 1, accumulationStart, bar_index, accumulationEnd, bgcolor=color.new(color.green, 70), border_color=color.green)
// Labels for Accumulation and Distribution if accumulation and not accumulation[1] label.new(bar_index, high, "Accumulation", style=label.style_label_down, color=color.green, textcolor=color.white)
if distribution and not distribution[1] label.new(bar_index, low, "Distribution", style=label.style_label_up, color=color.red, textcolor=color.white)
// Manipulation Detection: Assume manipulation if the price moves significantly within the threshold manipulation = (close - ta.lowest(low, 5)) / ta.lowest(low, 5) * 100 > manipulationThreshold
// Draw Boxes for Manipulation var float manipulationStart = na var float manipulationEnd = na
if manipulation manipulationStart := low // Start of manipulation candle manipulationEnd := high // End of manipulation candle
if not na(manipulationStart) box.new(bar_index - 1, manipulationStart, bar_index, manipulationEnd, bgcolor=color.new(color.yellow, 70), border_color=color.yellow)