Rajandran R Founder of Marketcalls and Co-Founder Algomojo. Full-Time Derivative Trader. Expert in Designing Trading Systems (Amibroker, Ninjatrader, Metatrader, Python, Pinescript). Trading the markets since 2006. Mentoring Traders on Trading System Designing, Market Profile, Orderflow and Trade Automation.

Amibroker AFL Code to Compute 10 Year Rolling Returns

35 sec read

Here is the simple AFL code to compute the 10 year rolling returns for any script. Generally Rolling Returns are computed for 3yr, 5yr, 10yr period. Rolling Returns are basically a performance measure of fund/index/stock over a period of time. Above chart shows current 10 year rolling returns of Nifty at 7.47%.

Rolling Returns are nothing but computation of Historical CAGR. Formula for calculation of CAGR is shown below.

CAGR = [(Ending Price ÷ Beginning Price)^1/n] – 1

where CAGR – Compound Annual Growth Rate
where “n” is the number of time periods (10 years for this example)

Note : To Compute 10 Year Rolling Returns historical data of 10+ years adjusted to split/bonus is required in case of stocks.

Here is the AFL code to compute 10 Year Rolling Returns. Code is designed to adapt to multiple timeframes like Daily, Weekly, Monthly however it is recommended to use weekly/monthly for better accuracy.

Amibroker AFL Code – 10 Year Rolling Returns

https://gist.github.com/8435aa28c0e24d12750854671b40b0f1

Rajandran R Founder of Marketcalls and Co-Founder Algomojo. Full-Time Derivative Trader. Expert in Designing Trading Systems (Amibroker, Ninjatrader, Metatrader, Python, Pinescript). Trading the markets since 2006. Mentoring Traders on Trading System Designing, Market Profile, Orderflow and Trade Automation.

Algomojo Index Straddle/Strangle Execution Module with Intraday Stoploss

This tutorial focus on how to automate your index straddle/strangle strategy with intraday stop-loss levels with time-based entry and exits using Algomojo Platform and...
Rajandran R
7 min read

Learn How to Login into Algomojo Account using Amibroker

In the last tutorial, we learn how to automate the algomojo login process and in this video tutorial, we are going to learn with...
Rajandran R
1 min read

Amibroker Execution Module – Hedged Index Futures for Directional…

In the last tutorial, we learn the importance of Hedging Futures Position with OTM Options for Reduced Margin. This tutorial focus on how to...
Rajandran R
14 min read

5 Replies to “Amibroker AFL Code to Compute 10 Year Rolling Returns”

  1. i’m using amibroker 4.80 & have data sinse 2003.
    but getting error in Afl program writer ” Ln: 2, Col: 8 : error 30. Syntax error”

Leave a Reply

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