help me please, how to save a value ?

 
int OnTick ()

{

if (Bid > Close [+1])

{ (Bid value saved forverer) } // How can i save Bid value that specific time?

Thanks 
 
  1. Close[-1] is the future, it doesn't exist.
  2. Close[0] is equal to Bid always.
  3. Just save it (static or global.)
    int OnTick(){
      static double Bid_value_saved_forverer;
      if (Bid > Close[1]){ Bid_value_saved_forverer = Bid; }
 
so just put a "static" before defining double? Thanks a lot
 

Just 1 more question, if i put another If condition, the Static value will update if last condition is checked?  

 

No.

Static values are static.

 
mrluck1:

Just 1 more question, if i put another If condition, the Static value will update if last condition is checked?  

If you give the static variable a new value, then it will retain that value until you assign a new value to it.
 

I still don't undertstand, mql4 book doesn't explain about this, and i really need to know this, for example:

 

int OnTick()

static double Bid_value_saved_forverer;

{

if (Bid > Close[1])

   { Bid_value_saved_forverer = Bid; } // happen...

   if (Bid > Close[1])
   { Bid_value_saved_forverer = Bid;} // happen too
  
   }

 

 If the first condition happen, then next happen too, the static will save only the first one, or the last?

Thanks 

 
mrluck1:

I still don't undertstand, mql4 book doesn't explain about this, and i really need to know this, for example:

 

int OnTick()

static double Bid_value_saved_forverer;

{

if (Bid > Close[1])

   { Bid_value_saved_forverer = Bid; } // happen...

   if (Bid > Close[1])
   { Bid_value_saved_forverer = Bid;} // happen too
  
   }

 

 If the first condition happen, then next happen too, the static will save only the first one, or the last?

Thanks 

The last one.
 
honest_knave:
The last one.
Thanks a lot 
 
mrluck1:
Thanks a lot 

const can only be set once.

If you want to remember it between calls, you can try static const 

Or look into Global Variables of the Terminal - https://docs.mql4.com/globals

Global Variables of the Terminal - MQL4 Reference
Global Variables of the Terminal - MQL4 Reference
  • docs.mql4.com
Global Variables of the Terminal - MQL4 Reference
 
mrluck1: I still don't undertstand, mql4 book doesn't explain about this, and i really need to know this,
I gave you links (#1.) Did you bother to read them?
Reason: