Welcome Forex EA downloads & MT4/MT5 auto-trading resources — EAs, Gold EAs, quant tools and real-world automation.
Sign In Sign Up

XIT_BuySellAutoStoploss.mq4 - Setting stop loss based on fractal levels, money management risk/reward - MetaTrader 4 script

author EAcpu | 2 reads | 0 comments |

XIT_BuySellAutoStoploss.mq4 - Stoploss set from Fractal Levels, Money management Risk/Reward - script for MetaTrader 4

XIT_BuySellAutoStoploss.mq4 - Stoploss set from Fractal Levels, Money management Risk/Reward - script for MetaTrader 4

XIT_BuySellAutoStoploss.mq4 - Stoploss set from Fractal Levels, Money management Risk/Reward - script for MetaTrader 4

XIT_BuySellAutoStoploss.mq4 - Stoploss set from Fractal Levels, Money management Risk/Reward - script for MetaTrader 4

XIT_BuySellAutoStoploss.mq4 - Stoploss set from Fractal Levels, Money management Risk/Reward - script for MetaTrader 4

XIT_BuySellAutoStoploss.mq4 - Set stop loss based on fractal levels, money management risk/reward

My main goal with this script is to help increase my win rate by placing stops on the fractals with the best support. I kept using a fixed stop loss value and kept hitting the stop loss and within minutes the price was back in the right direction. This script really helped me find the nearest support/resistance levels, providing good stops.

Here are some of the features of this script, and how to use it for a basic run.

XIT_BuySellAutoStoploss.mq4 - Stoploss set from Fractal Levels, Money management Risk/Reward - script for MetaTrader 4

First, you must choose to buy or sell. If both are false, you will receive a message stating this and must restart the script. If both are true, the same error occurs.

XIT_BuySellAutoStoploss.mq4 - Stoploss set from Fractal Levels, Money management Risk/Reward - script for MetaTrader 4

The next thing to do is set your risk percentage, which is set to 2% by default.

The way I calculate the risk in this script is as follows:

Available Margin * Risk % = Risk Capital

(Risk Capital/StopLossPips) / (Leverage/Exchange Rate) = Trading Volume

This formula should give accurate risk/stop volume. For accounts with small deposits, you may end up risking more than your desired risk percentage. In this case, you will receive a message stating that your risk exceeds your risk percentage. You can choose to continue or not.

XIT_BuySellAutoStoploss.mq4 - Stoploss set from Fractal Levels, Money management Risk/Reward - script for MetaTrader 4

The bonus multiplier is pretty simple, basically if you want your take profit to be set to the same number of pips as your stop loss entry 1, then double the stop loss entry 2, etc...

StopAdd, simply adds x points to the fractal-based stop loss level.

MaxSlip, sets the maximum price slippage allowed when opening a trade.

MaxSpread, sets the maximum spread allowed.

Magic, the magic number that sets the transaction. 0 if none.

The next thing to do is to select the fractal level at which you want to stop your loss. It's a good idea to add a fractal indicator to your chart so you can see the levels more clearly. A message will appear asking you if you want to set your stop loss at 0.3434 etc... If the first stop loss is where you want it, click "No" and go to the next fractal and so on.

XIT_BuySellAutoStoploss.mq4 - Stoploss set from Fractal Levels, Money management Risk/Reward - script for MetaTrader 4

After clicking "Yes" the script will run as expected and open your order. If an error occurs, you should receive a message explaining what went wrong.

I hope this script helps some of you, if you have any issues with the script please let me know so I can fix any issues. Also, if there are any additions or modifications that would make this script better, please let me know.


Attachment download

📎 XIT_BuySellAutoStoploss.mq4 (9.76 KB)

Source: MQL5 #10075

Verification code Refresh