
The famous Moving Average Convergence Divergence (MACD) Strategy is modified to be compatible with PineConnector to enable trading automation. We added a 20-period Exponential Moving Average (EMA20) to the trend-following strategy to filter out counter-trend positions. The MACD strategy can be used for forex trading, stock trading, futures trading, crypto trading and trading of other instruments – also, ideal if you are day trading or swing trading.
Updated 6 October 2026: the alerts now use explicit volume (vol_pct_bal_loss=) with a stop-loss (sl_pips=), replacing the older risk= parameter.
Nevertheless, we recommend that paper trading should be done first, before running on your live trading accounts.
After setting up this MACD crossover pine script,
- an alert will automatically trigger when conditions are met (as per the blue PineConnector arrows)
- the PineConnector EA will process the alert message
- the appropriate order or action will be executed automatically on your MT4/5 terminal
Looking to automate your trading?
PineConnector is a user-friendly bridge that enables retail traders to auto-execute TradingView alerts on MT4 & MT5 without fancy coding. Try Core for 7 days for $7, hosted MT5 included → After the trial, Core is $59/month unless you cancel.
Create a PineScript and attach the code below
|
|
| Edit the highlighted portion of the code to your preassigned ID found in the PineConnector members area (e.g. 60123456789) |
|
| Save the code, and click "Add to Chart" | |
|
Guide to create alerts: Create alerts
|
| Volume: set in the alert ● The alert sends vol_pct_bal_loss=1 with sl_pips=20. With a $1,000 balance, the EA sizes the trade so that a stop-loss hit loses about 1%, or $10. Gaps, slippage and broker volume rounding can make the actual loss differ.● Change the risk and the stop-loss distance in the indicator's settings. The 20-pip default is an example, not a recommendation; choose a stop that suits the instrument you trade. See the syntax guide for the other volume methods. |
|
| Close on Reverse: On ● When a sell signal arrives, an open buy position is closed first and then the sell opens, and vice versa. ● On PineConnector Edge, set it in Portal → Edge → EA Settings, under General. |
