OPEN-SOURCE SCRIPT
已更新 SMA Crossover with 1% SL/TP

This Pine Script strategy is built around a simple moving average (SMA) crossover and is an educational resource to illustrate how to write the NinjaTrader compatible message payload into your strategy.
This script specifically shows how to establish percentage based stops and targets, which can then be passed through the {{strategy.action.alert_message}} variable.
Entry Condition:
A buy order is triggered when the 1-period SMA crosses above the 3-period SMA.
A sell order is triggered when the 1-period SMA crosses below the 3-period SMA.
Stop Loss and Take Profit:
The stop loss and take profit levels are calculated as 1% above and below the entry price.
For a long position, the stop loss is set 1% below the entry price, and the take profit is set 1% above. For a short position, the stop loss is set 1% above the entry price, and the take profit is set 1% below.
The percentage-based approach ensures that the stop and target levels scale with the price, offering a flexible risk management solution. Feel free to modify this script as you see fit and don't forget to add your secret key for the alerts to pass through CrossTrade.
This script specifically shows how to establish percentage based stops and targets, which can then be passed through the {{strategy.action.alert_message}} variable.
Entry Condition:
A buy order is triggered when the 1-period SMA crosses above the 3-period SMA.
A sell order is triggered when the 1-period SMA crosses below the 3-period SMA.
Stop Loss and Take Profit:
The stop loss and take profit levels are calculated as 1% above and below the entry price.
For a long position, the stop loss is set 1% below the entry price, and the take profit is set 1% above. For a short position, the stop loss is set 1% above the entry price, and the take profit is set 1% below.
The percentage-based approach ensures that the stop and target levels scale with the price, offering a flexible risk management solution. Feel free to modify this script as you see fit and don't forget to add your secret key for the alerts to pass through CrossTrade.
發行說明
Converted to Pine Script V6發行說明
- Swapped the NT8 instrument format for the Pine Script {{ticker}} variable now that CrossTrade supports continuous contracts and will automatically convert the ticker into NT8s format. 開源腳本
本著TradingView的真正精神,此腳本的創建者將其開源,以便交易者可以查看和驗證其功能。向作者致敬!雖然您可以免費使用它,但請記住,重新發佈程式碼必須遵守我們的網站規則。
免責聲明
這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。
開源腳本
本著TradingView的真正精神,此腳本的創建者將其開源,以便交易者可以查看和驗證其功能。向作者致敬!雖然您可以免費使用它,但請記住,重新發佈程式碼必須遵守我們的網站規則。
免責聲明
這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。