On this blog I'll explain how the "MACD ALL" EA works so you can take advantage of its features.
BASIC FUNCTIONALITY:
The EA works using a "signal"; this "signal" is the cross of the MACD and the signal line of the MACD indicator (you can choose the MACD indicator settings). When the macd crosses below the signal line, then it is a "sell signal"; when the macd crosses above the signal line, it is a "buy signal" (this is calculated when the bar closes).
It's the same indicator as the default MACD on MT5; just the macd is represented as a blue line instead of a histogram.
YOU CAN APPLY FILTERS TO THE "SIGNAL":
(inputs)
Use ema as trend filter(default = true): This is a simple trend filter; it only confirms the signal if the price is above the EMA for a "buy signal" and below the EMA for a "sell signal." (uses a 200-period EMA by default, but you can change it)
Without ema Filter
With ema Filter
Use atr as filter(default = true): The filter checks if the candle on which the signal is generated is too big so the desired price move already occurred; to check this, the EA uses the ATR to compare. (uses a 20-period ATR by default, but you can change it)
Without ATR Filter
With ATR Filter
Only crossover below 0 line and Only crossunder above 0 line(default = true): This filter checks if the cross of the MACD and the signal line occurs above the 0 line for a "sell signal" and below the 0 line for a "buy signal".
Without 0 line Filter
With 0 line Filter
Hours filter(default = false): Checks if the signal is generated in the specify hours.
MAKING TRADES:
You can use the EA as an indicator without autotrade; there are two inputs:
"Activate alert on signal" (default = false): As the name says, this allows the EA to send an alert whenever a "signal" is detected; you can use this if you want to manually trade using your own analysis.
"Activate arrow printing on signal" (default = false): This input allows the EA to print arrows whenever a "signal" is detected; you can see this working on the screenshots above showing the printed arrows.
You can activate autotrading using the input "Activate trading on signal" (default = true). When it's activated, the EA will enter trades on "buy signal" or "sell signal." The EA has different options on risk, stop-loss placement, take-profit placement, and trailing stop-loss.
RISK SETTINGS:
(inputs)
Risk type (default = Equity percentage): The EA can use 3 different risk types.
Equity percentage: Using this type of risk, the EA will calculate the correct lot size to risk the chosen percentage of the account equity at the moment the trade is opened; for example, if you choose a 1% risk, and at the moment the EA makes a trade, the account has an equity of $10,000, the risk on the trade will be $100. (You can choose the percentage at risk on the input "Risk percentage" [default = 0.5%]).
Fixed lot size: As the name indicates, using this type of risk, the EA will make trades using the chosen lot size on every trade. (You can choose the desired lot size on the input "Lot Size" [default = 1.0]).
Fixed amount in money: Using this type, the EA will risk the same amount of money on every trade. (You can choose the desired money at risk on the input "Risk Amount" [default = 100]).
STOPLOSS SETTINGS:
(inputs)
Stop Loss type (default = Pivot): The EA can use 4 different stop loss types.
Pivot: This stoploss uses the lowest or highest, pivot of the last bars. to calculate the pivot the EA uses the inputs "pivot length" and "lookback for pivot". pivot length refears to how many candles has to be below in case of a high pivot or above in case of a low pivot at the right and the left of the pivot candle. and the lookback is how many candles before the entry the EA will try to find a pivot for example if the lookback is 5 then the EA will analize the last 5 candles looking for a pivot.
How pivot works:
Fixed points: Using this, the stop loss will be of the desired size in points using the formula STOPLOSS = ENTRY - POINTS * POINTSIZE (in case of buy, if sell the - is +). For example, if you use 100 points on a buy trade on the US500 with entry = 3850.4 and in this case the point size for the US500 is 0.01, the stop loss will be 3850.4 - 100 * 0.01 = 3849.4. (You can choose the desired points on the input "SL points" [default = 100]).
Percentage of price: Place the stop loss using the percentage of price using the formula STOPLOSS = ENTRY - (PERCENTAGE/100 * ENTRY) (in case of buy, if sell the - is +) ; for example, if you use a 1% stop loss on a buy trade on the US100 with entry = 15000, the stop loss will be 15000 with a 1% decrease, so 15000 - (1/100 * 15000) = 14850. (You can choose the desired percentage on the input "SL percentage" [default = 1.0]).
ATR: It uses the atr value and multiplies it by a chosen factor, the result is subtracted of the open price if buy trade or added in case of a sell trade using the formula STOPLOSS = ENTRY - ATR * FACTOR (in case of buy, if sell the - is +), for example using a factor of 1.5 on a buy trade on US500 with entry = 3800 and ATR = 27 the stop loss will be 3800 - 27 * 1.5 = 3759.5. (You can choose the desired factor on the input "ATR factor for SL" [default = 1.2]).
Same trade different SL:
TAKE PROFIT SETTINGS:
(inputs)
TP type (default = By ratio): The EA can use 3 different take profit types.
By ratio: It takes the SL distance and multiplies it by a desired ratio, which is the typical risk-reward ratio (RR). You have to choose the ratio using the input "TP ratio" (default = 1); a "TP ratio" of 1 means a 1 to 1 RR (if you risk 100, you win 100), and 2 means a 1 to 2 RR (if you risk 100, you win 200). So the formula to calculate the TP placement for a buy: TAKEPROFIT = ENTRY + (ENTRY - SL) * RATIO for a sell: TAKEPROFIT = ENTRY - (SL - ENTRY) * RATIO. For example, on a buy trade on US100 with entry = 15000, stop loss = 14500, and a "tp ratio" of 2.5, the take profit will be 15000 + (15000 - 14500) * 2.5 = 16250.
By points: Is the same as the "Fixed points" Stoploss, but for the take profit, so it place a take profit of the desired size in points using the formula TAKEPROFIT= ENTRY + POINTS * POINTSIZE (in case of buy, if sell the + is -). For example if you use a 100 points take profit on a buy trade on US500 with entry = 4256.3 and in this case the point size for the US500 is 0.01, the take profit will be 4256.3 + 100 * 0.01 = 4257.3. (You can choose the desired points on the input "TP points" [default = 100]).
No TP: As the name indicates, it means the trade opens without take profit; this option exists in case you want to use the trailing stop-loss feature and leave the trade open until it hits the trailing stop-loss.
TRAILING STOPLOSS FEATURE:
The EA has the option of using a trailing stop loss; this trailing stop loss uses the same logic as the normal stop loss, so the trailing stop loss types are the same as the normal stop loss type but use separate inputs, and the trailing stop is calculated on every tick and starts working once the trailing stop is in profit.
PROMISING RESULTS:
When I was developing the EA and playing with the settings I encountered some profitable setups that look promising, on the US100 symbol and the US500 symbol, both using the 4H timeframe.
US100 4H timeframe 1% equity risk 2016-2024 80% growth 15% max DD (using real tick data)
This is with a 1% equity risk per trade; with a 2.5% risk per trade, it reaches a 378% growth with a 35% max DD, matching the same max DD you would have got if you bought and held the US100 in the same period of time but almost doubling the growth.
US500 4H timeframe 2.5% equity risk 2022-2024 64% growth 7.9% max DD (using real tick data)
The same case as before, you can change the risk to obtain different results.
These are the set files with the settings used on US100 and US500.
Keep in mind that these results were obtained without optimization, so you can probably find a better setup by changing some things and optimizing the settings.