converting ask to a double - page 2

 
Guillermo:

That's exactly what I meant. I haven't come across any, but who knows... Better safe than sorry!

Kind regards.

Well, there are still ways around it. For example, most brokers will offer EURUSD so just test that. Of course, you may have a broker that doesn't offer it, and you may need to cater for broker suffix/prefix:

long EUdigits=SymbolInfoInteger("EURUSD",SYMBOL_DIGITS);
double pip=Point;
if(EUdigits==5)      { pip*=10; }
else if(EUdigits==6) { pip*=100; }    


 

 

That's an old and recurring discussion.

You can't expect to find a magic formula for a pip which will work for all symbols, for everyone and up to the end of time, simply as a pip doesn't have a scientific definition, it's a convention.

Find and use one that works for you and the symbols you are working with now, that's the best you can do.

 

Ok thanks for all the input guys,

whroeder1, thank you your code does a much better job than mine. 

Can I ask what the purpose of round_up and round_nearest is for? I don't see where it would be used within the rest of the code. 

I tried a small simple code added to yours to calculate the distance between the Ask and a level. Haven't got it working yet so any help for this would be great, I will keep working on it either way.

I tried it on AUDUSD when price was between 00 && 20 so it should have given me the pip difference from Ask to the level20. no Alerts came up at all even though price was moving. 

void OnTick()
   {
double pip = _Digits % 2 == 0 ? _Point : 10.0 * _Point;
double level00 = round_down(Ask, 100*pip);
double level20 = level00 + 20*pip;
double level50 = level00 + 50*pip;
double level80 = level00 + 80*pip;

   if (Ask<level20)
      {
      pipstolevel=(level20-Ask);
      return;
      }

Alert(pipstolevel);
return;
 
boh113 so it should have given me the pip difference from Ask to the level20. no Alerts came up at all even though price was moving. 
      pipstolevel=(level20-Ask);
That does not give you the pip difference, it gives you the price difference. To get the difference in pips, divide by the size of a pip.
 
whroeder1:
That does not give you the pip difference, it gives you the price difference. To get the difference in pips, divide by the size of a pip.

Your so right, completely over looked that. Thanks again whroeder1.

Reason: