Questions from Beginners MQL5 MT5 MetaTrader 5 - page 1226
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
That didn't work either.
What a hobgoblin likes kilometres of code...
Your problem can be solved in SIX lines of code, taking into account declaration of variables.
I hope you can figure out the signal variable.
О! It's working! Thank you, comrades, for the ideas!
But I had to tweak it a bit. It even got easier, without (true). Although I can't explain this complicated MQL logic).
That's how I implemented it:
I wonder why there is such a big code in MQL5 for position opening. Unlike MQL4. In 4 it's just one line. Can we cut it down? For example, can we remove the error handler?О! It's working! Thank you, comrades, for the ideas!
But I had to tweak it a bit. It even got easier, without (true). Although I can't explain this complicated MQL logic).
That's how I implemented it:
I wonder why there is so much code in MQL5 to open a position. Unlike MQL4. In 4, it's just one line. But here... Can you make it shorter? For example, can we remove the error handler?Use trade classes. And the code will be very short.
Example:
О! It's working! Thank you, comrades, for the ideas!
But I had to tweak it a bit. It even got easier, without (true). Although I can't explain this complicated MQL logic).
That is how I implemented it:
I wonder why there is such a big code in MQL5 for position opening. Unlike MQL4. In 4, it's just one line. But here... Can it be shortened? For example, can we remove the error handler?So, if you have in the condition
why do you need more checks for a new bar? Or is there an option that position will be closed at the same bar and the second opening should be prohibited?
О! It's working! Thank you, comrades, for the ideas!
But I had to tweak it a bit. It even got easier, without (true). Although I can't explain this complicated MQL logic).
That's how I implemented it:
I wonder why there is such a big code in MQL5 for opening a position. Unlike MQL4. In 4, it's just one line. But here... Can it be shortened? For example, can we remove the error handler?You know, long ago, when there was MQL4, people were indignantly saying that they hadn't been given lower-level access - so that they could do something in their own way.
Well, they did - now they gave access to OrderSend() in MQL4 - so to speak, they deployed its logic in MQL - so do what you want. But no - now I've got complaints that it's too complicated.
Complicated? No problem - give you trade classes in SB - they are almost the same as in MQL4 standard trade functions.
In MQL4 such classes are the trade functions. And in MQL5 - all with open access.
Take advantage of it.
You know, long time ago, when there was MQL4, people were indignantly saying that they didn't give them lower-level access - so that they could do something in their own way.
Well, they did - now they gave access to OrderSend() in MQL4 - so to speak, they deployed its logic in MQL - so do what you want. But no - now I've got complaints that it's too complicated.
Complicated? No problem - give you trade classes in SB - they are almost the same as in MQL4 standard trade functions.
In MQL4 such classes are the trade functions. And in MQL5 - all with open access.
Take advantage of it.
Docent, and Docent. Why are you so angry (today) ©
Docent, ah Docent. Why are you so angry (today) ©
Get in the ice hole...
So if you have a condition
why do we need to check for a new bar? Or is there an option that the position will close on the same bar and we should disallow a second opening?
Exactly right - there is an option to close the position on the same bar.
(Cut into the new wall. ) The "wall" is called breakeven.
This is how it was implemented in MQL4:
(I copied it somewhere I do not remember).
But here is how it is implemented in 5-PC. How do I do it?
I looked through the Trading Classes, I don't see it in there. But the thing is needed. What do the pros say?
How can I prevent trades from other charts from appearing on the chart?
Only the trades of the robot that is on the given chart.