TradingView
Trading_Nerd
27 mar 2022 09:38

MACD Strategy [Trading Nerd] 

BTC Perpetual Futures ContractBinance

Descrizione

This Strategy uses a EMA as a trend filter and MACD for entries. The stoploss can be calculated by the last highs/lows or by the ATR.

Entry Conditions
Long:
  • close price must be above the EMA
  • MACD-Line crossover MACD-Signal-Line
  • MACD-Signal- Line mus be below 0


Short:
  • close price must be below the EMA
  • MACD-Line crossunder MACD-Signal-Line
  • MACD-Signal- Line mus be above 0


Exit Conditions
The Stoploss can be set in two different ways:
1. By the calculated ATR value of the entry Candle. This Value can be multiplied with the ATR multiplier for SL.
For Longs: SL = entry Price - ATR * ATR-multiplier
For Shorts: SL = entry Price + ATR * ATR-multiplier

2. By the previous highest high or lowest low (also called Donchain Channels). The lookback length can be changed in the at Lookback length for HH/LL SL.
For Longs: SL = LL of the last X candles
For Shorts: SL = HH of the last X candles

Take Profit
The TP is calculated by the Risk * Risk Reward Ratio. The Risk Reward Ratio can be changed in the Settings. The Risk is the difference of entry price and stoploss price: Risk = absolute(entry price - stoploss price)
For Longs: TP = entry Price + Risk * Risk Reward Ratio.
For Shorts: TP = entry Price - Risk * Risk Reward Ratio.

Risk Management
You can set the Risk % per Trade in the settings. A Value of 2 means that the position size is calculated in a way that at a loosing trade the strategy will only loose 2% of the current capital (initial capital + net profit).
E.g.: The current capital is $1000 and a trade hits the SL. The strategy will only loose $20.


Info for Alerts: Alert message conversion of JSON Strings. You don't need to add any \n or \" to the alert String.
When you create the Alert the Message must be: {{strategy.order.alert_message}}

Note di rilascio

General:
- added option to select/unselect Strategy Conditions (Signal Line above/below Threshold, EMA Trend Filter)

Range Filter:
- added ADX Range Filter to filter flat markets

Take Profit:
- added option to Exit a Trade based on a returning MACD-cross (instead of Risk Reward Ratio)
- added optional partial Take Profit

Stop Loss:
- added optional Stop Loss Limit to cap a Stop Loss by a fixed percent

Backtesting:
- added option to unselect compound interest
- added Session and Weekday Filter

Note di rilascio

  • added Trailing Stop Loss Option
  • added Option to Move Stop Loss to Breakeven
  • added 'ATR Stop Loss - Entry Candle Source' variable
Commenti
WilliamSanchez
Hi, would I be able to get the source code for this strategy?
Trading_Nerd
@WilliamSanchez, Its available on my website. (Link is on my TradingView Profile)
Wri65
Hi, thank you very much for this indicator, I found it very helpful and do like the latest update, the ADX seems to make a large difference to the results. One thing I have found though is there are some trades that don't match the strategy and are either entering a long position when the MACD is above 0 or shorting when the MACD is below 0, EURCAD, EUR NZD & AUDUSD this morning Australian time are some that are outside the parameters. I have the EMA filter on which I believe should hold to the original strategy.
It seems it might be allowing long/short if the signal line is above or below the MACD line instead of the 0 line, I don't know enough about Pine to find it. Thanks
Trading_Nerd
@Wri65, sorry. I struggle to reproduce that potential error. Maybe you can name an exact trade with the script settings.
naturenoodle
Can u add enter and exit alert in the alert choice? that will be wonderful~
PhillipKam
Thank you very much!
rossguillermo
Thank you!
Altro