allanster

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!
Jan 21
Release Notes: Cosmetic.
Remove from Favorite Scripts Add to Favorite Scripts
If you find something useful enough that you would like to buy me a refreshing beverage :)...

LTC (preferred): LTDaAe7nPzbpBhZVT9o5f9f8M3aZSPa46Y

BTC: 13LhkeXBYrRomVAqbXcoLXHuqMk6Mf7G6N

Comments

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!
Reply
allanster Hero_Hedge
@Hero_Hedge, yes should be possible.
+1 Reply
Hero_Hedge allanster
@allanster, Thanks!!!!!
Reply
Hi, how can i get the Open_Price of the First Bar of the day??
Reply
allanster cavinodpat
@cavinodpat, I published an example of how to calculate prices for and overlay first lower timeframe bar of the day here:
Reply
cavinodpat allanster
@allanster, Thank you so much
Reply
great job as always A!
Reply
allanster TheCryptoBot
@TheCryptoBot, thank you sir!
Reply
Home Stock Screener Forex Screener Crypto Screener Economic Calendar How It Works Chart Features Pricing Refer a friend House Rules Help Center Website & Broker Solutions Widgets Charting Solutions Lightweight Charting Library Blog & News Twitter
Profile Profile Settings Account and Billing Refer a friend My Support Tickets Help Center Ideas Published Followers Following Private Messages Chat Sign Out