Peter_O

TradingView Alerts to MT4 MT5 + dynamic variables NON-REPAINTING

Peter_O 已更新   
Accidentally, I’m sharing open-source profitable Forex strategy. Accidentally, because this was aimed to be purely educational material. A few days ago TradingView released a very powerful feature of dynamic values from PineScript now being allowed to be passed in Alerts. And thanks to TradingConnector, they could be instantly executed in MT4 or MT5 platform of any broker in the world. So yeah - TradingConnector works with indices and commodities, too.

The logic of this EURUSD 6h strategy is very simple - it is based on Stochastic crossovers with stop-loss set under most recent pivot point. Setting stop-loss with surgical precision is possible exactly thanks to allowance of dynamic values in alerts. TradingConnector has been also upgraded to take advantage of these dynamic values and it now enables executing trades with pre-calculated stop-loss, take-profit, as well as stop and limit orders.

Another fresh feature of TradingConnector, is closing positions only partly - provided that the broker allows it, of course. A position needs to have trade_id specified at entry, referred to in further alerts with partial closing. Detailed spec of alerts syntax and functionalities can be found at TradingConnector website. How to include dynamic variables in alert messages can be seen at the very end of the script in alertcondition() calls.

The strategy also takes commission into consideration.

Slippage is intentionally left at 0. Due to shorter than 1 second delivery time of TradingConnector, slippage is practically non-existing. This can be achieved especially if you’re using VPS server, hosted in the same datacenter as your brokers’ servers. I am using such setup, it is doable. Small slippage and spread is already included in commission value.

This strategy is NON-REPAINTING and uses NO TRAILING-STOP or any other feature known to be faulty in TradingView backtester. Does it make this strategy bulletproof and 100% success-guaranteed? Hell no! Remember the no.1 rule of backtesting - no matter how profitable and good looking a script is, it only tells about the past. There is zero guarantee the same strategy will get similar results in the future.

To turn this script into study so that alerts can be produced, do 2 things:
1. comment “strategy” line at the beginning and uncomment “study” line
2. comment lines 54-59 and uncomment lines 62-65.
Then add script to the chart and configure alerts.

This script was build for educational purposes only.

Certainly this is not financial advice. Anybody using this script or any of its parts in any way, must be aware of high risks connected with trading.

Thanks @LucF and @a.tesla2018 for helping me with code fixes :)
版本注释:
Stoch default K value was changed.
版本注释:
Modified alertcondition() syntax.
版本注释:
Added plot definitions and plot names to fix passing dynamic variables to alerts.

Note! when converting to study for alerts, you need to uncomment lines 62-71, not 62-65, as explained in the original description.

By they way - previous update took place November 20, when net profit was at $56336.34 and profit factor 1.208. 40 days later these numbers have improved to over $57k and 1.21 profit factor. So it continues to grow :)
版本注释:
Fixed trade_id variable. Not all dynamic values were passed correctly to alerts.

Aaaaand - another 2 weeks, another check. Account appears to continue growing, +$500 since December 29 :)
版本注释:
With the fresh update to TradingConnector to version 2.5, I have decided to take a look at my previous scripts whether they are still using latest developments by TradingView dev team and guess what - this script definitely needed an update, too. It didn't include alerts-straight-from-strategy feature, so I have added the necessary lines at the end. Enjoy!
版本注释:
Updated to PineScript version 5.
版本注释:
With TradingConnector upgrade to version 1.35, a lot has been simplified, therefore this script update:
- Multiple Take-Profit feature has been introduced and example code can be found in this update.
- when dealing with single entries, tradeid= parameter is not needed (however still operational) for features like partial closing, slmod and tpmod. So tradeid= has been removed form this script.

Other new features are: 'delay=' parameter, separating TradingConnector alerts from all others, breakeven exit.
版本注释:
With the biggest TradingConnector's upgrade since its inception - including "Search&Replace Alerts Modifier", details can be found here: - it was highest time to update this script, to showcase the ability of setting exit conditions as percentage move from the entry price.

Moreover, alerts examples are now being displayed in an overlay.

I auto-execute TradingView Alerts into MT4/MT5 using this: www.tradingconnector.com 1-second delivery. Ping me if you need support with installation.
开源脚本

本着真正的TradingView精神,该脚本的作者将其开源发布,以便交易者可以理解和验证它。为作者喝彩!您可以免费使用它,但在出版物中重复使用此代码受网站规则的约束。 您可以收藏它以在图表上使用。

免责声明

这些信息和出版物并不意味着也不构成TradingView提供或认可的金融、投资、交易或其它类型的建议或背书。请在使用条款阅读更多信息。

想在图表上使用此脚本?