How To Set Backtest Time Ranges

Example how to set the time range window to be backtested for both entries and exits. Additional examples are also included showing how to set the date range and toggle plot visibility.

By incorporating this code with your own strategy's logic, it will allow you to backtest various time windows.

Much gratitude to @LucF and @a.tesla2018 for help with including ':1234567' for time ranges on weekends. 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: Cosmetic.
Von Favorisierten Skripten entfernen Zu Favorisierten Skripten hinzufügen
Telegram: • Gunbot Tuners:

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

LTC (preferred): LTDaAe7nPzbpBhZVT9o5f9f8M3aZSPa46Y

BTC: 13LhkeXBYrRomVAqbXcoLXHuqMk6Mf7G6N


wish to work with my strategy from 10 AM to 02:30 PM only . Please guide me how to code that one
@iamakp, in script above replace logic for enterLong and exitLong with your own logic.
Hi @allanster, thanks for this script.
Pls can you show me a way or a script to pin/fix a timeline on the chart? So that let's say i'm on 2012 timeline in Daily timeframe, when i change to 1 hr or lower timeframe, it stays on the same 2012. Please help. I would be waiting for your reply soon. Thanks
allanster Forexking7
@Forexking7, Pine currently has no ability to control which portion of the chart you are viewing.
Forexking7 allanster
@allanster, alright, thanks. I appreciate the reply.
@allanster Thanks for the post.

I was playing around with my strategy to fix the backtest time range part.

Your piece of code for back test time range is what I was exactly looking for and worked perfectly for me.
allanster irshad6964
@irshad6964, nice to know it helped, thanks!
Hello Allanster. Thank you for posting. I also would like to do something similar to Hero_H. I'd like to get the high, low, and close between 10 AM and 2 PM. I'd also like to test a later time in the day, but not sure yet. So, the times would need to be user-editable. Can you please show me how to write that. I'd be more than happy to get you several refreshing beverages!
allanster haydnlogan
@haydnlogan, sent you DM with some resources that hopefully may help.
Hi @allanster, do you think there could be a way to define a fixed point on a chart (say an exact candle) and write a script that uses the high or low of that candle as a fixed point and then uses a second point that is dynamic, like the lowest low since the original candle?
so the logic would look like this (assume a falling market)
point A = the high of a candle the the user inputs(could be time and date eg the candle at 6pm on the 10th of feb)
point B = the lowest low from point A (so keeps updating as price moves lower)
I am try to make an auto fib that draws between those 2 points
Not asking you to code it, but curious as to whether you think its possible

Many thanks!
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 Angeworbene Freunde Coins Meine Support Tickets Hilfe Center Veröffentlichte Ideen Followers Ich folge Private Nachrichten Chat Abmelden