kurtsmock

[FN] Session Range & Date Range For Backtesting

kurtsmock ที่อัปเดต:   
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.
e.g:
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.
เอกสารเผยแพร่:
Updated for v5. Now its actually a function. =)
You can add it to a library if you like (which is where I pulled it from) or use it as it is in a script.

สคริปต์โอเพนซอร์ซ

ด้วยจิตวิญญาณของ TradingView อย่างแท้จริง ผู้เขียนสคริปต์นี้ได้เผยแพร่เป็นโอเพนซอร์ส เพื่อให้ผู้ค้าสามารถเข้าใจและตรวจสอบได้ ไชโยให้กับผู้เขียน! คุณสามารถใช้ได้ฟรี แต่การใช้รหัสนี้ซ้ำในสิ่งพิมพ์อยู่ภายใต้กฎระเบียบการใช้งาน คุณสามารถตั้งเป็นรายการโปรดเพื่อใช้บนชาร์ตได้

คำจำกัดสิทธิ์ความรับผิดชอบ

ข้อมูลและบทความไม่ได้มีวัตถุประสงค์เพื่อก่อให้เกิดกิจกรรมทางการเงิน, การลงทุน, การซื้อขาย, ข้อเสนอแนะ หรือคำแนะนำประเภทอื่น ๆ ที่ให้หรือรับรองโดย TradingView อ่านเพิ่มเติมที่ เงื่อนไขการใช้บริการ

ต้องการที่จะใช้สคริปต์นี้บนชาร์ตใช่ไหม?