Voir comment télécharger gratuitement des robots de trading
Retrouvez-nous sur Twitter !
Rejoignez notre page de fans
Un script intéressant ?
Poster un lien vers celui-ci -
laisser les autres l'évaluer
Vous avez aimé le script ? Essayez-le dans le terminal MetaTrader 5
Scripts

SetSLByLoss — set Stop Loss on all open positions by target loss amount - script pour MetaTrader 5

Vues:
949
Note:
(1)
Publié:
MQL5 Freelance Besoin d'un robot ou d'un indicateur basé sur ce code ? Commandez-le sur Freelance Aller sur Freelance

Script that sets a Stop Loss on every open position based on a target loss amount expressed in the account's currency (e.g. $50 per position). Works for any deposit currency (USD, AUD, EUR, NZD, etc.) and any forex symbol - currency conversion is handled automatically via SYMBOL_TRADE_TICK_VALUE_LOSS. Validates broker stops/freeze levels before submitting changes, skips positions whose SL is already correct, and reports clear reasons for any positions that cannot be modified. The target loss is set in an input parameter: Maximum loss (amount in account currency) for each position.




LOGIC


  • For each open position, calculates the SL price such that if hit, the loss equals approximately InpTargetLossAmount (in the account's currency). 

  • Validates against stops level and freeze level before submitting modifications.

  • Skips positions that already have a correct SL (within 1 tick of the target).

  • Skips positions whose price has moved so far that placing the SL would violate broker constraints, logging the reason. 


TickValue_Compare — diagnose differences between TICK_VALUE, LOSS and PROFIT TickValue_Compare — diagnose differences between TICK_VALUE, LOSS and PROFIT

Diagnostic script that compares SYMBOL_TRADE_TICK_VALUE, SYMBOL_TRADE_TICK_VALUE_LOSS and SYMBOL_TRADE_TICK_VALUE_PROFIT for every symbol in Market Watch. Classifies each symbol into one of four categories (ALL_EQUAL, TV_MATCHES_PROFIT, TV_MATCHES_LOSS, ALL_DIFFER) and provides an aggregated summary plus interpretation tip. Useful for verifying which tick-value property to rely on when implementing risk-based lot sizing in EAs. Exports full per-symbol report to CSV in MQL5/Files.

Heiken ashi as series Heiken ashi as series

Heiken ashi with all buffers set as series

Gold Spread ATR Trend Panel MT5 Gold Spread ATR Trend Panel MT5

Educational MT5 chart panel for XAUUSD showing live spread, ATR volatility, EMA trend bias, RSI condition, daily range and active trading session.

XAUUSD Spread Alert Utility MT5 XAUUSD Spread Alert Utility MT5

Educational MT5 chart utility that monitors XAUUSD spread on the chart and alerts when spread rises above user-defined warning or danger levels.