Rajandran R Telecom Engineer turned Full-time Derivative Trader. Mostly Trading Nifty, Banknifty, USDINR and 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. Writing about Markets, Trading System Design, Market Sentiment, Trading Softwares & Trading Nuances since 2007 onwards. Author of Marketcalls.in)

Plotting Day Wise Equity Curve using Amibroker

1 min read

We know that Amibroker provides an equity curve for the whole strategy. Is there a way where we can build a simple Day Wise PNL to get a better idea about which day’s strategy is performing better to fine-tune the trading system?

It helps traders to avoid non-performing days. For example, if Friday’s Signal performance is not good then one can eliminate trading the system on Fridays.

Here is the simple visualization of Day Wise PNL (Monday Equity Curve, Tuesday Equity Curve ….. Friday Equity Curve)

Sample Trading Amibroker AFL Template to build Day Wise Equity Curve

_SECTION_BEGIN("Simple Two EMA Crossover Trading System");

SetChartOptions(0,chartShowArrows|chartShowDates);
SetPositionSize(1*RoundLotSize,spsShares);

shortema = Optimize("Short EMA",3,1,50,1);
longema = Optimize("Long EMA",13,1,50,1);

ema1 = EMA(Close,shortema);
ema2 = EMA(Close,longema);



//Trading Strategy

Buy = Cross(ema1,ema2); //bullish ema crossover - short MA crossing up long MA
Sell = Cross(ema2,ema1); //bearish ema crossover - long MA crossing down short MA



SetTradeDelays(0,0,0,0);

BuyPrice = ValueWhen(Buy,Close);
SellPrice = ValueWhen(Sell,Close);


iBuy = Buy;
iSell = Sell;

Buy = iBuy AND DayOfWeek()==1;
Sell = iSell;

Buy = ExRem(Buy,Sell);
Sell = ExRem(Sell,Buy);

e1 = Equity(1,0);

Buy = iBuy AND DayOfWeek()==2;
Sell = iSell;

Buy = ExRem(Buy,Sell);
Sell = ExRem(Sell,Buy);

e2 = Equity(1,0);

Buy = iBuy AND DayOfWeek()==3;
Sell = iSell;

Buy = ExRem(Buy,Sell);
Sell = ExRem(Sell,Buy);

e3 = Equity(1,0);

Buy = iBuy AND DayOfWeek()==4;
Sell = iSell;

Buy = ExRem(Buy,Sell);
Sell = ExRem(Sell,Buy);
e4 = Equity(1,0);

Buy = iBuy AND DayOfWeek()==5;
Sell = iSell;

Buy = ExRem(Buy,Sell);
Sell = ExRem(Sell,Buy);
e5 = Equity(1,0);

Plot(e1,"Eq-Monday",colorGreen,styleThick,styleOwnScale);
Plot(e2,"Eq-Tuesday",colorblue,styleThick,styleOwnScale);
Plot(e3,"Eq-Wednesday",colorRed,styleThick,styleOwnScale);
Plot(e4,"Eq-Thursday",colorYellow,styleThick,styleOwnScale);
Plot(e5,"Eq-Friday",colorPink,styleThick,styleOwnScale);


_SECTION_END();

Rajandran R Telecom Engineer turned Full-time Derivative Trader. Mostly Trading Nifty, Banknifty, USDINR and 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. Writing about Markets, Trading System Design, Market Sentiment, Trading Softwares & Trading Nuances since 2007 onwards. Author of Marketcalls.in)

[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

[Webinar] Understanding and Mitigating Curve Fitting in System Trading

"Understanding and Mitigating Curve Fitting in System Trading"! This dynamic session aims to equip novice to intermediate traders, quantitative analysts, and financial engineers with...
Rajandran R
1 min read

P-Signal Strategy Long Only Strategy – Amibroker AFL Code

This tutorial provides an overview of the P-Signal reversal strategy, a quantitative trading strategy that utilizes statistical parameters and error functions to generate probabilistic...
Rajandran R
2 min read

Leave a Reply

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