Questions from Beginners MQL5 MT5 MetaTrader 5 - page 964

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Thank you for the example.
Could you please clarify... if I understood correctly.
With this=(datetime)OrderGetInteger. we are telling OrderGetInteger to take the explicitdatetimetype. ?
Does this rule apply to all functions that do not have an explicit type or do not match the type of the variable being assigned? Or is it just a special case?
I want to understand if this is a rule or just need to be remembered as a special case.
It is not a special case. If you write a value of a different type into a variable of one type, the compiler will warn you about it. And it is up to you to decide which variable to take data from.
In your case - when returning an explicit datetime-value from a function with the long type, of course, it is safe and you should explicitly specify the type of value you get from the function.
But if you take a double value into int-variable, then it is up to you to understand whether the data will not be lost by such an assignment. If you know for sure that the return value will fit in int, then specify int explicitly, if you don't know, then take it as a double variable.
This is not a special case. If you write a value of another type into a variable of one type, the compiler will warn you about it. And it is up to you to decide which variable to take data from.
In your case - when you return an explicit datetime-value from a function with the long type, it is of course safe and you should explicitly specify the type of the value you get from the function.
But if you take a double value into int-variable, then you must understand yourself that no data will be lost during such assignment. If you know for sure that the returned value will fit into int, specify int explicitly, if you don't know, take it into a double variable.
Thank you for your detailed reply. Got it.
(Good afternoon to all of you)))
I've mastered MT4, but MT5 .... I do not understand((( There are not many examples, and those that are not explain what I need.
Please advise how to use MT5 with some samples from MT4 code or give me some links to the indicators with similar cases.
1.
2.
3. I don't understand how to do element comparison with iMa handle... I know about structures!!! Tried it, but MT5 is not as clear unlike MT4...
The general differences of programming in MT5 are already understood! But I can't program yet (the dice don't add up)))))
It's important for me to LISTEN in my head to these parts and modules of MT5.... I understand the logic quickly in MT4, but MT5 only "cubes" ....
Thanks for the tips)))
Please change my robot's fix lot to % lot. Code in private.
Freelance.
(Good afternoon to all of you)))
I've mastered MT4, but MT5 .... I do not understand((( There are not many examples, and those that are not explain what I need.
Please advise how to use MT5 with some samples from MT4 code or give me some links to the indicators with similar cases.
1.
2.
3. I don't understand how to do element comparison with iMa handle... I know about structures!!! Tried it, but MT5 is not as clear unlike MT4...
The general differences of programming in MT5 are already understood! But I can't program yet (the dice don't add up)))))
It's important for me to LISTEN in my head to these parts and modules of MT5.... I understand the logic quickly in MT4, but MT5 only "dice"....
Thanks for the tips)))
First, read the documentation carefully. The section"Access to timeseries and indicators".
It should be clear how to get the time, "put" it in the structure, and then get hour and minute separately.
There is also CopyBuffer to get indicator values by its handle.
If you still have questions...
(Good afternoon to all of you)))
I've mastered MT4, but MT5 .... I do not understand((( There are not many examples, and those that are not explain what I need.
Please advise how to use MT5 with some samples from MT4 code or give me some links to the indicators with similar cases.
1.
2.
3. I don't understand how to do element comparison with iMa handle... I know about structures!!! Tried it, but MT5 is not as clear unlike MT4...
The general differences of programming in MT5 are already understood! But I can't program yet (the dice don't add up)))))
It's important for me to LISTEN in my head to these parts and modules of MT5.... In MT4 I understand the logic quickly, but MT5 only "cubes" ....
Thanks for the tips)))
If you need to compare several timeseries of one timeframe, work with an array likeMqlRates-> and useCopyRates to fill this array.
It is convenient to store the time in aMqlDateTime structure -> useTimeToStruct to convert the time fromdatetime toMqlDateTime structure.
Now your example 1 will look like this:
Question: does this cause errors or is it normal within the limits of one code or even one function?
(Good afternoon to all of you)))
I've mastered MT4, but MT5 .... I do not understand((( There are not many examples, and those that are not explain what I need.
Please advise how to use MT5 with some samples from MT4 code or give me some links to the indicators with similar cases.
1.
2.
3. I don't understand how to do element comparison with iMa handle... I know about structures!!! Tried it, but MT5 is not as clear unlike MT4...
The general differences of programming in MT5 are already understood! But I can't program yet (the dice don't add up)))))
It's important for me to LISTEN in my head to these parts and modules of MT5.... In MT4 I understand the logic quickly, but MT5 only "cubes" ....
Thanks for the tips)))
Working with indicators - usingMA Force code as an example
Step 1: on a global program level declare variable handle_iMA, which will store the indicator handle
Step 2: create an indicator in OnInit() and return thehandle_iMA variable
Step 3: make a request in OnTick() - copy a certain amount of data(count) from the indicator intoma[] array
Step 4: work with the indicator data array and compare its elements:
Question: does this cause errors or is it normal within the limits of one code or even one function?
It's better not to be confused and use one approach: either trade classCSymbolInfo or system functions like SymbolInfoXXXX.