Rajandran R Creator of OpenAlgo Sketchmaker, RagZ. 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. Now the recent curiosity on building Trading AI Agents.

Preparing the Features Dataset using Amibroker Exploration – Machine Learning

1 min read

There are various methods to prepare the feature dataset, which is a key 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 prepare the features dataset using Amibroker 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.

Preparing Feature Dataset using Amibroker Machine Learning

Understanding Features and Targets

In machine learning, features 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.

OpenAlgo Desktop: algo trading on your own computer

WINDOWS, MAC AND LINUX

OpenAlgo Desktop: algo trading on your own computer

Install, sign in, connect your broker and trade. No server to set up and no Python to install.

  • Same API and screens as OpenAlgo web
  • Strategy module, charting and scalping terminals
  • Keys stay encrypted on your machine

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

Preparing the Features Dataset using Amibroker Exploration - Machine Learning

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

Python Elite membership

MEMBERSHIP

Python Elite membership

15 Python, AI and algo trading programs in one plan, including QuantFlow and AI Bootcamp live mentorship.

  • Python from fundamentals to trading apps
  • Backtesting, broker APIs and OpenAlgo
  • Live QuantFlow and AI Bootcamp sessions
View Python Elite →by Marketcalls

Learn by watching: free videos every week

Market Profile, order flow, Python, AI and OpenAlgo tutorials on YouTube.

Rajandran R Creator of OpenAlgo Sketchmaker, RagZ. 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. Now the recent curiosity on building Trading AI Agents.

Leave a Reply

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