Hello.
Started studing MQL5 3 days ago. My first language. Been looking at the Reference a lot. Some explanations there are a bit vague, so I still dont fully understood some concepts.
Return operator: The return operator terminates the current function execution and returns control to the calling program.
What is the "calling program"? Is it the "On Tick()" function? When return operator is activated, it returns control to On Tick() and then On Tick() proccess the next function in the line until the end of all functions?
And about loop: lets say
for(i=0;i<rates_total;i++).
rates_total is the number of bars in the chart, correct? So it will grow every timeframe cycle. Lets say it is 100 bars now. The On Tick() function will be processed, the i will arrive at 100 and the loop will stop. Ok.
Then a new bar is created. rates_total is now 101. When On Tick() starts the loop again,will the i be ZERO again (and the loop will work again until 101) or will it still be 100 (and the loop will pass only one more time to reach 101)?
I know i can use prev_calculated to not have to proccess everything again, but i just want to understand how loop works.
For now thats the more pressing doubts. I really apreciate any help, any indications of tutorials. Thanks!!
I think you need to start with the basics. Basically if someone explains, you can not evaluate the explanation.
When studying Mql5 it is best to use the Mql5 documentation, using Mql4 will confuse you even more, because it is not the same.
Guin: Started studing MQL5 3 days ago. My first language. Been looking at the Reference a lot. Some explanations there are a bit vague, so I still dont fully understood some concept ...
Since you are still very, very new to programming, maybe you should start with a few books on coding/programming in general first, then move onto MQL5 with the help of the following books:
Forum on trading, automated trading systems and testing trading strategies
Sergey Golubev, 2017.09.16 05:48
Expert Advisor Programming for MetaTrader 5
This book will teach you the following concepts:
- Learn the basics of MQL5, including variables and data types, operators, functions, event handlers, and object-oriented programming.
- Place, modify and close market and pending orders.
- Calculate, verify and add stop loss and take profit prices to an open position.
- Add a flexible trailing stop and/or break even stop to your strategy.
- Manage your trade risk with money management.
- Use pending orders to scale in and out of positions.
- Use price, time and indicator data in your expert advisors.
- Control program execution by trading on new bar open, and add flexible trade timers to your strategies.
- Walk through the creation of several basic trading strategies from start to finish.
- Inform the user with dialog boxes, email alerts, mobile notifications and sounds.
- Draw trend lines, arrows and text labels on the chart.
- Read and write data to CSV files.
- Learn the basics of creating indicators, scripts and libraries in MetaEditor.
- Debug, test and optimize your trading strategy.
- And much more!
Whether you’re an experienced programmer moving from MQL4, or a novice just starting with MQL5, this book will give you the foundation to quickly program fully-featured and robust trading systems.
Forum on trading, automated trading systems and testing trading strategies
Something Interesting to Read March 2017
Sergey Golubev, 2017.02.27 10:50
MQL5 programming language: Advanced use of the trading platform MetaTrader 5: Creating trading robots and indicators
by Timur MashninDevelopment of indicators and advisors using the MQL5 programming language for the MetaTrader 5.
I think you need to start with the basics. Basically if someone explains, you can not evaluate the explanation.
When studying Mql5 it is best to use the Mql5 documentation, using Mql4 will confuse you even more, because it is not the same.
Fernando Carreiro:
Since you are still very, very new to programming, maybe you should start with a few books on coding/programming in general first, then move onto MQL5 with the help of the following books:
Thanks guys. Just bought the "Expert Advisor Programming for Metatrader 5" book and im going to start reading now. Hope it get rid of my doubts!
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello.
Started studing MQL5 3 days ago. My first language. Been looking at the Reference a lot. Some explanations there are a bit vague, so I still dont fully understood some concepts.
Return operator: The return operator terminates the current function execution and returns control to the calling program.
What is the "calling program"? Is it the "On Tick()" function? When return operator is activated, it returns control to On Tick() and then On Tick() proccess the next function in the line until the end of all functions?
And about loop: lets say
for(i=0;i<rates_total;i++).
rates_total is the number of bars in the chart, correct? So it will grow every timeframe cycle. Lets say it is 100 bars now. The On Tick() function will be processed, the i will arrive at 100 and the loop will stop. Ok.
Then a new bar is created. rates_total is now 101. When On Tick() starts the loop again,will the i be ZERO again (and the loop will work again until 101) or will it still be 100 (and the loop will pass only one more time to reach 101)?
I know i can use prev_calculated to not have to proccess everything again, but i just want to understand how loop works.
For now thats the more pressing doubts. I really apreciate any help, any indications of tutorials. Thanks!!