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

 
How to move a global variable, structure, object in an indicator when moving to another timeframe? I haven't found it by Googling.
 
Mikhail Nazarenko:
How to move a global variable, structure or object in the indicator when moving to another timeframe? I googled it, but did not find it.

clumsy solution : if not objects, then don't reinitialize them :-)

When timeframe is changed, the data is not overwritten by itself, although the EA restarts. This is an unexpected behaviour for the C-suite, and maybe it will change in other builds, but there you go ;-)

And the correct solution - save the state in a file or database, and in the OnInit decide - to restore the previous state or start over

 
Maxim Kuznetsov:

clumsy solution : if not objects, then don't reinitialize them :-)

When timeframe is changed, the data is not overwritten by itself, although the EA restarts. This is an unexpected behaviour for the C-suite, and maybe it will change in other builds, but there you go ;-)

And the correct solution - to save the state in a file or database, and in the OnInit decide - to restore the previous state or restart from scratch

I understand that there are no simple solutions for structures and objects?

 

Maxim Kuznetsov:


When you change timeframe, the data is not overwritten by itself, although the EA restarts.


The question was about the indicator.

 
Mikhail Nazarenko:

How to movea global variable, structure, object in an indicator when moving to another timeframe? I googled it and did not find it.

- global variable - just save it in global variables of the terminal.
- chart object - simply do not delete it from a chart.
- structure - just write it to a file.

 
Mikhail Nazarenko:

I understand that there are no simple solutions for structures and objects?

Is it not an easy solutionto write to a file? There seems to be nothing complicated - FileWriteStruct() is available. That part of the object to be written (and it's still data, not methods, which makes no sense to save), converted into a structure.

 
Ihor Herasko:

Iswriting to a file a tricky solution? There seems to be nothing complicated - FileWriteStruct() is available. That part of the object to be written (and it's still data, not methods, which makes no sense to save), converted into a structure.

Seems like a simple thing to understand, but if there is nothing more elegant, then to a file. I naively thought I could do without crutches. Thank you.

 
It's easier to recalculate all the structures from scratch on a reinit, unless of course there are some super-mega-complex calculations...
 
transcendreamer:
It's easier to recalculate all structures from scratch, unless of course there are some super-mega-complex calculations...

There are times when data is not calculated. For example, user actions.

 
Ihor Herasko:

There are times when data is not calculated. For example, user actions.

Yes, there are, but they can usually be stored as statuses in globals or their objectified result as state of graph objects...

 

here@fxsaber showed an example of how to save the structure in global variables

https://www.mql5.com/ru/forum/320395/page6#comment_12910394

and below his post in this thread

Reason: