Previous Day High-Low - page 2

 
WHRoeder:
You misunderstood. He was using the variable i for BOTH the current chart AND the D1 chart.
I see your point now. He should have separated apple and orange = don't use the same i.
 
ledzep:

ledzep, why you have use this condition?

Isn't it always true?

Thanks for your reply.

int start()
  {
   static bool first=true

   ...

if(counted_bars==0 || first)
      {
      first=false; 
      ...
      }
 
That's something I didn't get until quite recently . . . static variables get initialised only once not every time the function they are in is called. https://docs.mql4.com/basis/variables/static
 
Along those lines, have anyone else noticed that global scale bools (not terminal global) don't save their values between function calls? Or is it just me ... I haven't really tested it extensively, I'm hoping to get a quick confirmation.
 
RaptorUK:
That's something I didn't get until quite recently . . . static variables get initialised only once not every time the function they are in is called. https://docs.mql4.com/basis/variables/static
Thanks a lot!
 
ubzen:
Along those lines, have anyone else noticed that global scale bools (not terminal global) don't save their values between function calls? Or is it just me ... I haven't really tested it extensively, I'm hoping to get a quick confirmation.
I hope it's just you . . otherwise my extern bools wouldn't be doing what they seem to be doing. ;-)
 
RaptorUK:
I hope it's just you . . otherwise my extern bools wouldn't be doing what they seem to be doing. ;-)


Now I really have to go test this. I've put it off long enough ;)

Update: they all worked!! Yeaaa. I must have had a logical issue when I dealt with it back-then. I've just got-by on using integers. This outta help shorten, optimize and save some resources.

 
RaptorUK:
That's something I didn't get until quite recently . . . static variables get initialised only once not every time the function they are in is called. https://docs.mql4.com/basis/variables/static
Statics get initialized only once on load. They do not get reinitialized on each deInit/Init cycle. This it my pattern for initialized globals/statics, statics become global as they are now shared between OnInitX() and X()
int start(){
   static bool first=true;
   :
   if(counted_bars==0 || first)
      {
      first=false; 
      ...
      }
int init(){
   OnInitStart();
   :
}
bool first; void OnInitStart(){ first=true; }
int start(){
   :
   if(counted_bars==0 || first)
      {
      first=false; 
      ...
      }
 

Hi all one

So is possible to add linee average HIGH - LOW of the previus day?

 
thanksssss......
Reason: