// Downloaded From https://www.WiseStockTrader.com // Accumulation Distribution (AD) Indicator AFL Script // This script calculates the Accumulation Distribution line // based on closing prices, volume, and the high/low range. function AccumulationDistribution() { // Price components H = High; // High price of the current bar L = Low; // Low price of the current bar C = Close; // Closing price of the current bar V = Volume; // Volume of the current bar // Calculate the AD value for the current bar // Money Flow Multiplier calculation MoneyFlowMultiplier = IIf(H == L, 0, // Avoid division by zero (C - L) / (H - L)); // Money Flow Volume calculation MoneyFlowVolume = MoneyFlowMultiplier * V; // Initialize the Accumulation Distribution (AD) array // AD should be cumulative, start from 0 AD = Cum(MoneyFlowVolume); // Cumulative sum of Money Flow Volume return AD; // Return the AD values } // Call the function to calculate AD values AD = AccumulationDistribution(); // Plot the Accumulation Distribution line Plot(AD, "Accumulation Distribution", colorBlue, styleLine | styleThick); // Add horizontal line at 0 for reference Plot(0, "Zero Line", colorRed, styleLine | styleDashed); // Create an alert condition (optional) // This generates a buy/sell signal when the AD line crosses above/below 0 BuySignal = Cross(AD, 0); SellSignal = Cross(0, AD); // Plot buy/sell signals on the chart PlotShapes(IIf(BuySignal, shapeUpArrow, shapeNone), colorGreen, 0, Low - 2*ATR(14)); PlotShapes(IIf(SellSignal, shapeDownArrow, shapeNone), colorRed, 0, High + 2*ATR(14)); // Displaying buy/sell signals in the analysis window Filter = 1; // This will always allow the buy/sell signals AddColumn(AD, "AD Value", 1.2);