AmiBroker exploration

Having recently discovered and purchased AmiBroker software I am keen to learn how to code my own indicators, trading systems and filters. Part of my own personal development will benefit by logging and sharing my various experiments and code, with today’s post showcasing my first ever trade exploration.

My first exploration intends as a quick method of comparing performance and volatility of chosen markets, whilst also serving to suggest the trend as bullish or bearish, reflecting the direction as red or green on the exploration.

I have spent a fare few hours transitioning from absolutely zero coding knowledge to creating trade explorations and indicators, so whilst the coding may not be efficient of within ‘best practices’ compared to professional coders, I am still proud of my progress so date and genuinely looking forward to developing my own strategies and systems in due course.


The exploration is a quick and dirty way of comparing performance and volatility, whilst also showing the underlying trend with red of green text on the ticker and full name columns.

Market Performance as %

This looks the 1 day, 1 week and 1 month % change on a close by close basis. Positive values are green whereas negative values are red. This means we can quickly see which trends are more bearish as 3 red columns will likely present more direct losses than mixed colour columns. Using the ROC (rate of Change indicator) it is a very raw way of looking at price changes. Where it has potential to fail is that it ignores price movements between periods, so may not always present clear trends. It is however a decent starting point.

ATR % Indicator

I have lost the original source, but I have taken the idea from Australian Trader Stuart McPhee. Although he uses it for (and advocates) MetaStock, software I seriously considered using over AmiBroker, the theory should be applicable to any trading software. By using ATR as a percentage it allows you to more easily compare volatility of various markets, and decide if a market is either too volatile or not volatile enough, as part of your trade filtering process. Taking this a step further I decided to show 10 day, 60 day and 255 day, as this also allows you to see if a market has more recently become more or less volatile compared to historical standard.

Plotting the moving averages

Annoyingly, every time I tried to visualise the moving averages on the chart, they would appear as an indicator at the bottom of the chart (as opposed to over the price where they should be). After many full circles it turns out the fix was blindingly obvious – you simply ‘overlay’ the exploration from the indicator menu.


With the moving averages now correctly placed on the chart (and not as an indicator blow the chart) and can visually see if the exploration is outputting the correct data




// read the list of symbols from Watchlist 0
// symlist = CategoryGetSymbols( Categorywatchlist, 200 );

// Conditions
ema1 = EMA(C,8);
ema2 = EMA(C,21);
ema3 = EMA(C,50);
ema4 = EMA(C,200);
Buy = ema1 > ema2 AND ema2 > ema3 AND ema3 > ema4;
Sell = ema1 < ema2 AND ema2 < ema3 AND ema3 < ema4;
Filter = Buy OR Sell;
// Explorer Columns
AddTextColumn( Name(),”Ticker”, 1.1, IIf( Buy, colorGreen, colorRed ), colorLavender, 50);
AddTextColumn( FullName(), “Full name”, 77, IIf( Buy, colorGreen, colorRed ), colorLavender, 250);
AddTextColumn( SectorID(1), “Sector”, 77, colorDefault, colorDefault, 150); // , colorDefault, IIf( Close < 10, colorRose, colorDefault ), 150);
AddTextColumn( IndustryID(1), “Industry”, 77, colorDefault, colorDefault, 150); // , colorBlack, IIf( Close < 10, colorRose, colorDefault ), 200);
AddTextColumn( Date(),”Date”, 1.1, colorGrey40, colorDefault, 75);
AddColumn(Close, “Close”,1.2, colorDefault, colorDefault, 50, Null);

//pchng = (C – Ref(C,-1)) /( Ref(C,-1) * 100);
AddColumn(pchng, “D1%”,1.2, IIf( ROC(C,1) > -0.01, colorGreen, colorRed ) );

//pchng = (C – Ref(C,-5)) /( Ref(C,-5) * 100);
AddColumn(pchng, “D5%”,1.2, IIf( ROC(C,5) > -0.01, colorGreen, colorRed ) );

//pchng = (C – Ref(C,-20)) /( Ref(C,-20) * 100);
AddColumn(pchng, “D20%”,1.2, IIf( ROC(C,20) > -0.01, colorGreen, colorRed ) );

//ATR Percentage (10)
ATRpchng = (ATR(10) / C) *100;
AddColumn(ATRpchng, “ATR(10) %”, 1.2);

//ATR Percentage (60)
ATRpchng = (ATR(60) / C) *100;
AddColumn(ATRpchng, “ATR(60) %”, 1.2);

//ATR Percentage (255)
ATRpchng = (ATR(255) / C) *100;
AddColumn(ATRpchng, “ATR(255) %”, 1.2);

// PLot averages on the chart (not as an indicator)
Plot(EMA(Close,8),”eMA 8″, colorOrange);
Plot(EMA(Close,21),”eMA 21″, colorBlue);
Plot(EMA(Close,50),”eMA 50″, colorRed);
Plot(EMA(Close,200),”eMA 200″, colorGreen);



Leave a Reply