Watch how to download trading robots for free
Find us on Telegram!
Join our fan page
Interesting script?
So post a link to it -
let others appraise it
You liked the script? Try it in the MetaTrader 5 terminal
Experts

Dynamic Trailing Stop Loss and Profit Target Management - expert for MetaTrader 5

Views:
10228
Rating:
(18)
Published:
2023.04.27 18:03
Updated:
2023.05.19 07:58
test.mq5 (3 KB) view
Need a robot or indicator based on this code? Order it on Freelance Go to Freelance

This code is a risk management strategy for an Expert Advisor in MetaTrader that manages existing trades based on the input parameters. It focuses on closing trades when a profit or loss threshold is reached and employs a trailing stop loss to lock in profits as the trade moves in the trader's favor.

Here is a brief explanation of the code:

  1. Necessary header files are included for trade and symbol information classes.
  2. Input parameters are defined for risk percentage, profit percentage, and trailing stop points.
  3. Global variables are declared for trade and symbol information objects.
  4. The OnInit function initializes the symbol information object and checks for errors.
  5. The OnDeinit function does nothing in this case.
  6. The OnTick function is called every time a new tick is received, and it calls the CheckTrades function.
  7. The CheckTrades function iterates through all open positions and checks if the position belongs to the current symbol. If it does, it calculates the current profit and determines whether the profit or loss thresholds have been reached. If either threshold is reached, it closes the position.
  8. If neither threshold is reached, the code checks if the position type is a buy or sell order and updates the stop loss level with a trailing stop loss. If the new stop loss level is more favorable than the current stop loss level, the position is modified with the new stop loss level.

This code provides a simple risk management strategy to manage existing trades by adjusting the stop loss level dynamically based on a trailing stop loss and closing trades when profit or loss thresholds are reached.

Expert Advisor for Opening Multiple Buy and Sell Orders Based on User Input Expert Advisor for Opening Multiple Buy and Sell Orders Based on User Input

This MT5 Expert Advisor opens multiple buy and sell orders based on user input, featuring a simple interface with Buy and Sell buttons. The EA calculates lot size, checks the spread against slippage, and places orders accordingly. It is essential to test this EA in a demo account before using it in live trading.

VPS Trailing Stop Service VPS Trailing Stop Service

VPS Trailing Stop Service

Equity and Balance as an indicator for MT5 Equity and Balance as an indicator for MT5

This is a very easy-to-use indicator that displays the changes in Equity and balance of the trading account as it dynamically moves. Particularly useful on the back tester and good for beginners to read this very easy MQL5 code.

Martingale Levels For Money Management Martingale Levels For Money Management

To use martingale money management when a position is in loss and price hits any of specific distances.