JPY pairs rounding

 

Any ideas how to round the JPY pairs here?

If price is at 85, I'm trying to find how far it is away from a number in the array, eg 80 and 90, it should round up.

It works for the 5 decimal place pairs.

I am trying to round to tens so 80, 90, 100, 110 even if price is at 85


bool SoundAlert = true;
datetime LastAlertTime;

//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
{
   //set the psych levels for stop hunting
   if (Point==0.00001) {
   double stops_array[20] = {0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9,
                             1.0, 1.1, 1.2, 1.25, 1.3, 1.4, 1.5, 1.6, 1.75, 1.8, 1.9, 2.0};
   double ignoreLevel = 0.0;
   }
   
   if (Point==0.001) {
   stops_array[16] = {200, 190, 180, 170, 160, 150, 140, 130, 120, 110, 100, 90, 80, 70, 60, 50, 40};
   ignoreLevel = 0.0;
   }
   
   //Work out nearest price level
   if (Point==0.00001) {
   
   double currPANearest = NormalizeDouble(Bid,1);

   double distanceAway = MathAbs(currPANearest-Bid);
   Comment("currPANearest="+DoubleToStr(currPANearest,1)+
           "\nDistance away="+DoubleToStr(distanceAway*10000,0)
   );
   int Arrayint = ArrayBsearch(stops_array,currPANearest,WHOLE_ARRAY,0,MODE_DESCEND);
   
   if (SoundAlert && LastAlertTime < Time[0] && (distanceAway*10000)<50)
            {
               Alert("Nearing psych level on "+Symbol());
               LastAlertTime = Time[0];
            }
            
   }

   if (Point==0.001) {
   
   currPANearest = NormalizeDouble(Bid,0);

   distanceAway = MathAbs(currPANearest-Bid);
   Comment("currPANearest="+DoubleToStr(currPANearest,0)+
           "\nDistance away="+DoubleToStr(distanceAway*100,0)
   );
   Arrayint = ArrayBsearch(stops_array,currPANearest,WHOLE_ARRAY,0,MODE_DESCEND);
   
   if (SoundAlert && LastAlertTime < Time[0] && (distanceAway*100)<50)
            {
               Alert("Nearing psych level on "+Symbol());
               LastAlertTime = Time[0];
            }
            
   }
   
   
}


 
SanMiguel:

Any ideas how to round the JPY pairs here?

If price is at 85, I'm trying to find how far it is away from a number in the array, eg 80 and 90, it should round up.

It works for the 5 decimal place pairs.

I am trying to round to tens so 80, 90, 100, 110 even if price is at 85


double RoundedValue;

RoundedValue=10*MathRound(Bid/10);

 
FXtrader2008:

double RoundedValue;

RoundedValue=10*MathRound(Bid/10);


Thanks!

Any ideas on how I also include code to look for 2 decimal places in this?

I need to get the following code to also look at 0.25, 0.5, and 0.75 (ie 2 decimal places) in the range but not sure how to check that as well as checking the 1 st decimal place only.

For example, it should alert me at all main 1.x numbers (1.1, 1.2, 1.3, etc.) but also 1.25, 1.5, 1.75, 0.75, 0.5, 0.25

Reason: