AmiBroker + TradingView Stock Signal Indicator
A Bollinger/moving-average zone signal system for Vietnamese stocks, written in AmiBroker AFL and kept functionally identical in a Pine Script v6 port, with MACD confirmation, an info table and licence expiry.
The problem
Retail stock traders in Vietnam use both AmiBroker and TradingView. The goal was one clear buy/sell zone system, in the local language, that behaves the same on both platforms and can be licensed for a fixed period.
What I built
- Zone state machine: price above both moving averages is a buy zone and below both is a sell zone. The moving-average type (SMA, EMA, WMA, DEMA, TEMA) is selectable.
- Signal filters: an optional anti-whipsaw filter (no opposite signal within N bars) and MACD histogram confirmation that can arrive up to 10 bars late.
- One signal per zone: signals alternate strictly, using
ExRem/Flipin AFL andvarstate in Pine. - Info table: entry price, P/L percent, days held, +15/30/50% targets, a defensive price and the current zone recommendation, with Vietnamese labels.
- Visuals: Bollinger Band fill coloured by zone, and custom rendering with AmiBroker’s Gfx functions.
- Licence expiry: a warning 7 days before the end date. At expiry, the plots are hidden, the background turns grey and a renewal notice appears.
- Pine Script v6 port that follows the AFL logic, with a documented rule that both versions change together.
Details
- A reversal filter that repainted in the AFL version was rewritten in Pine to look only at past bars.