Rajandran R Creator of OpenAlgo - OpenSource Algo Trading framework for Indian Traders. Building GenAI Applications. Telecom Engineer turned Full-time Derivative Trader. Mostly Trading Nifty, Banknifty, High Liquid Stock Derivatives. Trading the Markets Since 2006 onwards. Using Market Profile and Orderflow for more than a decade. Designed and published 100+ open source trading systems on various trading tools. Strongly believe that market understanding and robust trading frameworks are the key to the trading success. Building Algo Platforms, Writing about Markets, Trading System Design, Market Sentiment, Trading Softwares & Trading Nuances since 2007 onwards. Author of Marketcalls.in

Preparing the Features Dataset using Amibroker Exploration – Machine Learning

1 min read

There are various methods to prepare the feature dataset, which is a crucial input for a machine learning prediction model. One approach is to code technical indicators using Python and feed them as input to the model. Another simpler approach is to utilize Amibroker’s AFL Exploration, which provides built-in indicators and also supports custom indicators that are easy to code, explore, and prepare as feature datasets. The exploration dataset can then be extracted in CSV format.

Understanding Features and Targets

In machine learningfeatures represent the input data points or independent variables used to describe various aspects of the object under study. Targets, on the other hand, are the output or dependent variables that the model aims to predict or classify based on the input features.

If you are a beginner in Machine Learning the first thinking will be that technical analysis indicators like rsi, macd, ema, etc can be used to predict the value of Nifty the next day close. Will be using Amibroker to prepare the dataset easily.

Amibroker AFL Code for Exploration


Filter = 1;
AddColumn(Open,"Open",1.2);
AddColumn(High,"High",1.2);
AddColumn(Low,"Low",1.2);
AddColumn(Close,"Close",1.2);
AddColumn(Volume,"Volume",1.2);
AddColumn(Ref(Close,-1),"prevclose",1.2);
AddColumn(RSI(14),"rsi",1.2);
AddColumn(EMA(Close,5),"ema5",1.2);
AddColumn(EMA(Close,10),"ema10",1.2);
AddColumn(HMA(Close,5),"hma5",1.2);
AddColumn(HMA(Close,7),"hma7",1.2);
AddColumn(HMA(Close,9),"hma9",1.2);
AddColumn(ADX(14),"adx",1.2);
AddColumn(PDI(14),"pdi",1.2);
AddColumn(MDI(14),"mdi",1.2);
AddColumn(ATR(10),"atr",1.2);
AddColumn(Ref(Close,1),"close_forecast",1.2);

Performing Exploration

1)Open Amibroker and Select the Respective EOD database which contains EOD data to be exported as features dataset.

2)Save the above afl code as Feature Set EOD Close Prediction.afl inside formulas/custom folder (or any other folder of your choice)

3)Open New Analysis and Selec the Feature Set EOD Close Prediction.afl code

4)Click on Settings icon and Select the periodicity as Daily to export features data from daily timeframe

5)Press Explore to get the Features Dataset. Once Exploration is done goto File -> Export HTML/CSV data and save the file as NIFTY_EOD.csv in your local folder

6)Download the NIFTY_EOD.csv file

Rajandran R Creator of OpenAlgo - OpenSource Algo Trading framework for Indian Traders. Building GenAI Applications. Telecom Engineer turned Full-time Derivative Trader. Mostly Trading Nifty, Banknifty, High Liquid Stock Derivatives. Trading the Markets Since 2006 onwards. Using Market Profile and Orderflow for more than a decade. Designed and published 100+ open source trading systems on various trading tools. Strongly believe that market understanding and robust trading frameworks are the key to the trading success. Building Algo Platforms, Writing about Markets, Trading System Design, Market Sentiment, Trading Softwares & Trading Nuances since 2007 onwards. Author of Marketcalls.in

CUSUM Filter Strategy in AmiBroker AFL: A Practical Implementation

Detecting meaningful shifts in price trends while filtering out market noise is a challenge many traders face. Inspired by Jakub Polec’s blog, which applies...
Rajandran R
2 min read

Fisher Transform – Amibroker AFL Code

The Fisher Transform is a technical analysis indicator developed by John F. Ehlers, designed to identify potential turning points in the price movements of...
Rajandran R
2 min read

My Experience Converting SSL Hybrid from PineScript to Amibroker…

As a trader and coding enthusiast, I often find myself needing to translate trading indicators from one programming language to another. Recently, I embarked...
Rajandran R
8 min read

Leave a Reply

Get Notifications, Alerts on Market Updates, Trading Tools, Automation & More