OPEN-SOURCE SCRIPT

Ultimate Strategy Template (Advanced Edition)

ที่อัปเดต:
Hello traders

This script is an upgraded version of that one below

https://www.tradingview.com/script/2lGyzYkC-Ultimate-Strategy-Template/

New features

- Upgraded to Pinescript version 5
- Added the exit SL/TP now in real-time
- Added text fields for the alerts - easier to send the commands to your trading bots

Step 1: Create your connector

Adapt your indicator with only 2 lines of code and then connect it to this strategy template.

For doing so:

1) Find in your indicator where are the conditions printing the long/buy and short/sell signals.
2) Create an additional plot as below

I'm giving an example with a Two moving averages cross.

Please replicate the same methodology for your indicator wether it's a MACD , ZigZag , Pivots , higher-highs, lower-lows or whatever indicator with clear buy and sell conditions.



Basically, I identified my buy, sell conditions in the code and added this at the bottom of my indicator code



Important Notes

🔥 The Strategy Template expects the value to be exactly 1 for the bullish signal, and -1 for the bearish signal

Now you can connect your indicator to the Strategy Template using the method below or that one

Step 2: Connect the connector

1) Add your updated indicator to a TradingView chart
2) Add the Strategy Template as well to the SAME chart
3) Open the Strategy Template settings and in the Data Source field select your 🔌Connector🔌 (which comes from your indicator)

From then, you should start seeing the signals and plenty of other stuff on your chart

🔥 Note that whenever you'll update your indicator values, the strategy statistics and visual on your chart will update in real-time

Settings

- Color Candles: Color the candles based on the trade state ( bullish , bearish , neutral)
- Close positions at market at the end of each session: useful for everything but cryptocurrencies
- Session time ranges: Take the signals from a starting time to an ending time
- Close Direction: Choose to close only the longs, shorts, or both
- Date Filter: Take the signals from a starting date to an ending date
- Set the maximum losing streak length with an input
- Set the maximum winning streak length with an input
- Set the maximum consecutive days with a loss
- Set the maximum drawdown (in % of strategy equity)
- Set the maximum intraday loss in percentage
- Limit the number of trades per day
- Limit the number of trades per week
- Stop-loss: None or Percentage or Trailing Stop Percentage or ATR - I'll add shortly multiple options for the trailing stop loss
- Take-Profit: None or Percentage or ATR - I'll add also a trailing take profit
- Risk-Reward based on ATR multiple for the Stop-Loss and Take-Profit

Special Thanks

Special thanks to @JosKodify as I borrowed a few risk management snippets from his website: kodify.net/tradingview-programming-articles/

Best
Dave
เอกสารเผยแพร่
Version 2
Fixed an issue with the TP1 logic and position sizes
เอกสารเผยแพร่
- Added the alerts txt fields for the custom close long/short events
เอกสารเผยแพร่
Version 3

- Added a table displaying the opened trades data - works even with multiple opened trades
- the table is fully customisable: colors, location, text size, and much more....
- Added a sample script commented at the beginning of the script
เอกสารเผยแพร่
Version 5
Fixed an issue with the TPs when pyramiding > 1 is enabled
It was recalculating the TPs for every new pyramiding signal
It's common usage that the TPs and SL are calculated at the first signal of the trend
เอกสารเผยแพร่
Version 5.1

Fixed an issue with the SL and TPs (again)
Now it works as expected
เอกสารเผยแพร่
Version 5.2

Added the ability to create alerts using the "alert() function call only mode" which aren't based on the backtest orders fills but on my custom conditions
Sometimes, the backtest fills the orders too late, especially during very quick price action events

Example: imgur.com/a/NiH0MeT
เอกสารเผยแพร่
Version 6

- Added a Stop-Loss to Breakeven logic
- Added a custom optional exit logic closing closing the opened trade(s) after X bars
เอกสารเผยแพร่
Fixed and Improved the trailing SL logic
เอกสารเผยแพร่
Version 7

Removed the TP2 logic as it prevented the exit SL/TP1 orders to get executed in real-time
เอกสารเผยแพร่
- Fixed the SL to Breakeven logic
educationalPine utilitiesstrategytemplateTrend Analysis

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

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

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


⭐️ Listed as an Official TradingView Trusted TOP Pine Programmer

📧 Coding/Consulting Inquiries: dave@best-trading-indicator

Telegram: Daveatt

⏩ Course: best-trading-indicator.com

Twitter: twitter.com/bti_trading
และใน:

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