//+------------------------------------------------------------------+ //| orderstotal.mq5 | //| Copyright 2025, MetaQuotes Ltd. | //| https://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "Copyright 2025, MetaQuotes Ltd." #property link "https://www.mql5.com" #property version "1.00" #include #include string label_name = "BigTextLabel"; int highest_magic = 1; double lowestValue=0; //+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- if(!ObjectCreate(0, label_name, OBJ_LABEL, 0, 0, 0)) { Print("Failed to create label"); } // Set label properties ObjectSetInteger(0, label_name, OBJPROP_CORNER, CORNER_LEFT_UPPER); ObjectSetInteger(0, label_name, OBJPROP_XDISTANCE, 20); ObjectSetInteger(0, label_name, OBJPROP_YDISTANCE, 20); ObjectSetInteger(0, label_name, OBJPROP_FONTSIZE, 24); // Big font size ObjectSetInteger(0, label_name, OBJPROP_COLOR, clrRed); ObjectSetString(0, label_name, OBJPROP_TEXT, "Initial Text"); //--- return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Expert deinitialization function | //+------------------------------------------------------------------+ void OnDeinit(const int reason) { //--- // Create the label ObjectDelete(0, label_name); } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void OnTick() { //--- static datetime dtBarCurrent = WRONG_VALUE; datetime dtBarPrevious = dtBarCurrent; static datetime dtBarCurrent1 = WRONG_VALUE; datetime dtBarPrevious1 = dtBarCurrent1; dtBarCurrent1 = iTime(_Symbol, PERIOD_M1, 0); dtBarCurrent = iTime(_Symbol, PERIOD_M1, 0); bool bNewBarEvent = (dtBarCurrent != dtBarPrevious); bool bNewBarEvent1 = (dtBarCurrent1 != dtBarPrevious1); if(bNewBarEvent) { // Detect if this is the first tick received and handle it. /* For example, when it is first attached to a chart and the bar is somewhere in the middle of its progress and it's not actually the start of a new bar. */ if(dtBarPrevious == WRONG_VALUE) { // Do something on first tick or middle of bar ... } else { int totalOrders=PositionsTotal(); int total_positions = PositionsTotal(); if(total_positions > highest_magic) highest_magic = total_positions; string new_text = TimeToString(TimeCurrent(), TIME_SECONDS); ObjectSetString(0, label_name, OBJPROP_TEXT, "Updated: " + totalOrders+ " " +highest_magic+ " "+lowestEquity()); } } } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ double GetAverageSpread() { int candlesToCheck = 300; MqlRates priceData[]; if(CopyRates(Symbol(), PERIOD_M10, 0, candlesToCheck, priceData) <= 0) { Print("❌ Failed to retrieve price data."); return 160; } double totalSpread = 0; double pointSize = SymbolInfoDouble(Symbol(), SYMBOL_POINT); for(int i = 0; i < candlesToCheck; i++) { double spread = priceData[i].spread; totalSpread += spread; } double averageSpread = totalSpread / candlesToCheck; return averageSpread; } double GetMaxSpread() { int candlesToCheck = 300; MqlRates priceData[]; if(CopyRates(Symbol(), PERIOD_M10, 0, candlesToCheck, priceData) <= 0) { Print("❌ Failed to retrieve price data."); return 160; } double totalSpread = 0; double pointSize = SymbolInfoDouble(Symbol(), SYMBOL_POINT); for(int i = 0; i < candlesToCheck; i++) { double spread = priceData[i].spread; if (spread>totalSpread) totalSpread=spread; } double averageSpread = totalSpread; return averageSpread; } //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ double lowestEquity(){ double equity = AccountInfoDouble(ACCOUNT_PROFIT); double margin = AccountInfoDouble(ACCOUNT_MARGIN); double netValue = equity - margin; if (netValue