Libraries: TradeTransactions - page 5

 
fxsaber:

The library sources contain Convert.mqh, which quickly converts an array of one type into an array of another type.

// Fast array casting.
#include <fxsaber\TradeTransactions\Convert.mqh> // https://www.mql5.com/en/code/22166

void OnStart()
{
  MqlTick Ticks[];

  MqlRates Rates[];  
  CopyRates(_Symbol, PERIOD_CURRENT, 0, 10, Rates); // Got the quotes.
  CONVERT::ArrayToArray(Rates, Ticks);              // Casting MqlRates[] -> MqlTick[].

  MqlRates Rates2[];    
  CONVERT::ArrayToArray(Ticks, Rates2);             // Casting MqlTick[] -> MqlRates[].
  ArrayPrint(Rates2);                               // Make sure everything is correct.
}
 
fxsaber :

You can exchange anything through Resources.


You claim to download Container2, but you don't use it. Logically, it should be:

  // Get the data in its original form
  string Str2[];
  Container2[0].Get(Str2);                // Got the array
  ArrayPrint(Str2);

  PRINT(Container2[1].Get<double>())      // We got a number
  PRINT(Container2[2].Get<MqlTick>().bid) // We got the structure   
Of course, in your example, the result is the same.

More importantly, using the above code as a script with libraries download from

I got :

2019.03.26 18:11:51.624 R-277866Original (EURUSD,M1) Container[i].GetType() = string[2]
2019.03.26 18:11:51.624 R-277866Original (EURUSD,M1) Container[i].GetType() = double
2019.03.26 18:11:51.624 R-277866Original (EURUSD,M1) Container[i].GetType() = MqlTick
2019.03.26 18:11:51.656 R-277866Original (EURUSD,M1) Stack overflow in '...\MQL5\Scripts\forum\ R-277866Original.ex5'

?
 
Alain Verleyen:

You claim to load Container2, but you don't use it. Logically, it should be:

Yes, there is a typo in the example.


Of course, in your example the result is the same.

With your edit, the result will be the same.


More importantly, using the above code as a script with libraries download from

I got :

2019.03.26 18:11:51.624 R-277866Original (EURUSD,M1) Container[i].GetType() = string[2]
2019.03.26 18:11:51.624 R-277866Original (EURUSD,M1) Container[i].GetType() = double
2019.03.26 18:11:51.624 R-277866Original (EURUSD,M1) Container[i].GetType() = MqlTick
2019.03.26 18:11:51.656 R-277866Original (EURUSD,M1) Stack overflow in '...{MQL5\Scripts\forum\R-277866Original.ex5'

?

I can't say anything without the source code.

 
fxsaber :
...

I can't say anything without the source.

The source is exactly your code. Build 2009.

Files:
 
Alain Verleyen:

It is your code that is the source. Build 2009.

Executed without errors.

 

Good afternoon.

I'm just declaring

RESOURCEDATA<uchar> Res;

And such an error

'Data' - struct undefined       Convert.mqh     75      49
in template 'int CONVERT::ArrayToStruct(const SOURCE&[],TARGET&[])' specified with [SOURCE=uchar,TARGET=uint]   Convert.mqh     60      14
'Data' - struct undefined       Convert.mqh     43      38
in template 'int CONVERT::StructToArray(const SOURCE&[],TARGET&[])' specified with [SOURCE=uchar,TARGET=uint]   Convert.mqh     29      14

It was not before, I think after updating the terminal appeared (build 2085). Or am I somewhere stupid? )

 
Oleksii Chepurnyi:

It didn't exist before, I think it appeared after terminal update (build 2085).

Localised this compiler bug

template <typename T>
struct A { T a; };

void f1()
{
  struct B { int Data; };
  A<B> Tmp;
}

void f2()
{
  struct B { int Data; };
  A<B> Tmp;
  
  Tmp.a.Data = 0; // 'Data' - struct undefined
}
 
I think after updating the terminal it appeared
.

Yes, there is no such error in 2037.

 
Oleksii Chepurnyi:

Yeah, there's no such error in 2037.

Bypassed the bug, replace Include\fxsaber\TradeTransactions\Convert.mqh with the attached one.

Files:
Convert.mqh  4 kb
 
fxsaber:

Bypassed the bug, replace Include\fxsaber\TradeTransactions\Convert.mqh with the attached one.

Works ) Thanks!