Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 364

 
Sepulca:
Do you have the source code of the indicator? If not, search for the author))))

I have the source code - it's a mess.
 
No, I won't even try it then. Sometimes you get lost in your own code, let alone someone else's))))
 

How to tell me please some proven Expert Advisor in MQL4 and 5, and the time is very short, sometimes you need to check one idea or help someone to finally create a basis for the robot and to finish writing it yourself ...

I would be grateful, thanks in advance!!! =)

 
vadynik:

I'm writing a function like this

But why does OrderOpenPrice() return the rounded price to four digits on the five digits?


int i, k=OrdersTotal();

  for (i=k-1; i>=0; i--) 
   {
    if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
     {                
       if ((OrderType()==OP_BUY)&&(OrderOpenPrice()>=Ask-350*Point)&&(OrderMagicNumber()==Magic)||(OrderType()==OP_BUY)&&(OrderOpenPrice()<=Ask+250*Point)&&(OrderMagicNumber()==Magic))
         {
           double o=OrderOpenPrice();
           Print(o);
           OrderClose(OrderTicket(),OrderLots(),Bid,50,Blue); 
         
      }
    }
  }
Try to do this and see what OrderOpenPrice() really returns, maybe the reason is that you are normalizing the function with the Digits parameter and you see in the printer not what it really is.
 
vadynik:

I'm writing a function like this

But why does OrderOpenPrice() return the rounded price to four decimal places?

Print does not return a rounded price, in this case, it simply outputs the default number of decimal places.
Actually, Forex does not work with decimal places that are lower than digits. In general, the EURSD example shows only four decimal places.

But in your case it is better to do so: Print(DoubleToStr(OrderOpenPrice(),Digits));

 
Ekburg:

Try to do this and see what OrderOpenPrice() really returns, maybe the reason is that you normalize the function with the Digits parameter and you see in the printer not what it really is.

It's the same without normalization, I need to subtract points from the opening price, if so the price is what I need, but then I get a type mismatch in IF(
Print(DoubleToStr(OrderOpenPrice(),Digits));
 
vadynik:

I need to subtract points from the opening price, and if so, the price is the one I need, but then I get a type mismatch in IF (

Do calculations in four digits. If accuracy is important to you, then put it back with the value of the last digit, as it is not changing during the calculations because of the nature of the calculations.
 
Ekburg:

Make calculations as for four digits, and if accuracy is important to you, then return it in place, with the value of the last digit that was earlier, because it does not change during the calculations, due to the specifics of calculations.
Normalization is needed only in Ordersend, orderclose etc. Well and still at comparison of real values and in printers specify any quantity of signs after a decimal point. But if you just write Print(whatever_double_value), it will usually print four decimal places. Therefore, the correct way to do this is to write
Print(DoubleToStr(OrderOpenPrice(),Digits));

As already mentioned, first convert double to string with specified number of decimal places and then print it into log using Print....
 
And if points are calculated, do not confuse them with points. Say double SPRED=Ask-Bid points, or even let double SPRED=(Ask-Bid)/Point points.
 
Sepulca:
And if points are calculated, don't confuse them with points. Say double SPRED=Ask-Bid points, or even double SPRED=(Ask-Bid)/Point points.


It's just a problem on the level as it seems to me))) OrderOpenPrice() is a double, but to see the real opening price I have to do a string?))

and to make a subtraction or addition again need to do a double of string, well, not nonsense, eh? Or I do not understand something)