Quantcast
Channel: Market Calls
Viewing all articles
Browse latest Browse all 2070

Plotting Day Wise Equity Curve using Amibroker

$
0
0

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();

The post Plotting Day Wise Equity Curve using Amibroker appeared first on Marketcalls.


Viewing all articles
Browse latest Browse all 2070

Trending Articles