Rajandran R Creator of OpenAlgo - OpenSource Algo Trading framework for Indian Traders. 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. 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

Line Trading – OpenAlgo Automation Module for Amibroker Users

The line Trading Automation tool is designed for Manual traders who want to perform level-based trade execution faster and also bring some advanced trade...
Rajandran R
55 sec read

Mini Certification Course on Algorithmic Trading

Welcome to the Mini Certification on Algorithmic Trading using Amibroker and OpenAlgo! This comprehensive 4-part series is designed to equip you with the knowledge...
Rajandran R
1 min read

Pivot Reversal Strategy – Tradingview Pinescript to Amibroker AFL…

Pivot Reversal Strategy is a popular in-built strategy in Tradingview Platform. Here I had attempted to convert the pinescript v5 to Amibroker AFL Code....
Rajandran R
3 min read

Leave a Reply

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