Ive come across a warning when writing an expert advisor that I don't understand. I have some ideas on why I'm getting it but was hoping someone could clarify. I'm getting the warning possible loss of data due to type conversion warning when compiling the code attached. I know this error is normally caused when trying to use the wrong data type with the normaliseDouble function but im passing a double type variable into it in onTick. I'm also not sure if the warning is something to do with the pass by reference element and possibly my improper use of it?
This is the proper way to adjust the Volume (lots) for an Order (don't use NormalizeDouble) :
void lotSizeChecks( double &lotSize ) { double volumeMinimum = SymbolInfoDouble( _Symbol, SYMBOL_VOLUME_MIN ), volumeMaximum = SymbolInfoDouble( _Symbol, SYMBOL_VOLUME_MAX ), volumeStep = SymbolInfoDouble( _Symbol, SYMBOL_VOLUME_STEP ); lotSize = fmin( volumeMaximum, // Prevent too greater volume fmax( volumeMinimum, // Prevent too smaller volume round( lotSize / volumeStep ) * volumeStep ) ); // Align to Step value }
Also, the reason you were getting a "possible loss of data", was because of the "roundingDigits" argument which should have been of the "int" type and not a "double" (for NormalizeDouble).
For warnings and errors, you should always look at the line number, and column position, to identify the problem.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Ive come across a warning when writing an expert advisor that I don't understand. I have some ideas on why I'm getting it but was hoping someone could clarify. I'm getting the warning possible loss of data due to type conversion warning when compiling the code attached. I know this error is normally caused when trying to use the wrong data type with the normaliseDouble function but im passing a double type variable into it in onTick. I'm also not sure if the warning is something to do with the pass by reference element and possibly my improper use of it?