every value shall be exported to csv with same amount of decimal place

 

Hi!

I calculate Momentum with

Momentum[i] = iMomentum(NULL,0,14,PRICE_CLOSE,i);

for different bars and export it to excel.

In excel the number is written as a string like that:

100 1.000.25 999.964 999.856 1.000.036


I need it in this way:

100.0000 100.2520 99.9964 99.9856 100.0036


Has someone an idea how to solve this?

Thanks in advance!

 

Divide the values by 10 ? :-0

If you are talking about the formatting within Excel you need to adjust the cell formatting and adjust the number of decimal places shown.

 

The numbers

100 1.000.25 999.964 999.856 1.000.036


are formatted as string. So, the dot is only a "seperator" for better reading. If I adjust the cell formatting e.g. to 2 decimal places the result would be


100,00 1.000.25,00 999.964,00 999.856,00 1.000.036,00


But I need

100,0000 100,02500 99,9964 99,9856 100,0036 (should have written that above with a comma, too)

 

Can you get rid of the dot that isn't a decimal point ?

Then look at this http://support.microsoft.com/kb/181298

 

Hello,

The first value does not fit in the row.

After your normalisation there will be nearly no difference between the first and the last one. But on realty there is.

Set excel cell formating to 4 decimals without separator

double normalizeToMax100(double value){
 while(value>100) value=value/10;
 NormalizeDouble(value,4);
 return (value);
}
 

Thank you very much for your ideas. Now I figuered out what the solution for the problem is:

Using normalizedouble("value",4) delivers a number including 4 digits after the decimal point, except the last digit is zero - then you get 3 digits after the decimal point. While using FileWrite in purpose to export to csv the number is converted to a string:

before normalize after normalize after export to csv
1,12345 1,1234 11234
1,1230 1,123 1123


Now you need to use the excel function "len" to search numbers with less than 5 digits, multiply them with 10 (or 100 if less than 4, and so on) and the exportet numbers are in same scale to each other as before exporting.