SymbolInfoDouble returning le-05 - page 3

 
bti4: Yes I currently as they wont be yielding the problem I am having.

That is the wrong attitude in proper coding because you could be introducing bugs. Always make sure everything is properly coded and compiling with no errors or warnings before looking for bugs. It will save you time in debugging.

 
bti4:

I have come from a Java background and honestly I like a challenge but wont go close to OOP. Its just my preference as I find it easier to debug and read later on again.

This pip thing is the only thing i cant resolve. Everything else works perfectly after changing over. Yes I know there are errors with conversions etc and I fully respect everyone's feedback on this.

 
Fernando Carreiro:

That is the wrong attitude in proper coding because you could be introducing bugs. Always make sure everything is properly coded and compiling with no errors or warnings before looking for bugs. It will save you time in debugging.

I totally understand that however it still yields le-05 even with the changes you advised. Even more so if I only use that small portion of code and compile it without the other code. It amazes me that it works perfectly for 3 digits but not 5?

 
bti4:I totally understand that however it still yields le-05 even with the changes you advised. Even more so if I only use that small portion of code and compile it without the other code. It amazes me that it works perfectly for 3 digits but not 5?

I have already answered that several times yet you insist in ignoring my advice. I have already stated that "le-05" is just a different notation for "0.00001" and if you want a different format, then print accordingly ...

Print( "Point Size: ", DoubleToString( point, digits ) );
However, the value is correct and does not need to be corrected. It is just how you print it that makes a difference.
 
Fernando Carreiro:

I have already answered that several times yet you insist in ignoring my advice. I have already stated that "le-05" is just a different notation for "0.00001" and if you want a different format, then print accordingly ...

I understand I can print it differently. It does not work in a calculation. Cannot divide by le-05. It tells me I am dividing by zero, that is the problem.


Maybe I am not explaining this very well which is always possible. I am printing it out to debug and establish why i get an error for dividing by zero. I have isolated it to:

double point = SymbolInfoDouble(position_symbol,SYMBOL_POINT);


This outputs le-05. Yes I know I see that as its printed out and i can change it... it cant be divided by.

 
bti4: I understand I can print it differently. It does not work in a calculation. Cannot divide by le-05.

I give up! We tell you where things are wrong! We tell you where to place debug prints (and you don't). And you give us the results of separate testing which has nothing to do with printing the actual values happening in your real-time code debugging.

We tell you to break up your code (for real, not just testing) so that it can be read and debugged more easily and you don't!

If you are unwilling to follow advice, then we can't help you much!

This is very bad coding:

if(orderType == 0){ //buy order
   orderPips = MathAbs((NormalizeDouble(((orderPriceCurrent - PositionGetDouble(POSITION_PRICE_OPEN))/SymbolInfoDouble(position_symbol,SYMBOL_POINT)),SymbolInfoInteger(position_symbol,SYMBOL_DIGITS)))/point_compat); //price 2 is current, price 1 is open
   if(orderPriceCurrent < PositionGetDouble(POSITION_PRICE_OPEN)){orderPips = orderPips * -1;}
} 


 
   string make_your_dang_doubles_a_string_before_concatination = DoubleToString(
      SymbolInfoDouble(_Symbol, SYMBOL_POINT), int(SymbolInfoInteger(_Symbol, SYMBOL_DIGITS))
   );
   printf("The point value for %s is %s",
       _Symbol, 
      make_your_dang_doubles_a_string_before_concatination
   );
 
bti4:

I have come from a Java background and honestly I like a challenge but wont go close to OOP. Its just my preference as I find it easier to debug and read later on again.

I find this very hard to believe. Java is 100% OOP and Java devs wouldn't concat string objects with other types... 

 
nicholi shen:

make_your_dang_doubles_a_string_before_concatination

:-D

 
bti4:

I have done everything asked. I have duplicated your requests on my end with the same results.


Must I overhaul 8000 lines of code to correct something not diving by 5 points and only by 3? By debugging and printing I have narrowed down the exact line that causes this problem. Yes maybe I am not explaining it properly.

I am not trying to find out how many points or digits there are for a specific symbol. I am trying to take the (current price - open price) / points and then normalise it and finally divide it by 10 to get it into pips. Its very basic and works perfectly in MQL4. I realise MQL5 is different.


All calculations work correctly until its a 5 digit symbol, then it says cant divide by zero.

I literally gave you the exact code to do this earlier ITT. Fernando has spent a great deal of time spelling it out for you in increasingly simplified steps. What more information could you possibly need? 

Reason: