Learning and writing together in MQL5 - page 6

 

Gentlemen, please comment:

...
enum varOfInt
{
Duple= 2,
Triple = 3,
};
input varOfInt Var = Duple;
...

int OnInit()
{
...
double tmp;
tmp = 0.531 * Var // tmp == 0!!!
tmp = 1.531 * Var // tmp == 2!!!
...
numbers (0.531; 1.531) are arbitrarily specified.
Thank you.

 

Try it like this

tmp = 0.531 * int(Var)   // tmp == 0!!!
tmp = 1.531 * int(Var)   // tmp == 2!!!

 
vdv2001 писал(а) :

Try it like this

Thank you for your attention. This problem is solved, but since this is a discussion thread, I would like the authors to look at the type conversion.
ENUM - integer (integer 4-byte data type).
 

Checked, the given expressions are calculated correctly.

What version of compiler and terminal do you have and how did you measure the results of the expressions?

 
mql5 писал(а) :

Checked, the given expressions are calculated correctly.

What version of compiler and terminal do you have and how did you measure the results of the expressions?

...
double tmp = 0.531 * Var; // 1.062
double tmp = Var * 0.531; // 0!!!
The constant 0.531 is taken arbitrarily. It can be replaced by double variable.
Thank you for your attention.

 
FlyAgaric:

...
double tmp = 0.531 * Var; // 1.062
double tmp = Var * 0.531; // 0!!!
The constant 0.531 is taken arbitrarily. It can be replaced by double variable.
Thank you for your attention.

Thank you for your message. The error has been corrected, please wait for an update.
 

Is it possible to set a trailing stop programmatically?

Or is it necessary to tighten SL with every tick through order modification?

 

Can you advise a beginner how to catch an event in the EA whentp or sl is triggered.

Thank you in advance.

 
Документация по MQL5: Основы языка / Функции / Функции обработки событий
Документация по MQL5: Основы языка / Функции / Функции обработки событий
  • www.mql5.com
Основы языка / Функции / Функции обработки событий - Документация по MQL5
 
sergeev:
OnTrade function

Thanks....But...I'm a very beginner:)))