Errors, bugs, questions - page 934

 
uncleVic:
That's the way it is.

Thank you so much for all your help! Everything is simple and nice )

I originally tried Event map but didn't understand it to the end, so I decided to overload OnEvent() myself...

P.S. It would be nice if in any code that comes with the terminal, or in its documentation there were some examples of using event map (from ON_EVENT to ON_EXTERNAL_EVENT) - it would be much easier to understand them. There are only ON_EVENT examples - Experts/Examples/Controls/ControlsDialog.mq5 and Indicators/Examples/Panels/PanelDialog.mq5 - at least I haven't found any other examples. And a search on the website, except for a few words in the article, didn't yield anything.

 
Rone:

Thank you so much for all your help! Everything is simple and nice )

Originally and tried Event map, but didn't understand it completely, therefore I decided to overload OnEvent() myself...

P.S. It would be nice if in any code that comes with the terminal, or in its documentation there were some examples of using event map (from ON_EVENT to ON_EXTERNAL_EVENT) - it would be much easier to understand them. There are only ON_EVENT examples - Experts/Examples/Controls/ControlsDialog.mq5 and Indicators/Examples/Panels/PanelDialog.mq5 - at least I haven't found any other examples. And a search on the website, except for a few words in the article, didn't yield anything.


1. Please. Please do not hesitate to contact me.

2. To add.

 
CTrade::OrderSend: buy stop 0.94 USDCHF at 0.93366 sl: 0.93016 tp: 0.94816 [invalid volume]

Why did I receive error 0.94 lot volume on USDCHF ?

This is an invalid volume or I did not have enough money to place this volume?

 
Konstantin83:
CTrade::OrderSend: buy stop 0.94 USDCHF at 0.93366 sl: 0.93016 tp: 0.94816 [invalid volume]

Why did I receive error 0.94 lot volume on USDCHF?

This is an invalid volume or I did not have enough money to place this volume?

What is the step of volume in the tool settings? 0.10 or 0.01 of lot? If it is 0.10, then everything is correct - invalid volume
 
Renat:
What is the volume step in the tool settings? 0.10 or 0.01 lot? If 0.10, you are correct - wrong volume

demo server from metaquotes, you have 0.01 step.

the lot is checked



CSymbolInfo       Exp_Symbol_Info;              // symbol info object

...
double CBaseTrade::GetCorrectLot(double pLot)
 {
      double   dLot   = pLot;
      double   dLotMin   = Exp_Symbol_Info.LotsMin();
      double   dLotMax   = Exp_Symbol_Info.LotsMax();
      double   dLotStep  = Exp_Symbol_Info.LotsStep();
    
      dLot=dLotStep*NormalizeDouble(pLot/dLotStep, 0);
 
      if(dLot < dLotMin) dLot=dLotMin;
 
      if(dLot > dLotMax && dLotMax !=0) dLot=dLotMax;

 
  return(dLot);
 }

 

Print out the volumevalue to 4-8 digits, please.

Clear error of not rounding to the second digit here:

dLot=dLotStep*NormalizeDouble(pLot/dLotStep, 0);
 
Renat:

Print out the volume value to 4-8 digits, please.

A clear error of not rounding to the second digit here:

yes but why is there no rounding?

Let's say the lot step is 0.01

Input lot 2.111

result = 0.01 * NormalizeDouble(2.111/0.01)=0.01*NormalizeDouble(211.1)=0.01*211=2.11

Or there are brokers where the lot increment is 0.25, you can not just round the result to the 2nd sign.

Suppose the lot step is 0.25

Incoming lot 2.3

Result = 0.25 * NormalizeDouble(2.3/0.25)=0.25*NormalizeDouble(9.2)=0.25*9=2.25


No problem in the tester. Just got this error a couple of times today in the demo.

Is the volume step from CSymbolInfo class normalized?

 

Please advise!

How to change the background colour of currency pairs in the market overview

Or remove the colour altogether!

Thanks in advance!

 
Konstantin83: result = 0.01 * NormalizeDouble(2.111/0.01)=0.01*NormalizeDouble(211.1)=0.01*211=2.11
The product of two double numbers is an unnormalized number. 0.01*NormalizeDouble(211.1)=0.01*211.***********=2.11*************
 
Konstantin83:

Yes, but why isn't it rounded?

Because the result of mat operations of the highest-normalised values is not a normalised number.

That's why it's a place of error.

Документация по MQL5: Преобразование данных / NormalizeDouble
Документация по MQL5: Преобразование данных / NormalizeDouble
  • www.mql5.com
Преобразование данных / NormalizeDouble - Документация по MQL5
Reason: