Posts

Showing posts from August, 2024

MQL5 Multi currency big boss big candle ea

 //+------------------------------------------------------------------+ //|                             BigBossCandleAtrCalMulticurrency.mq5 | //|                                  Copyright 2023, MetaQuotes Ltd. | //|                                             https://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "Copyright 2023, MetaQuotes Ltd." #property link      "https://www.mql5.com" #property version   "1.00" double ATR[]; #include <Trade\Trade.mqh> CTrade trade; datetime ExitTime; enum stmode   {    BUY=1,    SELL=2,    BOTH=3,   }; string stgmodes; input ENUM_TIMEFRAMES Time...

MQL5 : Add time to current time in mins

 datetime currentTime = TimeCurrent();  // Get the current time int minutesToAdd = 30;  // Example: Add 30 minutes // Add minutes to current time (converted to seconds) datetime newTime = currentTime + minutesToAdd * 60; // Output the new time Print("Current Time: ", TimeToString(currentTime, TIME_DATE | TIME_MINUTES)); Print("New Time: ", TimeToString(newTime, TIME_DATE | TIME_MINUTES));

MQL5 : Get running pnl

 mtm=AccountInfoDouble(ACCOUNT_PROFIT);   Get running pnl  by magin number for specific chart double GetPnLByMagicNumber(int magic_number)   {    double total_pnl = 0.0;    for(int i = 0; i < PositionsTotal(); i++)      {       ulong ticket = PositionGetTicket(i);       int position_magic = (int)PositionGetInteger(POSITION_MAGIC);       if(position_magic == magic_number)         {          total_pnl += PositionGetDouble(POSITION_PROFIT);         }      }    return total_pnl;   }

MQL5 : Calculate total pnl of today closed trades

 double Today_Closed_Profit()  {     MqlDateTime SDateTime;    TimeToStruct(TimeCurrent(),SDateTime);    SDateTime.hour=0;    SDateTime.min=0;    SDateTime.sec=0;    datetime  from_date=StructToTime(SDateTime);     // From date    SDateTime.hour=23;    SDateTime.min=59;    SDateTime.sec=59;    datetime  to_date=StructToTime(SDateTime);     // To date    to_date+=60*60*24;    HistorySelect(from_date,to_date);    int trades_of_day=0;    double wining_trade=0.0;    double losing_trade=0.0;    double total_profit=0.0;    uint total=HistoryDealsTotal();    ulong    ticket=0; //--- for all deals    for(uint i=0; i<total; i++)      {       //--- try to get deals ticket       if((ticket=HistoryDea...