Questions from Beginners MQL5 MT5 MetaTrader 5 - page 666

 

Good afternoon.

Can you please tell me how to modify this function to get rid of the error (the size of local variables is too large (more than 512kb)):

double DTWDistance(double &s[], double &t[])
{
   int slenght = ArraySize(s);
   int tlenght = ArraySize(t);
   double dtw[1000][1000];
   int i, j;

   dtw[0, 0] = 0.0;
   for (j = 1; j <= tlenght; j++)
   {
      dtw[0, j] = 1000000.0;
   }
  
   for (i = 1; i <= slenght; i++)
   {
      dtw[i, 0] = 1000000.0;
   }

   for (i = 1; i <= slenght; i++)
   {
      for (j = 1; j <= tlenght; j++)
      {
         dtw[i, j] = Distance(s[i], t[j]) + MathMin(dtw[i - 1, j], MathMin(dtw[i, j - 1], dtw[i - 1, j - 1]));
      }
   }

   return (dtw[slenght, tlenght]);
}
 
Craft:

Good afternoon.

Can you please tell me how to modify this function to get rid of the error (the size of local variables is too large (more than 512kb)):

double DTWDistance(double &s[], double &t[])
{
....
   return (dtw[slenght, tlenght]);
}
In order to redo it, you need to know what your function solves, and for what tasks it is used
 
Vitaly Muzichenko:
In order to re-do it, you need to know what your function solves and for what tasks it is used.
Good day, Vitaliy.

I have started to get compiling error message (the size of local variables is too large (more than 512kb) of different code from some build of MT4. I tried to find error message and attached simple code fragment from WmiFor30 indicator for example. Can you use this example to show me how to fix this error?

Files:
WmiFor30.mq4  25 kb
 
Craft:
Good day, Vitaly.

Since a certain build of MT4 I have started to receive an error during compilation (the size of local variables is too large (more than 512kb)) of different code, I tried to understand how to deal with it and for example I pasted what I thought was a simple code fragment from WmiFor30 indicator. Can you use this example to show me how to fix this error?

I don't know what's the principle of it, try it, you will see the fix
Files:
WmiFor30.mq4  25 kb
 
Vitaly Muzichenko:
I don't know what's in it, try it, you'll see.
Thanks, it's interesting.
 

Graphic question:

There is a design like this

for(long currChart = ChartFirst();currChart != -1; currChart=ChartNext(currChart)) {
 if(currChart == график тестера) continue; // Что сюда написать?
  ObjectSetInteger(currChart,"Sync",OBJPROP_BGCOLOR,clrGreen);
}

How do I find out that the graph is not the main graph but open in tester mode and skip it?

 
Hello!
Today is Sunday:
TimeCurrent()=1478300399, which corresponds to 2016.11.04 22:59 - Friday
DayOfWeek()=5, which is quite natural ))

Question: Please tell me how to determine programmatically in init(); that now, when an EA is attached to a chart, the day off is Sunday ?
Without reference to TimeLocal():
 
Leo59:
Hello!
Today is Sunday:
TimeCurrent()=1478300399, which corresponds to 2016.11.04 22:59 - Friday
DayOfWeek()=5, which is quite natural ))

Question: Could you please tell me how to determine programmatically in init(); that now, at the moment of attaching EA to chart, day off is Sunday ?
Without reference to TimeLocal():
Will help?
 
Vitaly Muzichenko:
will it help?
Thanks for the tip. But, :

AccountInfoInteger(ACCOUNT_TRADE_ALLOWED) can return false in the following cases:

  • no connection to the trade server. Can be checked with TerminalInfoInteger(TERMINAL_CONNECTED));
  • the trading account has been switched to read-only mode (sent to archive);
  • trading on the account has been banned on the trade server side;
  • connection to the trading account has been made in investor mode.

Here if just : trading is prohibited on the trade server side;

Otherwise, it's not quite right ))


Although, in principle, boolIsTradeAllowed(); can be tried.

Many thanks Vitaly!!!!

 
Unfortunately, it doesn't work.

init();
if(IsTradeAllowed()) Print("Trade Allowed");
if(!IsTradeAllowed()) Print("Trade is NOT allowed");


It says: "Trading authorised"

There's got to be another way. How do I do it ?