@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.
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.
@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" ...
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'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_buffers1#property indicator_plots1// Plot Properties for buffer 0#property indicator_type1DRAW_LINE#property indicator_color1clrDodgerBlue#property indicator_style1STYLE_SOLID#property indicator_width11#property indicator_label1"TestBufferLine0"// Global variable for the bufferdouble g_testBuffer[];
// Global flag for debug printsbool g_EnableDebugPrints_Test = true;
//+------------------------------------------------------------------+intOnInit()
{
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: truePlotIndexSetString(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) !!!!!!!!!!");
returnINIT_SUCCEEDED;
}
//+------------------------------------------------------------------+intOnCalculate(constint rates_total,
constint prev_calculated,
constdatetime &time[],
constdouble &open[],
constdouble &high[],
constdouble &low[],
constdouble &close[],
constlong &tick_volume[],
constlong &volume[],
constint &spread[])
{
ArraySetAsSeries(time, true); // Standard practiceArraySetAsSeries(open, true);
ArraySetAsSeries(high, true);
ArraySetAsSeries(low, true);
ArraySetAsSeries(close, true);
staticint calc_count = 0;
if (g_EnableDebugPrints_Test && calc_count < 3) { // Log only a few timesPrint("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];
}
} elseif (g_EnableDebugPrints_Test && calc_count < 3) {
Print("TestSeriesIndicator v2: OnCalculate: SKIPPING g_testBuffer assignment because it's NOT series.");
}
calc_count++;
return(rates_total);
}
//+------------------------------------------------------------------+voidOnDeinit(constint reason) {}
//+------------------------------------------------------------------+
Log Output from TestSeriesIndicator.mq5:
TestSeriesIndicator v2: OnInit Start.
TestSeriesIndicator v2: BEFORE SetIndexBufferfor g_testBuffer (index 0). Is series? false
TestSeriesIndicator v2: AFTER SetIndexBufferfor g_testBuffer (index 0). Is series? false
TestSeriesIndicator v2: AFTER ArraySetAsSeriesfor 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 afterSetIndexBuffer().
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.
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
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
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" ...
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
I noticed the OnChartEvent on Tester works for indicators now.
Unless it was always this way
Hello Dear,
I would like to share the following image
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.
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):
Log Output from TestSeriesIndicator.mq5:
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.