How do I move the global variable structure in the indicator when moving to another timeframe? - page 6

 
Nikolai Semko:

No one is stopping you from making your own adjustments.

It's just that the example is not about casting at all.

 
fxsaber:

It's just that the example isn't about casting at all.

All right, that's it.
Bygones
 
fxsaber:

It was this version that gave the error.

No, you have something else, because on line 144, position 55 is not an index.

 
Nikolai Semko:
All right, we're clear.
Travelled

Still wasted both their time.

#include "Convert.mqh" // https://c.mql5.com/3/360/Convert.mqh

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
template <typename T>
CStructArr::CStructArr(const string name,T &var[]) {
   //ulong tt=GetMicrosecondCount();
   
   int sizeT = sizeof(T)/4;
   size = ArraySize(var);
   w=1+size*sizeT;
   ArrayResize(Var,w);
   h=1;
   
   Name="::"+name+ IntegerToString(ChartGetInteger(0,CHART_WINDOW_HANDLE));
   if(ResourceReadImage(Name,Var,w,h)) {
      uint_to_t = GetMicrosecondCount();
      CONVERT::ArrayToArray(Var, var);
      uint_to_t = GetMicrosecondCount()-uint_to_t;
   } else {
      for (int j=0; j<size; j++) {
         su.st=var[j];
         //for(int i=0; i<sizeof(T)/4; i++) Var[j*sizeof(T)/4+i]=su.u[i];
         ArrayCopy(Var, su.u,j*sizeT,0,sizeT);
         value[j]=var[j];
      }
      if(!ResourceCreate(Name,Var,w,1,0,0,0,COLOR_FORMAT_XRGB_NOALPHA)) printf("Error create Resource: "+DoubleToString(GetLastError(),0));
   }
}

template <typename T>
bool CStructArr::Set(T &var[]) {
   t_to_uint = GetMicrosecondCount();
   CONVERT::ArrayToArray(var, Var);  
   t_to_uint = GetMicrosecondCount() - t_to_uint;
   if(!ResourceCreate(Name,Var,w,1,0,0,0,COLOR_FORMAT_XRGB_NOALPHA)) {
      printf("Error create Resource: "+DoubleToString(GetLastError(),0));
      return(false);
   } else return(true);
}
 
Nikolai Semko:
No, you have something else, because in line 144 position 55 is not an index.

Line 114.


 
fxsaber:

Still wasted both of their time.

The original (SIZE = 1000).

        Сохранение данных - 71 микросекунд
        Время T[] -> uint[] - 49 микросекунд
        Востановление данных - 252 микросекунд
        Время uint[] -> T[] - 52 микросекунд
        Востановление данных - 258 микросекунд
        Время uint[] -> T[] - 51 микросекунд
        Востановление данных - 262 микросекунд
        Время uint[] -> T[] - 52 микросекунд

Modified.

        Сохранение данных - 55 микросекунд
        Время T[] -> uint[] - 47 микросекунд
        Сохранение данных - 30 микросекунд
        Время T[] -> uint[] - 25 микросекунд
        Сохранение данных - 54 микросекунд
        Время T[] -> uint[] - 45 микросекунд
        Сохранение данных - 31 микросекунд
        Время T[] -> uint[] - 25 микросекунд
Data recovery is not working. No time to figure it out. Most likely, when switching TFs, the old copy is knocked out later than the new one.
 
fxsaber:

Line 114.



Yes, I got 144 wrong, but I was looking at 114.
no, miracles don't happen. There can't be an overflow error in this position.
Check the inline path and location of your files.
So you have two iCanvas in your folders and you're running an older version.

 
fxsaber:

Original (SIZE = 1000).

Modified.

Data recovery is not working. No time to figure it out. Most likely, when switching TFs, the old copy is knocked out later than the new one.

Yes, also could not run your version. There is no recording taking place.

 
Nikolai Semko:

Check the inluder path and the location of your files.

So you have two iCanvas in your folders and you are running an older version.

There is only one iCanvas in the whole MQL5 folder. I use ALT+G to jump to it. An error has been excluded.

 
fxsaber:

It's just that the example isn't about casting at all.

It's such a measuring stick.

#include "Convert.mqh"                     // https://c.mql5.com/3/360/Convert.mqh
#include <fxsaber\Benchmark\Benchmark.mqh> // https://www.mql5.com/ru/code/31279

void OnStart()
{
  int Array[];
  MqlTick Ticks1[];
  
  ArrayResize(Ticks1, 10000);
  
  _B(CONVERT::ArrayToArray(Ticks1, Array), 1);
  
  MqlTick Ticks2[];
  
  _B(CONVERT::ArrayToArray(Array, Ticks2), 1);
  
  Print(ArrayCompare(Ticks1, Ticks2)); // Должен быть ноль.
}
Reason: