New MetaTrader 5 platform build 4755: General improvements - page 7

 
@Carl Schreiber #The function fails, but neither sets _LastError nor does GetLastError() return an error number.

The function did not fail. It returned false. There is a diference and I even highlighted it in the quoted documentation.

As I already explained, the GetLastError is only for when the function itself fails, not the trade request verification, which is returned in the in the MqlTradeCheckResult object, not GetLastError.

 

Just look at the MQ example here: https://www.mql5.com/en/docs/trading/ordercheck

//--- check trade request parameters
   ResetLastError();
   bool res=OrderCheck(request, check);
   if(!res)
     {
      PrintFormat("Trade request verification completed with error %d\nServer retcode: %u, comment: %s", GetLastError(), check.retcode, check.comment);
      return;
     }

If OrderCheck fails or as you more precise say "returns false" GetLastError() ist logged "Print( .., GetLastError(), ... );" but it is not set. Sure it's bug - of course not a serious one.

Documentation on MQL5: Trade Functions / OrderCheck
Documentation on MQL5: Trade Functions / OrderCheck
  • www.mql5.com
The OrderCheck() function checks if there are enough money to execute a required trade operation . The check results are placed to the fields of...
 
@Carl Schreiber #: If OrderCheck fails or as you more precise say "returns false" GetLastError() ist logged "Print( .., GetLastError(), ... );" but it is not set. Sure it's bug - of course not a serious one.

Yes, and in that very example you seem to be ignoring the other output to the log, namely "check.retcode" ...

PrintFormat("Trade request verification completed with error %d\nServer retcode: %u, comment: %s", GetLastError(), check.retcode, check.comment);
 
Fernando Carreiro #:

Yes, and in that very example you seem to be ignoring the other output to the log, namely "check.retcode" ...

But in the debugger _LastError - if it would be set correctly and if this variable would be available and recognised in the debugger - should show the error generally for everything that has happened, in the past it was that way! So you need(ed) only this, _LastError, instead of a lot of different fields of structures and classes which would flood the variable window of the debugger.

 

I noticed the OnChartEvent on Tester works for indicators now.

Unless it was always this way 

 
Lorentzos Roussos #:

I noticed the OnChartEvent on Tester works for indicators now.

Unless it was always this way 

Always been.
 

Hello Dear,

I would like to share the following image


indicator not inidicator.png


Also, I attached the file.


Thanks!

 

Hello Metatrader tech team, 

Im really really want you to enhance the settings for subcribing signals, that is allow to copy signals with fixed lot. PLEASE PLEASE.


as current settings, there are no where to set fixed lot.

Thanks much, please help me to do it soon. Regards.

Trading signals for MetaTrader 5
Trading signals for MetaTrader 5
  • www.mql5.com
A showcase of successful trading strategies with automated copy trading
 

Just found something related -

Forum on trading, automated trading systems and testing of trading strategies

New MetaTrader 5 platform version build 4755: general improvements

Renat Fatkhullin , 2025.03.01 12:43

We are changing the GUI and controls, including a dark theme.

This is the first beta for now.


 

Hello MQL5 Community,

I'm encountering a persistent and perplexing issue where ArraySetAsSeries() does not seem to correctly set the time series flag for dynamic arrays used as indicator buffers within the OnInit() function. This occurs even in a minimal, standalone test indicator.

Environment:

  • MetaTrader 5 Version: 5.00 build 4885 (64-bit)

  • Build Date: 28 Feb 2025

Problem Description:
When an indicator buffer is mapped using SetIndexBuffer() and then ArraySetAsSeries(buffer, true) is called immediately afterward within OnInit(), a subsequent check using ArrayIsSeries(buffer) in the same OnInit() scope (and later in OnCalculate()) consistently returns false.

This means that functions in OnCalculate() which expect these buffers to be time series (e.g., standard indicator calculation routines like ATR, RSI) then fail or produce incorrect results because they detect the buffer is not a series array.

Minimal Reproducible Test Case (TestSeriesIndicator.mq5):

#property copyright "Minimal Series Test v2"
#property link      ""
#property version   "1.0"
#property strict

#property indicator_chart_window
#property indicator_buffers 1
#property indicator_plots   1

// Plot Properties for buffer 0
#property indicator_type1   DRAW_LINE
#property indicator_color1  clrDodgerBlue
#property indicator_style1  STYLE_SOLID
#property indicator_width1  1
#property indicator_label1  "TestBufferLine0"

// Global variable for the buffer
double g_testBuffer[];

// Global flag for debug prints
bool g_EnableDebugPrints_Test = true;

