Stock Portfolio Organizer

The ultimate porfolio management solution.

Shares, Margin, CFD's, Futures and Forex
EOD and Realtime
Dividends and Trust Distributions
And Much More ....
For Portfolio Manager Click Here

WiseTrader Toolbox

#1 Selling Amibroker Plugin featuring:

Advanced Adaptive Indicators
Advanced Pattern Exploration
Neural Networks
And Much More ....
Find Out More Here

Accumulative Swing Index (ASI) for Amibroker (AFL)

Rating:
0 / 5 (Votes 0)
Tags:
Accumulative Swing Index (ASI)

Accumulative Swing Index (ASI)

Indicator / Formula

Copy & Paste Friendly

Accumulative Swing Index (ASI)

_SECTION_BEGIN("Accumulative Swing Index (ASI)");

// Define parameters
asiPeriod = Param("ASI Period", 14, 1, 100, 1);
maPeriod = Param("MA Period", 50, 1, 200, 1);
rsiPeriod = Param("RSI Period", 14, 1, 50, 1);
rsiOverbought = Param("RSI Overbought Level", 70, 50, 100, 1);
rsiOversold = Param("RSI Oversold Level", 30, 0, 50, 1);
volumeThreshold = Param("Volume Threshold", 100000, 1, 10000000, 10000);

// Calculate Swing Index
prevClose = Ref(Close, -1);
K = Max(H - prevClose, L - prevClose);
SwingIndex = IIf(H == L, 0, 
                IIf(Close > prevClose, (50 * (Close - prevClose + 0.5 * (Close - Open) + prevClose - Open) / K), 
                    (50 * (Close - prevClose + 0.5 * (Close - Open) + prevClose - Open) / K)));

// Calculate ASI
asi = Cum(SwingIndex);

// Calculate Moving Average (filter)
maValue = MA(Close, maPeriod);

// Calculate RSI (additional filter)
rsiValue = RSI(rsiPeriod);

// Buy and Sell Signals based on ASI and additional filters
buySignal = Cross(asi, MA(asi, asiPeriod)) AND Close > maValue AND Volume > volumeThreshold AND rsiValue < rsiOversold;
sellSignal = Cross(MA(asi, asiPeriod), asi) AND Close < maValue AND Volume > volumeThreshold AND rsiValue > rsiOverbought;

// Plot the price chart
Plot(Close, "Price", colorBlack, styleCandle);

// Plot ASI
Plot(asi, "Accumulative Swing Index (ASI)", colorBlue, styleLine);

// Plot Moving Average
Plot(maValue, "MA(" + maPeriod + ")", colorRed);

// Plot Buy and Sell signals on the price chart
Buy = buySignal;
Sell = sellSignal;

// Plot Buy and Sell arrows on the chart
PlotShapes(IIf(Buy, shapeUpArrow, shapeNone), colorGreen, 0, Low, Offset=-30);
PlotShapes(IIf(Sell, shapeDownArrow, shapeNone), colorRed, 0, High, Offset=30);

// Add additional indicators for better visualization
Plot(rsiValue, "RSI(" + rsiPeriod + ")", colorLightOrange, styleLine);
Plot(Volume, "Volume", colorBlue, styleHistogram | styleOwnScale);

// Plot buy and sell signals on the indicator chart for reference
PlotShapes(IIf(Buy, shapeStar, shapeNone), colorGreen, 0, Low, Offset=-10);
PlotShapes(IIf(Sell, shapeStar, shapeNone), colorRed, 0, High, Offset=10);

// Generate buy and sell signals
Buy = ExRem(Buy, Sell);
Sell = ExRem(Sell, Buy);

_SECTION_END();

0 comments

Leave Comment

Please login here to leave a comment.

Back