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 and Co-Creator of Algomojo (Algorithmic Trading Platform for DIY Traders)

How to Plot the Equity Curve without Backtesting?

1 min read

Equity Curve is the graphical representation of how your money grows when you follow a particular trading system over a period of time. It shows whether your trading strategy is making money or loosing over a period of time.

In Amibroker the general way of computing the Equity curve is to backtest the given trading system and the report computes the equity curve, drawdown…etc results for you. And to compute the equity curve you have to push the backtest button every time which makes you little uncomfortable if you want to measure the Equity curve in realtime.

Here is a simple example which solves the problem and makes to measure the Equity curve to be computed in realtime. You can use this as a template in your trading strategies to calculate and plot the equity curve in realtime.

[wp_ad_camp_5]

 
Set the Initial Parameters

Let us assume that we have a Initial capital of Rs2,00,000 and we want to test our trading system in Nifty futures(10% Margin deposit Required) and Rs100 for per leg transaction for two lots of Nifty Futures(i.e Rs200 for both buy and Sell. Then the Intial Parameters can be set using the AFL code as shown below

//Initial Parameters

SetOption( “InitialEquity”, 200000);
SetOption(“FuturesMode” ,True);
SetOption(“MinShares”,1);
SetOption(“CommissionMode”,2);
SetOption(“CommissionAmount”,100);
SetOption(“AccountMargin”,10);
SetOption(“RefreshWhenCompleted”,True);

//Position Sizing

SetPositionSize(100,spsShares);

Buy/Sell Logic

Once the initial parameters are set then you need to concentrate on your buy and sell logic. Here in this case i had taken a simple EMA crossover 20 and 50 in this example for easier understanding and the logic is code as afl as shown below.

Rules are very Simple Buy when 20 EMA crosses 50EMA on the upper side(Positive Crossover) and sell when 50EMA crosses 20 EMA on the downside(negative crossover).

//Parameters

MALength1 = Optimize(“MALength1”,20,1,5,1);
MALength2 = Optimize(“MALength2”,50,1,5,1);

//Buy-Sell Logic

Buy = Cross(ema( C, MALength1 ),ema( C, MALength2 ));
Sell =Cross( ema( C, MALength2 ), ema( C, MALength1 )) ;

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

Short = Sell;
Cover = Buy;

Compute Equity Curve

In Amibroker the equity function returns single-security Equity line based on buy/sell/short/cover rules, buy/sell/short/coverprice arrays, all apply stops, and all other backtester settings.

For Example e=equity(0,1); retrieves the equity curve for based on buy/sell/short/cover rules with the given initial parameters. however if you want to retrieve the equity curve only for the selected from and to dates then checkout the following example which computes the equity curve between 1st May 2014 to 31st May 2014 and it computes in realtime.

start = ParamDate( “Start Date”, “2014-05-01” );
end=ParamDate( “End Date”, “2014-05-31” );
e=Equity(1,3,start,end); //Calculates for the Date Specific Quotes

For more detailed information refer the Equity Function in Amibroker.

Nifty Futures Equity Curve
Image showing the Nifty May futures hourly charts along with the Equity curve since 1st May 2014.

Download Simple EMA Crossover Trading System with Equity Curve plot

[note: Code provided here is for illustration purpose only]
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 and Co-Creator of Algomojo (Algorithmic Trading Platform for DIY Traders)

Sending Smart Futures/Spot – Signals to Two-Legged Options Execution…

Thought of making an open source AFL code demanded by most of the option traders to control the cost, to control the risk, and...
Rajandran R
12 min read

Send Smart Options Execution Orders from Futures or Spot…

This tutorial provides instructions on how to utilize simple buy and sell trading signals in Spot/Future charts to place option orders (including ATM, ITM,...
Rajandran R
19 min read

Backup your Amibroker EOD/Intraday Database in CSV Format

This Amibroker tutorial helps you to export your entire Amibroker EOD/Intraday Database in CSV Format with just a click of a button. Backing up...
Rajandran R
1 min read

2 Replies to “How to Plot the Equity Curve without Backtesting?”

Leave a Reply

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