why code in metatraders don't have memory for variables

 

Even adviser that works on ticks, or any other code, cannot save a variable in memory. Because of this, the ability to make a cool code fades away greatly.

 When code execution ends, the values ​​of all variables are reset....

 And already doesn't matter , that function OnTick (other global function for running codes are even more weakest) , have ability to repeat weak codes

Any code gives the value of the variable from start, need to remember result of certain variables, and use this result in next repeat of code, it's my problem.

 
Mikhail Ilyinchyk:

Even adviser that works on ticks, or any other code, cannot save a variable in memory. Because of this, the ability to make a cool code fades away greatly.

 When code execution ends, the values ​​of all variables are reset....

 And already doesn't matter , that function OnTick (other global function for running codes are even more weakest) , have ability to repeat weak codes

Any code gives the value of the variable from start, need to remember result of certain variables, and use this result in next repeat of code, it's my problem.

sounds like you have a bigger problem than you realise. You do not know how to post a question for starters. Where's your example of problem? Where's your description of how you want it to happen?

We have a common saying on this forum. "We can not read your mind". We can not see your screen. And my favourite "Our Crystal Balls are Broken and Cracked".

 
Michael Charles Schefe #:
Our Crystal Balls are Broken and Cracked
my favorite too
 
Michael Charles Schefe #:

sounds like you have a bigger problem than you realise. You do not know how to post a question for starters. Where's your example of problem? Where's your description of how you want it to happen?

We have a common saying on this forum. "We can not read your mind". We can not see your screen. And my favourite "Our Crystal Balls are Broken and Cracked".

I'm surprised this isn't a common problem yet, and a simple example is needed.

Any code in the metaeditor works in a loop ( scripts in a single loop), variables in it are assigned new values.

When the loop is finished, you can see the result that the variables in the code received, but this result will not be used in the new loop.

 

 double b,c,d,e;

   MqlTick last_tick;
   SymbolInfoTick("EURUSD",last_tick);
   b =  last_tick.time;
   c = TimeCurrent();
 
if ( c-b > 3)
{
d++;
Print(d,"adgd");
 PlaySound ("expert.wav");

}


  Variable d, will take new assign in code, but in new loop it had not result from previous loop.

i need result of "d" from previous loop, in current loop.
 
Mikhail Ilyinchyk #:


please edit your code and add it again via the button </>

Also search Mr's Google for "static variable". this is not specific to mql code, but to all c++ code types i have ever seen.

i first learn of static variables over 25 years ago.

 
Michael Charles Schefe #:
static variable

thank for your time. Static variable solve my problem

 
Mikhail Ilyinchyk #:

thank for your time. Static variable solve my problem

you're very welcome.