Errors, bugs, questions - page 736

 
I was referring to it and also to the .chm extension
 
 
void OnStart()
  {
   MqlRates a[],b[];
   Alert("после MqlRates a[],b[] Series == "+ArrayIsSeries(b));
   CopyRates(Symbol(),PERIOD_CURRENT,0,TerminalInfoInteger(TERMINAL_MAXBARS),a);
   ArraySetAsSeries(a,true);
   CopyRates(Symbol(),PERIOD_M1,0,TerminalInfoInteger(TERMINAL_MAXBARS),b);
   Alert("после CopyRates Series == "+ArrayIsSeries(b));
   ArraySetAsSeries(b,true);
   Alert("после ArraySetAsSeries(b,true); Series == "+ArrayIsSeries(b));
}
2012.05.06 17:29:55 TEMP (EURUSD,H1) after ArraySetAsSeries(b,true); Series == false
2012.05.06 17:29:55 TEMP (EURUSD,H1) after CopyRates Series == false
2012.05.06 17:29:55 TEMP (EURUSD,H1) after MqlRates a[],b[] Series == false

It shows and it does not blush. May be I am boiling?

 
 
sergeev:

ArrayGetAsSeries

Removing the lid, turning off the fire.

Thank you.

 
Market is not working, no demos or free products can be downloaded - "Error loading program *****. Please try again later"
 
papaklass:

1 leaked strings left

I figured it out, it's the initialization mode of MQLTradeRequest request structure.

If we initialize it this way:

then"1 leaked strings left" does not appear.

If initialization is carried out from the OpenPosition() function to the global level, the memory record appears:

Regarding the second option. Trying to figure it out, I found the following code:

//+------------------------------------------------------------------+
//|                                                   papaclass4.mq5 |
//+------------------------------------------------------------------+
MqlTradeRequest      mrequest={1};
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void OnStart()
  {
   Print("Global: mrequest.price=",mrequest.price);
  }
//+------------------------------------------------------------------+

Returns:

2012.05.07 10:52:10 papaclass4 (USDCAD,M1) Global: mrequest.price=0.0

It turns out that the variable mrequest={1} is initialized on global level, but the program does not see values of its initialized fields for some reason. The compiler does not complain too.

 
You have initialised the first member of the structure with one and the rest with zero by default.
 
Renat:
You have initialised the first member of the structure with one and the rest with zero by default.
Got it. I found the explanation in the Reference Manual: "There must be at least one value in the initialization sequence: the first element of the corresponding structure or array is initialized with this value, missing elements are considered zero".
 
papaklass:

1 leaked strings left

I figured it out, it's coming from the way MqlTradeRequest structure is initialized.

If we initialize it this way:

then"1 leaked strings left" doesn't appear.

If we move initialization from the OpenPosition() function to the global level, the memory record appears:

Thank you for the message, the compiler error is fixed.