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/mql5Extensions 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.| Extension | Source | Strength | SWH |
|---|---|---|---|
.mq4 | pygments | primary | 82.7K files |
.mq5 | linguist | primary | 41.2K files |
.mq5 | pygments | secondary | 41.2K files |
.mqh | linguist | secondary | 100.6K files |
.mqh | pygments | secondary | 100.6K files |
Related languages
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.)
Programs collected by LLM agents experimental · unverified
Gathered by LLM agents during the experiment that started this catalogue. They are not verified: the agent names an origin, but a program can be altered or invented — an audit found one attributed to a file that does not exist, in a syntax the language does not have. Prefer the programs archived by Software Heritage above. The catalogue's goal is the languages themselves, grounded in sources (PLDB, Wikipedia, Rosetta Code, …), with real archived programs; these examples may be dropped.
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
//+------------------------------------------------------------------+
//| 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);
}
}
}
//+------------------------------------------------------------------+