i need help to do store static value

 

hi

i need mql code to store static values A and one for dynamic variable as B

so i need to compare this one

let for example one high made it stored in static and another high made as dynamic variable as B

so i have to compare this two values


pls help me out to give  code for this

 
This is not understandable.
 

If I am understanding your usage of "static" you mean a fixed value and dynamic means it can be changed.  Well, if you want to store an unchanging value, use a constant (naming convention is all caps), and in the spot you want to put the variable value, just do so, like this.

const float FIXED_VALUE = 23.5;  // fixed value
int b = x + 5;  // b is a variable, and can be changed in the program, as long as you keep the same type

But if you want to pull the value from within a certain point, and set your "static" variable to that specific value, just do so except make it a regular variable, and make sure your code only changes it when you want it to.

 
Alain Verleyen:
This is not understandable.

Hi sir

thank u for ur reply


I need two variables old and new.
double old, new;

If suppose current price is 138.50,
old   :  0
new  : 138.50

if current price is changed to 138.75
old   :  138.50
new  : 138.75

if current price is changed to 138.95
old   :  138.75
new  : 138.95

if current price is changed to 138.20
old   :  138.95
new  : 138.20

I need the last two values of price.
 
JD4:

If I am understanding your usage of "static" you mean a fixed value and dynamic means it can be changed.  Well, if you want to store an unchanging value, use a constant (naming convention is all caps), and in the spot you want to put the variable value, just do so, like this.

But if you want to pull the value from within a certain point, and set your "static" variable to that specific value, just do so except make it a regular variable, and make sure your code only changes it when you want it to.

hi sir

thank u for ur reply sir let explain more clear

i need mql code for that sir



I need two variables old and new.
double old, new;

If suppose current price is 138.50,
old   :  0
new  : 138.50

if current price is changed to 138.75
old   :  138.50
new  : 138.75

if current price is changed to 138.95
old   :  138.75
new  : 138.95

if current price is changed to 138.20
old   :  138.95
new  : 138.20

I need the last two values of price.

 
int old=Bid;
int new=0;

if(Bid>new)
 {
  old=new;
  new=Bid;
 }
 
JD4:
If you want help with YOUR specific coding efforts, usually people here are more than happy to help.  However, you have to show you are making the effort to code it yourself by showing YOUR code attempts (using the SRC button) and your specific problems with something.  If you do not know how to code, but want to learn, there are resources for that on this site.  If you are expecting to come in here and have someone code it for you, that is not very likely to happen.  You need to go to the freelance section and ask someone to code your program for you there. 

Hi Sir,

I dont know where is the src button in my editor. I'm using version 5.00 build 1035

Anyway here i'm posting the code:

double new[100], old[100];

void oldnew()
  {
   old1[1] = 0;
   new1[1] = High[1];
   for(int i=1;i<=100;i++)
     {
      new1[i+1]=High[1];
      if(new1[i]!=High[1]) old1[i]=High[1];
      //return(old1[i]);
     }

  }

I'm getting two values from the above function one is new1 and old1

The new1 is High[1] which is coming properly, but the old1 is not coming.

I need the recent two high values, the high[1] is to be new1 and high[2] is to be old1

Here I'm not considering the input as High, just for working confirmation, I'm using the High value of candles. I know it's very easy to use High[1] and High[2] for new1 and old1. But i am not using high.


Pls help me to store the current value in new1 and the last value(recent) in old1.

 
Alain Verleyen:
This is not understandable.

Hi Sir,

I dont know where is the src button in my editor. I'm using version 5.00 build 1035

Anyway here i'm posting the code:

double new[100], old[100];

void oldnew()
  {
   old1[1] = 0;
   new1[1] = High[1];
   for(int i=1;i<=100;i++)
     {
      new1[i+1]=High[1];
      if(new1[i]!=High[1]) old1[i]=High[1];
      //return(old1[i]);
     }

  }

I'm getting two values from the above function one is new1 and old1

The new1 is High[1] which is coming properly, but the old1 is not coming.

I need the recent two high values, the high[1] is to be new1 and high[2] is to be old1

Here I'm not considering the input as High, just for working confirmation, I'm using the High value of candles. I know it's very easy to use High[1] and High[2] for new1 and old1. But i am not using high.


Pls help me to store the current value in new1 and the last value(recent) in old1.
 
kart555:

Hi Sir,

I dont know where is the src button in my editor. I'm using version 5.00 build 1035

Anyway here i'm posting the code:

double new[100], old[100];

void oldnew()
  {
   old1[1] = 0;
   new1[1] = High[1];
   for(int i=1;i<=100;i++)
     {
      new1[i+1]=High[1];
      if(new1[i]!=High[1]) old1[i]=High[1];
      //return(old1[i]);
     }

  }

The SRC button is not in your editor, it is in the comment entry area here, along the top of where you enter your text, next to the camera icon.  Use that so your code, instead of showing up as it does in your post, will look like this.  It makes it easier for others to track your code, and possibly spot potential problems with it.  Edit: I also noticed something else, your use of the word new in the way you did will most likely give your program problems, as new is a specific command in the language to create a new item.

double new[100], old[100];  // this use of "new" is likely to cause you problems

void oldnew()
  {
   old1[1] = 0;
   new1[1] = High[1];
   for(int i=1;i<=100;i++)
     {
      new1[i+1]=High[1];
      if(new1[i]!=High[1]) old1[i]=High[1];
      //return(old1[i]);
     }

  }
 
JD4:

The SRC button is not in your editor, it is in the comment entry area here, along the top of where you enter your text, next to the camera icon.  Use that so your code, instead of showing up as it does in your post, will look like this.  It makes it easier for others to track your code, and possibly spot potential problems with it.  Edit: I also noticed something else, your use of the word new in the way you did will most likely give your program problems, as new is a specific command in the language to create a new item.

double new1[100], old1[100];  // this use of "new" is likely to cause you problems

void oldnew()
  {
   old1[1] = 0;
   new1[1] = High[1];
   for(int i=1;i<=100;i++)
     {
      new1[i+1]=High[1];
      if(new1[i]!=High[1]) old1[i]=High[1];
     }
  }

Sir, I need help to get last two values, I'm getting the new value as correctly, but I'm not getting the last value.
What I'm expecting is that:

If the current value is 50 means,
old : 0
new : 50

If the value is changed to 65 from 50 means,
old : 50
new : 65

If the value is changed to 98 from 65 means,
old : 65
new : 98

If the value is changed to 47 from 98 means,
old : 98
new : 47

Pls help me to get the output as above, the input value I'm getting from a disappearing indicator, that's why here i given code by using High value.
 

you making it way to complicated why the for loop and why the array's if you only want to compare High[1];

double new1,old1;

int OnInit()
  {
   old1=0;
   new1=High[1];
   return(INIT_SUCCEEDED);
  }
  
void OnTick()
  {  
   if(new1!=High[1])
    {
     old1=new1;new1=High[1];
    }
    Print("old1: ",old1," new1: ",new1);
  } 
Reason: