Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 206

 
Alexey Viktorov:
Have you tried normalising to 2 digits?

And normalise what? The current price, and then compare..... with what?

I don't knowwhat you're talking about
.

 
Vyacheslav Kornev:

I have a mac book. I can't even copy from the meta-editor

Decipher the values and type of variables in the second case.
 
Victor Nikolaev:

Decipher the values and type of variables in the second case.





 
mila.com:

Hello.

Please help to fix the fact that the current price crosses any round price, not a specific one as in the example.

For example:

or

static double prevBid=EMPTY_VALUE;

if (prevBid!=EMPTY_VALUE && prevBid<=levelPrice && Bid > levelPrice ) {

   /// цена пересекла уровень снизу вверх

}

prevBid=Bid;

 
mila.com:

Hello.

Please help to fix the fact that the current price crosses any round price, not a specific one as in the example.

For example:

or

//===============================================================================================
//---------------------------- Возвращает ближайший круглый уровень ----------------------------+
//===============================================================================================
double GetUniversalLevel(int ne=100, string symb="0") {
 if(symb=="0") symb=Symbol();
 static double LastBid;
 double _Level=0, PriceStep=0, bid=0, point=0;
 bid=SymbolInfoDouble(symb,SYMBOL_BID);
 point=SymbolInfoDouble(symb,SYMBOL_POINT);
  if(LastBid<point) LastBid=bid;
   PriceStep=ne*point;
   _Level=MathRound(bid/PriceStep)*PriceStep;
  LastBid=bid;
  return(_Level);
 }

Calling

//double R_Level = GetUniversalLevel(100, Symbol()); // круглые 100
double R_Level = GetUniversalLevel(50, Symbol()); // круглые 50
// дальше надеюсь разберётесь
Comment(R_Level );
 
Vyacheslav Kornev:






Let's try to substitute values in the formula

if (St==7)
  {
     double Pris_Lin=0;
     Lots0=(L(OP_SELL)+(Bid-0)/10*Lotsc;  
     // Для Евро 
     // Lots0=(L(OP_SELL)+(1.10890-0)/10*0.1;
     // Lots0=(L(OP_SELL)+0.0110890;
     
     .....................
     if (Op_Pr>=Bid)
        Lots0=L(OP_SELL);
     if (Lotsc>Lots0) Loys0=Lotsc;
  }

If the lot size is rounded according to the requirements of the DC, the lot will either increase by 0.01 or remain unchanged.

But there is no rounding, so there is just an error - Invalid lot volume.

 
Victor Nikolaev:


Let's try to substitute values in the formula

If the lot size is rounded according to the requirements of the DoC, the lot size will either increase by 0.01 or remain the same.

But there is no rounding, so there is just an error - Invalid lot volume.


Actually, Pris_lin is a price, and it is never equal to zero
 
Vyacheslav Kornev:

Actually Pris_lin is a price and it is never zero.

Look carefully at the code you posted on the previous page.
 
Victor Nikolaev:

Look carefully at the code you posted on the previous page.

Yeah, I can see that. That's why I'm asking for help.
 
Victor Nikolaev:

Look carefully at the code you posted on the previous page.

I need to take the price and then modulo calculate the difference and that's it( Bid - Pris_lin)
Reason: