[FN] Session Range & Date Range For Backtesting

This has been done before in different ways, however, my goal is to publish a single, simplified copy/paste version of the idea so you can quickly and easily incorporate it into your strategy backtesting.
You can designate weekdays, weekdays + weekends for 24/7 markets, and also session range.
So, you trade bitcoin? It works. CME futures? It works. You are a discretionary trader so the only signals that matter are the ones that happen when you're awake? It works. Copy and paste.
The goal is that its that easy. You'll have to let me know if it is. glhf everyone.

If I'm not mistaken, you should be able to copy/paste this directly into your strategy script (Paste it in before your entry declarations). Just leave out the last 2 lines where the bgcolor() is declared... unless you want the background color lit up, that's up to you. It's just for demonstration purposes in this script.

After you've pasted it in, then in your strategy.entry() function you are adding: to the strategy.entry() function.
strategy.entry("Long", strategy.long, qty=1, when = ENTRY_SIGNAL and signal_backtest())

Shoutouts to @zenandtheartoftrading and @allanster for providing the basis of this code that I put together here. We stand on the shoulders of giants.
お気に入りスクリプトから削除 お気に入りスクリプトに追加


Undervalued script! Thanks


1) If i have put a future date in in the "end" section why does it not fill up to that date and stop on the current day?
How can i change this to fill the full period?

2) What does (Define backtest range, Date range,Session Range and Use session constraint) do as when i click them NOTHING happens?
How can i just remove these if they not needed?

3) If i wanted to create lets say 4 colored backgrounds according to seasons. Can i just copy paste this script 4 times after each other?

All i want is a script for 4 sections to input 4 starting and ending day / months / years and adjust color so my backgrounds are different only for the season?

i want to do it in other way, hope you will help, i want to use this session on time session. for example. daily 8am-11am and 16pm-19pm. hope you can make changes required
kurtsmock ataleeq
@ataleeq, Are you saying you want to be able to do multiple sessions in one day?
ataleeq kurtsmock
@kurtsmock, yes, and its working for me already, i have made changes. thanks for quick response.
ホーム 株式スクリーナー FXスクリーナー 仮想通貨スクリーナー 経済指標カレンダー 使い方 チャート機能 価格 友達紹介 ハウスルール ヘルプセンター ウェブサイト&ブローカー向けソリューション ウィジェット チャートソリューション 軽量チャートライブラリ ブログ&ニュース ツイッター
プロフィール プロフィール設定 アカウントとお支払い 友達紹介 コイン マイサポートチケット ヘルプセンター 公開したアイデア フォロワー フォロー中 プライベートメッセージ チャット サインアウト