Click here to Login





                                                   Print daily equity with monthly timeframe

  1

0
Salvatore Gaziano
2016-06-09 04:14:40


Hello everyone,
i've a problem that i can't solve: i've implemented some monthly strategies that use monthly bars. Now i want print the daily equity value of my backtest: i've created a AMM script that catch this value and relative date for every OnEndPeriod anche append it on csv file.
But if i set monthly time frame, the end of period is monthly and i can't print daily equity.
Than i think to adapt the backtest rule to use daily bars, but there is a problem: now i calculate every value using monthly time frame and, for example, if i want performance at 4 months i've "returnA = performance(close, 4);". If i convert the time frame from monhtly to daily, how can i write a code that use only the daily bars included in this 4 months?
I saw that many users use to aproximate one monthly bar to 21 daily bars (than, for performance at 4 months, use "returnA = performance (close, 4*21);" ), but this isn't correct and the result isn't comparable with the same code that use monthly time frame although in both systems i use rebalance every month.
I'm searching a solution that return the same result of monthly time frame or return me the daily equity value usin monthly time frame.

Thanks.
Best regards.



QuantShare
2016-06-09 08:43:08

  0

You can use the time frame conversion function. Here is an example, that calculates the 4-month performance (rate of return) based on daily data:

a = timeframedecompress(timeframeapply(3, roc(4)));



Salvatore Gaziano
2016-06-09 16:04:46

  0

Hi QuantShare, thanks for your replay. I tried your solution, but i'm not sure that it works.
I opened a chart, i setted "monthly" timeframe in the chart to plot the function:
a = roc(4);
plot( a, "performance", colorRed);

For each bar, i wrote the value returned on the pane (for may '16, the bar was 2016/05/01).
I setted "daily" timeframe and i've plotted the function that have you posted and i've compared the value on the last bar of each month (such as, on may '16, the bar on the 2016/05/31) with the value earlier writed and they didn't correspond.
For example, if i set "MDY" ETF i obtain this result
performance at 4 months with monthly bars on 2016/05/01 - 13,2725
performance at 4 months with daily bars on 2016/05/31 - 3,73

http://s33.postimg.org/hevfg534f/monthly.png
http://s33.postimg.org/bxpc5o9vz/daily.png



QuantShare
2016-06-09 18:21:45

  0

Best Answer
Sorry there was a typo. The second parameter of the "timeframeapply" is the time frame.
It should be:
a = timeframedecompress(timeframeapply(31, roc(4))); //365 for yearly, 31 for monthly, 7 for weekly



Salvatore Gaziano
2016-06-10 12:06:56

  0

Hi, now it works! I've tried your solution and the backtest based on monthly timeframe and daily trimeframe return the same result.
I'm not undestrading why some values aren't alike: Initial Cap and Net Profit are the same, the Yearly performance year by year are the same, but Drawdown and Annual Return are different (i think Sortino, Ulcera etc... not correspond because drawdown and annual return are different). The order flow is the same. Them are the result http://s33.postimg.org/699vh27b3/result.png
Have you some idea about?

Thanks



QuantShare
2016-06-11 10:41:17

  0

Of course a lot of metrics would be different, this is simply because they will first be calculated based on monthly bars and then with daily bars.


No more messages
0




Reply:

No html code. URLs turn into links automatically.

Type in the trading objects you want to include: - Add Objects
To add a trading object in your message, type in the object name, select it and then click on "Add Objects"










QuantShare

Trading Items
Intraday Trading System with Daily Ranking
Equity Put-Call Ratio
Monthly individual stocks put and call volume
Nepal Market - Daily Stock Quotes
Asset Allocation: Equal Weight Rebalanced Monthly

How-to Lessons
How to print a chart
How to screen for stocks having a high correlation with the Dow J...
How to create a chart with a black background
How to associate an index with a list of stocks
How to use QuantShare with Metastock data

Related Forum Threads
Help With Daily Data Import Script
Mixing Daily and Monthly (or weekly) data
Trouble with GetSeries
Equity Curve and Trades list for out-of-sample Walk Forward test
Display weekly RSI in a daily chart

Blog Posts
Long Term Trading with Technical Analysis
Optimizing the Strategy Equity Curve
Trading System: Buy stocks with the highest Sharpe ratio
Trading the Strategy Equity Curve
How to Backtest an Intraday Stock Trading System with EOD Ranking









QuantShare
Product
QuantShare
Features
Create an account
Affiliate Program
Support
Contact Us
Trading Forum
How-to Lessons
Manual
Company
About Us
Privacy
Terms of Use

Copyright © 2024 QuantShare.com
Social Media
Follow us on Facebook
Twitter Follow us on Twitter
Google+
Follow us on Google+
RSS Trading Items



Trading financial instruments, including foreign exchange on margin, carries a high level of risk and is not suitable for all investors. The high degree of leverage can work against you as well as for you. Before deciding to invest in financial instruments or foreign exchange you should carefully consider your investment objectives, level of experience, and risk appetite. The possibility exists that you could sustain a loss of some or all of your initial investment and therefore you should not invest money that you cannot afford to lose. You should be aware of all the risks associated with trading and seek advice from an independent financial advisor if you have any doubts.