System Architecture: Two Sections
This AFL is organised into two _SECTION_BEGIN blocks โ TSL (Trailing Stop Level) and SWING โ each handling a distinct part of the strategy:
TSL Section: Color Candles
Uses StochD(8,3,3), MACD histogram, RSI(3), and ValueWhen close comparisons to color each candle green (bull) or red (bear). This gives instant visual trend context without any manual analysis.
SWING Section: TSL Signal
The HHV/LLV trailing stop (TSL) is plotted as a staircase line. When close crosses above TSL โ Buy arrow. When close crosses below TSL โ Sell arrow. Clean, simple, effective.
The Multi-Indicator Color Logic
Candle color is determined by a cascading condition check โ making it one of the most information-rich visual signals in this AFL library:
Technical Specifications
Installation & Usage
Install the AFL
Copy Swing-Trading.afl to your AmiBroker\Formulas\Custom\ folder.
Apply on Daily Chart
Insert as an indicator on a Daily chart. Set the Swing parameter (default 5) โ higher values make the TSL wider and catch bigger swings.
Read the Signals
Green Up arrow = Buy signal (close crossed above TSL). Red Down arrow = Sell signal. White candles = neutral/sideways โ avoid new entries.
Trail Your Stop
Once in a trade, the teal staircase TSL line is your trailing stop. Exit when price closes below TSL (long) or above TSL (short).