MQL5

1 program Added 2025-10-29T11:01:38Z Model: google/gemini-2.5-proTemp: 0.4 Evidence Report issue View issues
Aliases: MetaQuotes Language 5
Provenance: commit dab3410a84 · authored 2025-10-29T12:01:38+01:00 · model google/gemini-2.5-pro

Sources mentioning this language

4 sources · pl_id: pl/mql5
LLM (this repo) · 1LinguistPygmentsHyperpolyglot

Extensions claimed by this language

5 claims. Each row is one upstream assertion with its strength. SWH column shows file occurrences with that extension across the entire archive.
ExtensionSourceStrengthSWH
.mq4pygmentsprimary71.6K files
.mq5linguistprimary27.2K files
.mq5pygmentssecondary27.2K files
.mqhlinguistsecondary80.6K files
.mqhpygmentssecondary80.6K files

Related languages

MQL (0.74)MQL4 (0.65)ML (0.35)SL5 (0.31)Metal (0.27)

LLM-contributed programs

Close Positions on Total Profit

Provenance: commit dab3410a84 · authored 2025-10-29T12:01:38+01:00 · model google/gemini-2.5-pro · Temp 0.4
code.mq5 · added: 2025-10-29T11:01:38Z
//+------------------------------------------------------------------+
//|                                     CloseOnTotalProfit_Sample.mq5|
//|                        Copyright 2009, MetaQuotes Software Corp. |
//|                                              https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2009, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
/*
 A simple EA that closes all positions when the total profit reaches a certain level
*/
//--- input parameters
input double ProfitLevel=10.0; // Profit level to close all positions
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---
   double total_profit=0;
   //--- go through all open positions
   for(int i=PositionsTotal()-1;i>=0;i--)
     {
      //--- get position properties
      ulong  position_ticket=PositionGetTicket(i);
      string position_symbol=PositionGetString(POSITION_SYMBOL);
      long   magic=PositionGetInteger(POSITION_MAGIC);
      double volume=PositionGetDouble(POSITION_VOLUME);
      double price_open=PositionGetDouble(POSITION_PRICE_OPEN);
      double price_current=PositionGetDouble(POSITION_PRICE_CURRENT);
      long   type=PositionGetInteger(POSITION_TYPE);
      double profit=PositionGetDouble(POSITION_PROFIT);
      //--- calculate total profit
      total_profit+=profit;
     }
   //--- check the total profit
   if(total_profit>=ProfitLevel)
     {
      //--- close all positions
      for(int i=PositionsTotal()-1;i>=0;i--)
        {
         //--- get position ticket
         ulong  position_ticket=PositionGetTicket(i);
         //--- create trade request
         MqlTradeRequest request;
         MqlTradeResult  result;
         //---
         request.action=TRADE_ACTION_DEAL;
         request.position=position_ticket;
         //--- send order
         OrderSend(request,result);
        }
     }
  }
//+------------------------------------------------------------------+

Real programs from Software Heritage

No SWH evidence indexed yet for this language. (Either the SWH mining hasn't reached this language's extensions, or no matching files exist in the archive.)

Contribute — propose a file extension

Tell us where to find evidence about MQL5 (mapped to pl/mql5). A reference URL is required; at least one of extension or program code must be provided too. A maintainer reviews each submission via a draft PR before anything lands.
Optional: attach a program from that URL
If the reference URL points at a single source file you'd like to add as an example program, paste it below. The workflow will write it under languages/MQL5/programs/<sha>/. Keep under ~200 lines.
(or open the pre-filled issue directly)
← MQL4 MQSC →