Errors, bugs, questions - page 1845

 
Nikolai Semko:
Question-please ask the developers.
The possibility to save some variables or arrays when switching timeframes, so that their re-initialization would not happen, is very missing. Or can it be done somehow throughOnDeinit by defining a REASON_CHARTCHANGEreason code?
I just have quite cumbersome time-independent calculations in the body of my program and I don't want to recalculate them every time. I feel we miss some special type of global variables, which aren't reinitialized when timeframe changes. I've learned how to do it with simple variables without global variables in the terminal, but with structures or arrays I have no idea how to do it, and it seems that such a possibility simply does not exist. You can, of course, use resources, but it's very confusing.
Try to use an indicator. The global variables are not reinitialized there when changing TF (as far as I remember). Or through a file.
 
Konstantin:

how?

Like this:

struct MyArray
{
   double buff[];
   
   MyArray()
   {
   }
   MyArray( int n )
   {
      ArrayResize( buff, n );
   }
   MyArray( const MyArray& other )
   {
      ArrayCopy( buff, other.buff );
   }
   ~MyArray()
   {
      ArrayFree( buff );
   }
   
   void operator=( const MyArray& other )
   {
      ArrayCopy( buff, other.buff );
   }
   
   void assign( int n, const double val = 0.0 )
   {
      ArrayResize( buff, n );
      ArrayInitialize( buff, val );
   }
};

MyArray func()
{
   MyArray myArray;
   
   // Заполняем массив.
   
   return myArray;
}
 
Koldun Zloy:

For example, like this:

That's not what was asked, but perhaps that would suit the author of the question, to which there is an unequivocal answer - NONE.

There is no refusal in Service Desk

Forum on trading, automated trading systems and trading strategies testing

Bugs, bugs, questions

fxsaber, 2017.04.02 10:34

Is it possible to compensate for the absence of pointers to an array by introducing the ability to return an array with a function?
int[] Func()
{
  int a[] = {1, 2, 3};

  return(a);
}

Print(Func()[1]); // 2

Forum on trading, automated trading systems and trading strategy testing

Bugs, bugs, questions

fxsaber, 2017.04.01 10:20

Once upon a time , the [] operator was added to the string type
string Str = "AB C";
Print(CharToString(Str[1])); // B


Is it possible on the developers side to add an = operator for arrays?

int a[], b[];
a = b; // ArrayCopy(a, b);


Since there are no pointers, such an operator would make the language more flexible - found situations where it would be VERY handy.

 
Alexey Kozitsyn:
Try using an indicator. There global variables are not reinitialised when the TF changes (as far as I remember). Or through a file.

It's the other way round:

Forum on trading, automated trading systems and trading strategy testing

Initialization of global program variables and other useful knowledge.

Artyom Trishkin, 2016.12.05 20:27

Answer received from SD:


I think you can safely use such a feature of global variable EAs.


 
Alexey Kozitsyn:
Try using an indicator. The global variables are not reinitialised when the TF is changed (as far as I remember). Or through a file.

This is what I use the indicator for. They are re-initialized. The file is not an option at all, it is slow and it is difficult to provide good synchronization. I'd better useResourceCreate in this case.But this all is not very convenient. If I have dozens of arrays, some of them with several Mb, I must write at least two functions of reading and writing, create a handler atOnDeinit. I've already experimented with it all, faced the problem of synchronization, because resources and files have their own separate lives in multithreading. Why make a hump when there's just not enough possibility to not re-initialize at certain event, in my case timeframe change.
 
Nikolai Semko:

Indicator and I use it. Reinitialised. File is not an option at all, it's slow and it's hard to provide quality synchronization. I'd better useResourceCreate in this case.But this all is not very convenient. If I have dozens of arrays, some of them with several Mb, I must write at least two functions of reading and writing, create a handler atOnDeinit. I've already experimented with it all, faced the problem of synchronization, because resources and files have their own separate lives in multithreading. Idon't know why I bothered with it when I simply want to avoid reinitialization of some particular event, in my case it was a timeframe change.
The answer is here.
 
Artyom Trishkin:

It's exactly the opposite:



Thanks, I didn't know about the EA!
But man, if I need that chip in the indicator!

 
Koldun Zloy:

For example, like this:


thanks for the example, but creating an object of a complex type because of a single array is exactly what I don't want, it all feels like excessive code ))
 
fxsaber:

That's not what was asked, but perhaps that would suit the author of the question, to which there is an unequivocal answer - NONE.

There is no refusal to do so at Service Desk



let's hope they will introduce this feature, although it would be more usual to introduce a pointer for arrays
 
Artyom Trishkin:

It's exactly the opposite:

Oh, man... Yes, I was guided exactly by your post, just got it all mixed up:)
Reason: