OPEN-SOURCE SCRIPT

Heatmap MACD Strategy - Pineconnector (Dynamic Alerts)

Hello traders

This script is an upgrade of this template script.
Heatmap MACD Strategy

Pineconnector

Pineconnector is a trading bot software that forwards TradingView alerts to your Metatrader 4/5 for automating trading.
Many traders don't know how to dynamically create Pineconnector-compatible alerts using the data from their TradingView scripts.

Traders using trading bots want their alerts to reflect the stop-loss/take-profit/trailing-stop/stop-loss to breakeven options from your script and then create the orders accordingly.

This script showcases how to create Pineconnector alerts dynamically.

Pineconnector doesn't support alerts with multiple Take Profits.
As a workaround, for 2 TPs, I had to open two trades.
It's not optimal, as we end up paying more spreads for that extra trade - however, depending on your trading strategy, it may not be a big deal.

TradingView Alerts

1) You'll have to create one alert per asset X timeframe = 1 chart.
Example: 1 alert for EUR/USD on the 5 minutes chart, 1 alert for EUR/USD on the 15-minute chart (assuming you want your bot to trade the EUR/USD on the 5 and 15-minute timeframes)

2) For each alert, the alert message is pre-configured with the text below
{{strategy.order.alert_message}}

Please leave it as it is.
It's a TradingView native variable that will fetch the alert text messages built by the script.

3) Don't forget to set the webhook URL in the Notifications tab of the TradingView alerts UI.

EA configuration

The Pyramiding in the EA on Metatrader must be set to 2 if you want to trade with 2 TPs => as it's opening 2 trades.

If you only want 1 TP, set the EA Pyramiding to 1.

Regarding the other EA settings, please refer to the Pineconnector documentation on their website.

Logger

The Pineconnector commands are logged in the TradingView logger.
You'll find more information about it from this TradingView blog post

Important Notes

1) This multiple MACDs strategy doesn't matter much.
I could have selected any other indicator or concept for this script post.
I wanted to share an example of how you can quickly upgrade your strategy, making it compatible with Pineconnector.

2) The backtest results aren't relevant for this educational script publication.
I used realistic backtesting data but didn't look too much into optimizing the results, as this isn't the point of why I'm publishing this script.

3) This template is made to take 1 trade per direction at any given time.
Pyramiding is set to 1 on TradingView.

The strategy default settings are:

  • Initial Capital: 100000 USD

  • Position Size: 1 contract
  • Commission Percent: 0.075%
  • Slippage: 1 tick
  • No margin/leverage used


For example, those are realistic settings for trading CFD indices with low timeframes but not the best possible settings for all assets/timeframes.

Concept

The Heatmap MACD Strategy allows selecting one MACD in five different timeframes.
You'll get an exit signal whenever one of the 5 MACDs changes direction.

Then, the strategy re-enters whenever all the MACDs are in the same direction again.

It takes:

  • long trades when all the 5 MACD histograms are bullish
  • short trades when all the 5 MACD histograms are bearish


You can select the same timeframe multiple times if you don't need five timeframes.
For example, if you only need the 30min, the 1H, and 2H, you can set your timeframes as follow:

  • 30m
  • 30m
  • 30m
  • 1H
  • 2H


Risk Management Features

All the features below are pips-based.

  • Stop-Loss
  • Trailing Stop-Loss
  • Stop-Loss to Breakeven after a certain amount of pips has been reached
  • Take Profit 1st level and closing X% of the trade
  • Take Profit 2nd level and close the remaining of the trade


Custom Exit

I added the option ON/OFF to close the opened trade whenever one of the MACD diverges with the others.

Help me help the community

If you see any issue when adding your strategy logic to that template regarding the orders fills on your Metatrader, please let me know in the comments.
I'll use your feedback to make this template more robust. :)

What's next?

I'll publish a more generic template built as a connector so you can connect any indicator to that Pineconnector template.
Then, I'll publish a template for Capitalise AI, ProfitView, AutoView, and Alertatron.

Thank you
Dave
educationalmultitimeframepineconnectorPine utilities

Skrip open-source

Dengan semangat TradingView yang sesungguhnya, penulis skrip ini telah menerbitkannya sebagai sumber terbuka, sehingga para trader dapat memahami dan memverifikasinya. Hormat untuk penulisnya! Anda dapat menggunakannya secara gratis, namun penggunaan kembali kode ini dalam publikasi diatur oleh Tata Tertib. Anda dapat memfavoritkannya untuk digunakan pada chart

Inggin menggunakan skrip ini pada chart?


⭐️ 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
Juga di:

Pernyataan Penyangkalan