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
Views:
84
Rating:
(2)
Published:
MQL5 Freelance Need a robot or indicator based on this code? Order it on Freelance Go to Freelance


Close_Orders - Universal function for closing positions and deleting orders

Brief description

One function for 14 trade management tasks in MetaTrader 5.

Closes positions and deletes pending orders with filtering by type, profitability and magic number.

What it can do

For positions (9 options):

  • All positions / only profitable / only losing positions

  • BUY only / SELL only

  • BUY profitable / BUY unprofitable

  • SELL profitable / SELL losing

For pending orders (5 options):

  • All pending orders / only Buy Stop / only Buy Limit

  • Only Sell Stop / only Sell Limit

How to use

// Call Examples:
Close_Orders("Position", "All", 0);           // All positions
Close_Orders("Position", "Buy Profit", 123);  // Profitable BUY with magik 123
Close_Orders("Order", "Buy Stop", 0);         // All Buy Stop orders

Parameters:

  • p_o : " Position" or "Order" .

  • type_po : Filter type (see options above)

  • magicNumber : Magic (0 = all)

Advantages

  • Simplicity - one call instead of 14 functions

  • Flexibility - fine filtering of trades

  • Safety - proper handling of loops

  • Versatility - for Expert Advisors, scripts, indicators

Technical features

  • deviation = 5 - optimal price tolerance

  • Iteration from the end - safe deletion

  • Local variables - query isolation

Inclusion in project

#include <Close_Orders.mqh>
// Ready to use!

Translated from Russian by MetaQuotes Ltd.
Original code: https://www.mql5.com/ru/code/68469

ICE (Impulse Confirmation Engine) ICE (Impulse Confirmation Engine)

ICE Pro v1.0: Momentum Intelligence System. ICE bukan sekadar EA (Expert Advisor) berbasis indikator statis. Ini adalah mesin Adaptive Trading yang menggunakan volatilitas (ATR) dan profil volume sebagai filter utama untuk menyaring mana pergerakan harga yang merupakan "Impuls Sejati" dan mana yang hanya "Market Noise".

WPR for Overbought and Oversold WPR for Overbought and Oversold

Overbought and oversold indicators aim to determine where the price may experience a reversal.

Fractal Maturity Oscillator FMO Fractal Maturity Oscillator FMO

The FMO indicator is a technical analysis tool that measures "trend age" using fractal cycles. Its purpose is to help traders determine whether a trend is still young (safe to follow) or over-aged (high risk). A Conceptual Synthesis of Psychology, Sociology, and Life Cycles This work presents a deep analysis of human life through a numerical matrix (3, 7, 39, 49), using it as a conceptual lens for understanding psychology, sociology, and developmental cycles. It is not a conventional scientific framework. Rather, it is a synthesized model — integrating esoteric, psychological, and sociological perspectives into a unified cyclical structure. The goal is to organize and interpret human development through layered, interacting cycles.

MASTER-WINNERFX-Asim MASTER-WINNERFX-Asim

Trend based grid Expert Advisor for MetaTrader 5 using EMA and RSI indicators. Dynamic lot size is calculated from account balance with minimum and maximum lot protection. Initial trade opens when price confirms trend direction relative to EMA and RSI levels. Grid orders are added at fixed point distance using controlled multiplier. All trades are managed as a basket and closed at defined profit target or maximum loss level. Includes optional news hour pause and market close filter. No DLL or external services required.