[WARNING CLOSED!] Any newbie question, so as not to clutter up the forum. Professionals, don't go by. Can't go anywhere without you. - page 168

 

Please tell me how to round off a value to 4 decimal places.

I have a calculation like this

a_M5_461=(Price1_M5_1-4.61*(Price1_M5_1-Price2_M5_1));


where Price1_M5_1 and Price2_M5_1 are values of quotes. However, a_M5_461 is not four decimal places, but more, as long as the expression contains the multiplication by 4.61. We need to make the value be rounded to 4 decimal places.

Please tell me how to do it. I can't find it anywhere.

 
FOReignEXchange писал(а) >>

Please tell me how to round off a value to 4 decimal places.

I have a calculation like this

where Price1_M5_1 and Price2_M5_1 are values of quotes. However, a_M5_461 is not four decimal places, but more, as long as the expression contains the multiplication by 4.61. We need to make the value be rounded to 4 decimal places.

Please tell me how to do it. I can't find it anywhere.

a_M5_461=NormalizeDouble(Price1_M5_1-4.61*(Price1_M5_1-Price2_M5_1),Digits);
 

Thank you very much. This is the second time you've helped.

Thank you.

 
FOReignEXchange писал(а) >>

Thank you very much. This is the second time you've helped.

Thank you.

Is that all the indicator you're doing. Or is it something else?

 
Vinin >> :

Is that all the indicator is doing. Or is it something else?

I'm doing it. I'm in no hurry. The indicator is complicated, but I'm interested in doing it myself. I like complex tasks.

 
Vinin >> :

Your option does not work. When a value is displayed on the screen, 8 decimal places are shown. Of these, 4 are zeros.

 
FOReignEXchange писал(а) >>

Your option does not help. When a value is displayed on the screen, 8 decimal places are shown. Of these, 4 are zeros.

NormalizeDouble() is used for calculations, DoubleToStr() is better for output;

 
Vinin >> :

NormalizeDouble() is used for calculations, DoubleToStr() is better for output;

Yes. It fits perfectly. Thanks again.

 

Please advise what the error is:


extern int RSI_Periods = 14;
extern int Percent_K   = 14;

// double Buffer1[];
double Buffer1[100000];

start() {

   while( i>=0) {

// ============================================================================================
      double Current_RSI, Lowest_RSI, Highest_RSI;

      Current_RSI    = iRSI(NULL,0, RSI_Periods,PRICE_TYPICAL, i);
      Highest_RSI    = Current_RSI;
      Lowest_RSI     = Current_RSI;

      for(int x= i+1; x<= Percent_K+ i+1; x++){
         Lowest_RSI  = MathMin( Lowest_RSI, iRSI(NULL,0, RSI_Periods,PRICE_TYPICAL, x));
         Highest_RSI = MathMax( Highest_RSI,iRSI(NULL,0, RSI_Periods,PRICE_TYPICAL, x));
      }


      Buffer1[ i]     = (( Current_RSI- Lowest_RSI) / ( Highest_RSI- Lowest_RSI)) * 100;
// ============================================================================================


   Comment(
      "\n",
      "\n", "Buffer1[i+30] = ", Buffer1[ i+30],
      "\n", "Buffer1[i+1] = ", Buffer1[ i+1],
      "\n", "Buffer1[i] = "  , Buffer1[ i],
      "\n",
      "\n"
   );

      i--;
   } // while
}


As a result, Buffer1[i+1] and Buffer1[i+30] show 0 when the Indicator starts.

After some time Buffer1[i+1] starts to show non-zero value (why not immediately?),

but Buffer1[i+30] stays 0.

- What is it related to?

 
chief2000 писал(а) >>

Please advise what the error is:

As a result, Buffer1[i+1] and Buffer1[i+30] show 0 when the Indicator starts.

After some time Buffer1[i+1] starts to show non-zero value (why not immediately?),

but Buffer1[i+30] stays 0.

- What does this have to do with it?

And what i equals?