//+------------------------------------------------------------------+
int OnInit()
{
    if(g_EnableDebugPrints_Test) Print("TestSeriesIndicator v2: OnInit Start.");

    IndicatorSetInteger(INDICATOR_DIGITS, _Digits);
    IndicatorSetString(INDICATOR_SHORTNAME, "TestSeriesInd_v2");

    if(g_EnableDebugPrints_Test) Print("TestSeriesIndicator v2: BEFORE SetIndexBuffer for g_testBuffer (index 0). Is series? ", ArrayIsSeries(g_testBuffer));
    SetIndexBuffer(0, g_testBuffer, INDICATOR_DATA);
    if(g_EnableDebugPrints_Test) Print("TestSeriesIndicator v2: AFTER SetIndexBuffer for g_testBuffer (index 0). Is series? ", ArrayIsSeries(g_testBuffer));

    ArraySetAsSeries(g_testBuffer, true);
    if(g_EnableDebugPrints_Test) Print("TestSeriesIndicator v2: AFTER ArraySetAsSeries for g_testBuffer (index 0). Is series? ", ArrayIsSeries(g_testBuffer)); // <<< CRITICAL EXPECTATION: true

    PlotIndexSetString(0, PLOT_LABEL, "TestBuffer Plot 0");
    PlotIndexSetDouble(0, PLOT_EMPTY_VALUE, EMPTY_VALUE);
    PlotIndexSetInteger(0, PLOT_DRAW_BEGIN, 1);

    if(g_EnableDebugPrints_Test) Print("TestSeriesIndicator v2: OnInit End. Final status of g_testBuffer (index 0). Is series? ", ArrayIsSeries(g_testBuffer));
    if(g_EnableDebugPrints_Test) Print("!!!!!!!!!! MINIMAL ONINIT V2 COMPLETED (TestSeriesIndicator) !!!!!!!!!!");
    return INIT_SUCCEEDED;
}

//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
{
    ArraySetAsSeries(time, true); // Standard practice
    ArraySetAsSeries(open, true);
    ArraySetAsSeries(high, true);
    ArraySetAsSeries(low, true);
    ArraySetAsSeries(close, true);

    static int calc_count = 0;
    if (g_EnableDebugPrints_Test && calc_count < 3) { // Log only a few times
        Print("TestSeriesIndicator v2: OnCalculate (call #", calc_count, "): Start. g_testBuffer is series? ", ArrayIsSeries(g_testBuffer));
    }

    if (rates_total > 0 && ArrayIsSeries(g_testBuffer) && ArraySize(g_testBuffer) >= rates_total) {
        int limit = (prev_calculated == 0) ? rates_total - 1 : rates_total - prev_calculated -1;
             if(limit <0) limit =0;

        for (int i = limit; i >= 0; i--) {
            if (i < ArraySize(g_testBuffer)) g_testBuffer[i] = close[i];
        }
    } else if (g_EnableDebugPrints_Test && calc_count < 3) {
         Print("TestSeriesIndicator v2: OnCalculate: SKIPPING g_testBuffer assignment because it's NOT series.");
    }
    calc_count++;
    return(rates_total);
}

//+------------------------------------------------------------------+
void OnDeinit(const int reason) {}
//+------------------------------------------------------------------+

Log Output from TestSeriesIndicator.mq5:

TestSeriesIndicator v2: OnInit Start.
TestSeriesIndicator v2: BEFORE SetIndexBuffer for g_testBuffer (index 0). Is series? false
TestSeriesIndicator v2: AFTER SetIndexBuffer for g_testBuffer (index 0). Is series? false
TestSeriesIndicator v2: AFTER ArraySetAsSeries for g_testBuffer (index 0). Is series? false  <-- PROBLEM HERE
TestSeriesIndicator v2: OnInit End. Final status of g_testBuffer (index 0). Is series? false
!!!!!!!!!! MINIMAL ONINIT V2 COMPLETED (TestSeriesIndicator) !!!!!!!!!!
TestSeriesIndicator v2: OnCalculate (call #0): Start. g_testBuffer is series? false
TestSeriesIndicator v2: OnCalculate: SKIPPING g_testBuffer assignment because it's NOT series.

Troubleshooting Steps Taken:

  • Ensured ArraySetAsSeries() is called after SetIndexBuffer().

  • Performed clean recompiles (deleting .ex5 file) and restarted MetaTrader 5 multiple times.

  • Tested with a completely new, minimal indicator file (code above).

  • Confirmed that other standard indicators (like the included iVAR.mq5 if recompiled on this build) that use similar buffer initialization seem to work, making this specific failure puzzling.

  • The issue persists even after trying a "Data Folder Reset" (renaming the terminal instance folder to let MT5 create a fresh one, then creating and compiling the test indicator from scratch in the new environment).

  • Tried installing a fresh copy of MT5 from MetaQuotes official website, created the minimal test indicator from scratch, and the issue still occurs.

Expected Behavior:
The log line TestSeriesIndicator v2: AFTER ArraySetAsSeries for g_testBuffer (index 0). Is series? should show true. Consequently, ArrayIsSeries(g_testBuffer) in OnCalculate() should also be true.

Question:
Has anyone encountered a similar issue with ArraySetAsSeries() failing to set the series flag for indicator buffers in OnInit() on MT5 build 4885 or similar recent builds? Could this be a bug specific to this build or certain system configurations, or is there a subtle aspect of indicator buffer initialization I might be missing that's not apparent in standard examples or documentation?

Any insights or suggestions would be greatly appreciated.

Thank you.