Errors, bugs, questions - page 1380

 
Sergey Zhukov:
The application has been created, but no one has looked at it in more than three days.
What is the application number?
 
Alexander:
What is the application number ?
#1302121 | 2015.09.14 18:17
Signals: Problem with the statistics
 

The perennial theme of dubs =)

I ask the developers to add two standard features.

I suggest the following specification:

====

Rp

The function returns the value to be aligned to the price step of the instrument.

double Rp(

stringsymbol_name, // symbol name
doublevalue// price to align
);

Parameters

symbol_name

[in] Symbol.

value

[in] Positive number.

Returned value

Nearest number rounded to price step of trading instrument.

...

Example:

Input values:

symbol_name = ES-...

value = 2000.55

output = 2000.50

(price step by instrument ES = 0.25)


Input values:

symbol_name = SPX

value = 2000.55

output = 2000.63

(on SPX the price step is also 0.25, like on ES, but there is a base offset and the quote can have only the following fractional parts -- 13,38,63,88)


Input values:

symbol_name = RTS

value = 82055,55

output = 82060

(price step by RTS instrument = 10)

...and so on.


The second function, which interests me even more:

====

Rv

The function returns a value that will be aligned with the volume step of the instrument and will be in the range from SYMBOL_VOLUME_MIN to SYMBOL_VOLUME_MAX.

double Rv(

stringsymbol_name, // symbol name
doublevalue// lot to align
);

Parameters

symbol_name

[in] Symbol.

value

[in] Positive number.

Returned value

Nearest number rounded up to the volume step of thetrading instrument. The number will not be bigger than SYMBOL_VOLUME_MAX or smaller than SYMBOL_VOLUME_MIN.

...

======


The main property I expect from these functions is that they should be valid for ALL TRADING INSTRUMENTS IN THE WORLD and FOR ANY INTRODUCTION.

If anyone has a ready solution, please share as long as the developers do.

Strange that there is still no such =/

 

Solving the problem from your comment I made a dumbest and clumsiest function, but even it fails for many input values.

Function code:

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 Возвращает кол-во значимых цифр после запятой
 вернёт 0 если число без значимой десятичной дробной части
 вернёт -1 в случае ошибки во время разбора строки на массив
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
int GetDigits(double n)
{
   ushort array[];
   string st=(string)n;                                        // явным образом формируем строку из числа
   int len=StringLen(st);
   if(len<3) return(0);                                        // число не может быть дробным если строка получилась меньше трёх символов
   if(StringToShortArray(st,array)!=len+1) return(-1);         // разбираем строку на массив символов
   for(int i=0;i<len;i++) if(array[i]=='.') return(len-i-1);   // ищем в строке точку и если она есть, возвращаем кол-во символов от точки до конца строки
   return(0);
}

The point is, I've stupidly shifted the whole hassle of determining the significant part of fractional number to the method the compiler inserts instead of operator =(string).

But it turns out that in this way the code formats the string almost like the g-type from printf(), i.e. for long fractions the string prints in a scientific format.

How can I get the output to a string for any n without exponential format and without extra digits on the right, and without hassle =)?

And another question: is it always a decimal fraction separated by a dot or by default from system settings can be a comma or something else?

 
Fry:

Solving the problem from your comment I made a dumbest and clumsiest function, but even it fails for many input values.

Function code:

The point is, I've stupidly shifted the whole hassle of determining the significant part of fractional number to the method the compiler inserts instead of operator =(string).

But it turns out that in this way the code formats the string almost like the g-type from printf(), i.e. for long fractions the string prints in a scientific format.

How can I get the output to a string for any n without exponential format and without extra digits on the right, and without hassle =)?

And another question: is it always a decimal fraction separated by a dot or by default from system settings can be a comma or something else?

Why don't you like Point(), Digits???
 
Vladimir Pastushak:
And what don't you like about Point(), Digits???

At least have DigitsLot(), which will return the accuracy of the volume step.

Perhaps I didn't get your hint. Is there any sensible way to get what you're looking for via Point() or Digits()?


Still, really need those two functions I described above (valid equalizers for price and for lot).

I understand that in forex kitchens the volume is accepted most often in 0.01 increments, and nobody cares what will happen tomorrow, but the terminal is developing.

There are more and more tools. All the homemade devices that don't allow the whole lot increments do not work anymore. Who says that there won't be the minimum lot, say, one-quarter? There are not a lot of variants.

This solution must be absolute (for all values) or it cannot be trusted.


And about the quote. When you send a request, the server accepts prices that are not even, if only to normalize them (cut them in characters), but there are other tasks.

You agree that we should be able to get a real possible quote for any symbol but not a trimmed one.

 
Fry:

Solving the problem from your comment I made a dumbest and clumsiest function, but even it fails for many input values.

Function code:

...
Correcting myself. This one seems to be working:
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
Возвращает кол-во значимых цифр после запятой для чисел с точностью до 8 знаков 
   Вернёт 0 если число целое (в пределах 8 знаков после запятой) 
   Вернёт -1 в случае ошибки во время разбора строки на массив
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
int GetDigits(double n)
{
   ushort array[];
   if(StringToShortArray(StringFormat("%.8f",n),array)<10) return(-1); // число в строку и разбираем строку на массив символов
   int r=ArraySize(array)-2;                                           // размер массива минус ноль-терминатор и минус нулевая база указателя 
   for(;r>0 && array[r]=='0';r--);                                     // ищем справа не ноль
   for(int l=0;l<=r;l++) if(array[l]=='.') return(r-l);                // ищем слева точку и если она есть, возвращаем кол-во символов от точки до не нуля справа
   return(0);
}

Don't think I'm such a fool, so stubbornly making a string out of a number for the sake of a purely mathematical problem.

At first I tried to do it through the logarithm, but it turned out glitchy to the point of no return =(

 
Fry:
Correcting myself. This one seems to work:

Don't think I'm too stupid to make a string out of a number for a purely mathematical problem.

At first I honestly tried to do it via logarithm, but it turned out glitchy as hell =(

Just in case, why don't you like NormalizeDouble()_Point _Digits ?????????

Why do you make a bicycle?

 
Vladimir Pastushak:

Just in case, what's wrong with NormalizeDouble() _Point _Digits ?????????

Why are you making a bicycle?

I will answer this one more time just in case. Please explain me how to find out the accuracy of SYMBOL_VOLUME_STEP using "NormalizeDouble() _Point _Digits"?

Or how to get a value multiple of SYMBOL_VOLUME_STEP from any positive number?

How to get the following result:

2000.55 (ES symbol) -----> 2000.50

2000.55 (SPX symbol) -----> 2000.63

1055.5555 (RTS symbol) ------> 1060

for any symbol in the world that is available in the MT5 terminal today (and preferably tomorrow)

"????????"

The developers can add only 2 functions and modify them as the terminal develops, and I do not know all the peculiarities of different trading instruments. Where can I find out what quotes even exist? And I need a quote, not the result of NormalizeDouble().

If this bike is already out there - poke at a specific implementation, I'd appreciate it. What I found myself already doesn't work on some symbols right now.

 
Fry:

...

2000.55 (ES symbol) -----> 2000.50

2000.55 (symbol SPX) -----> 2000.63

1055.5555 (symbol RTS) ------> 1060

...

Please showSYMBOL_VOLUME_STEP for these three characters.
Reason: