How can i compare two prices?

 

I want to compare the price of the EURUSD, for example, with the previous second or minute price. How can I do this?

I try to use a while loop like this, for compare infinite times, but this code is very slowly and as time goes on is even slower :

  double AskAnt = Ask;
  double AskAct = Ask;
  while(true)
  { 
      RefreshRates();
       AskAnt = AskAct;
           AskAct = Ask;

         Comp = AskAnt - AskAct;
 
         if(Comp > 0 )
         {
                     //Execute Commands
         }
      Sleep(1000);
  }

When I use without a while, the AskAnt and AskAct be equal same time.

How can I do this with a performatic code?


Thank You!

 
andisu:

I want to compare the price of the EURUSD, for example, with the previous second or minute price. How can I do this?

I try to use a while loop like this, for compare infinite times, but this code is very slowly and as time goes on is even slower :

When I use without a while, the AskAnt and AskAct be equal same time.

How can I do this with a performatic code?


Thank You!

double AskAnt = Ask;
double dP = 0.5*Point;
double Comp   = 0;
  while(Comp<dP)
  { 
      Sleep(1000);
      RefreshRates();
      Comp = MathMod(AskAnt - Ask);
  }
// Do Any Y Want

If Y wanna to wait while price will be changed - try this one.

If Y not - just whithout while()

double AskAnt = Ask;
double dP     = 0.5*Point;
    Sleep(1000);
    RefreshRates();
    if(MathMod(AskAnt-Ask)>dP)
    {
    // DO Any Y want
    }


Regards.