allanster

How To Auto Set Date Range

Example how to automatically set the date range window to be backtested from X days or weeks ago to present. Additional options are also included to manually set the date range or to show entire range available.

Normally when you change chart period it changes the number of days being backtested, which means as you increase the chart period (for example from 5min to 15min), you also increase the number of days traded. So you can not compare apples to apples for which period would yield best performance for your strategy.

By incorporating this code with your own strategy's logic (replacing buy and sell), it will allow you to compare results of different period backtests over the same duration of time.

Date Range: ALL uses entire history.
Date Range: DAYS uses number you set in # Days or Weeks
Date Range: WEEKS uses number you set in # Days or Weeks
Date Range: MANUAL uses manual dates you set in From and To fields

Much gratitude to @pinechrix for suggesting this improvement to me, and to @Gesundheit for pointing me in the right direction on the original example I published previously. Thank you both!

NOTICE: This is an example script and not meant to be used as an actual strategy. By using this script or any portion thereof, you acknowledge that you have read and understood that this is for research purposes only and I am not responsible for any financial losses you may incur by using this script!
Versionshinweise: Added option to show on chart the date range selected.
Von Favorisierten Skripten entfernen Zu Favorisierten Skripten hinzufügen
Telegram: https://t.me/allanster • Gunbot Tuners: http://www.allanster.com

If you would like to buy me a refreshing beverage :)...

LTC (preferred): LTDaAe7nPzbpBhZVT9o5f9f8M3aZSPa46Y

BTC: 13LhkeXBYrRomVAqbXcoLXHuqMk6Mf7G6N

Kommentare

How come that in some strategies adding backtest script just doesnt work? For example in this strategy
Antworten
allanster robertocrypto
@robertocrypto, not sure I understand your question. If by "adding backtest script" you mean merging my "How To Auto Set Date Range" script above with the script you linked, the input lines 14-21 and the function lines 24-33 of my script above would need to be added to the other script somewhere before it's strategy.X functions. Then the window() function would need to be incorporated into the logic of each of the strategy.X functions in that script.
+2 Antworten
@allanster, Thank you, I'll try that.
Antworten
allanster allanster
Lines mentioned in answer above have shifted down since latest update. The sections that would need to be incorporated are:

// === INPUT BACKTEST RANGE ===

// === FUNCTION EXAMPLE ===
Antworten
Startseite Aktien-Screener Forex-Screener Krypto-Screener Wirtschaftskalender So funktioniert es! Chartmerkmale Preise Einen Freund empfehlen Hausregeln Hilfe Center Webseite & Brokerlösungen Widgets Charting Lösungen Lightweight Charting Library Blog & News Twitter
Profil Profileinstellungen Konto und Abrechnung Einen Freund empfehlen Meine Support Tickets Hilfe Center Veröffentlichte Ideen Followers Ich folge Private Nachrichten Chat Abmelden