OPEN-SOURCE SCRIPT

Accumulation & Distribution Zones with Manipulation

//version=5
indicator("Accumulation & Distribution Zones with Manipulation", overlay=true)

// Parameters
fastLength = input.int(9, title="Fast MA Length")
slowLength = input.int(21, title="Slow MA Length")
manipulationThreshold = input.float(2.0, title="Manipulation Threshold (%)", minval=0)

// Moving Averages
fastMA = ta.sma(close, fastLength)
slowMA = ta.sma(close, slowLength)

// Plot Moving Averages
plot(fastMA, color=color.blue, title="Fast MA")
plot(slowMA, color=color.red, title="Slow MA")

// 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)

// Plot Manipulation Labels
if manipulation
label.new(bar_index, close, "Manipulation", style=label.style_label_down, color=color.yellow, textcolor=color.black)

// Alerts
alertcondition(accumulation, title="Accumulation Alert", message="Potential Accumulation Zone identified!")
alertcondition(distribution, title="Distribution Alert", message="Potential Distribution Zone identified!")
alertcondition(manipulation, title="Manipulation Alert", message="Potential Manipulation detected!")
Chart patternseducationalTrend Analysis

开源脚本

本着真正的TradingView精神,此脚本的作者已将其开源,以便交易者可以理解和验证它。向作者致敬!您可以免费使用它,但在出版物中重复使用此代码受网站规则约束。 您可以收藏它以在图表上使用。

想在图表上使用此脚本?

免责声明