NOTE: There is a limit in backtesting to 2000 orders, so please be aware of this when setting your date ranges. If you set your range too high, you may be exceeding this limit on some periods and not on others, so this would yield incorrect comparison of returns per period. If you see in your backtesting results that you are nearing this limit for one of your periods you are testing, then reduce the date range to a smaller number of days.
(Thanks to @Gesundheit "Adeel" for pointing me in the right direction on this!)
- Using input statements for MA lengths.
- Using date range condition within execution.
- BONUS example of creating a function for date range.
Also added simple error checking to input statements for month and day.
For preventing the error on exceeding 2000 orders you must take steps to reduce the number of trades. Various means to do this include changing the range you are backtesting, changing the period, changing the frequency of how often your strategy trades, etc.
LTC (preferred): LTDaAe7nPzbpBhZVT9o5f9f8M3aZSPa46Y
Thanks alot for the script, you just did hell of a job there helping us out.
From what I understand, this is useful for chopping the already available (on the chart) time frame.
How about creating a chart with 3m intervals in the past, let's say in 2017 for the purposes of testing? I have been looking the whole day for a way to get back to certain periods in the past with different resoltions but I have not figured it out.
If you have any ideas that would be awesome. Because, honestly, a max of 5000 bars back on a 3m strategy is 10 days which is definitely not enough IMO.
Thanks once again.
I understand you can do that for backtesting an indicator on the same security.
I wonder whether one can PLOT a barcandle chart using for example the plotbar function a time in the past.
For example, in the chart (https://www.tradingview.com/x/5x9xpQ3W/) I have requested pine to plot a 3m interval bars from April 4, 2018 to May 10, 2018 for XBTEUR under a random chart which happened to be that of ECYT.
One can easily see that the plotted chart goes back only to May 7, 2018 (as far as I can go without putting it in pine as a main chart and zoom out). So I was asking whether there is a way to plot it before May 7??
Thank once again and I apologize if I am not grasping it or explaining myself wrong.