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

Interactive Brokers – Smart Order Chart Trading Module using…

The IB Controller is an interface designed to facilitate automatic trading with AmiBroker and Interactive Brokers (IB) TWS (Trader Workstation). It serves as a...
Rajandran R
8 min read

Introducing OpenAlgo V1.0: The Ultimate Open-Source Algorithmic Trading Framework…

OpenAlgo V1.0 is an open-source algorithmic trading platform to automate your trading strategies using Amibroker, Tradingview, Metatrader, Python etc. Designed with the modern trader...
Rajandran R
2 min read

[Live Coding Webinar] Build Your First Trading Bridge for…

In this course, you will be learning to build your own trading bridge using Python. This 60-minute session is perfect for traders, Python enthusiasts,...
Rajandran R
1 min read

Leave a Reply

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