how to make an assignment whch is not changed due to new quote ?

 

I am a newbie of coding MQL4

I did not know how to create an assignment which will not be reassigned at every moment a new quote posted.

For example, I want to create a function working as follows:

----------------------------------------------

if total=OrdersTotal()==0 then

assign the Ask price at the moment as the baseprice (ex: 1450.45)

// the problem is that how to fix this baseprice so that it will not be changed due to every new quote !

Then, if the Ask price goes down 200 points (Ask <=1648.45), do something (for example: Buy/sell/Alert ...)

----------------------------------------------

What is the algorithm for such a function in MQL4 ?

Please help me. Thank you very much.

 

Something like

if( OrdersTotal()==0 && baseprice==0 ){ baseprice=Ask; }

followed by

if( OrdersTotal()>0 && baseprice>0 ){ baseprice=0; }

You can also use != in place of >.

 
ubzen:

Something like

if( OrdersTotal()==0 && baseprice==0 ){ baseprice=Ask; }

followed by

if( OrdersTotal()>0 && baseprice>0 ){ baseprice=0; }

You can also use != in place of >.


Excellent algorithm ! Thanks
Reason: