Menu
Brokers
MT4 Forex Brokers
MT5 Forex brokers
PayPal Brokers
Skrill Brokers
Oil Trading Brokers
Gold Trading Brokers
Web Browser Platform
Brokers with CFD Trading
ECN Brokers
Bitcoin FX Brokers
PAMM Forex Brokers
With Cent Accounts
With High Leverage
Cryptocurrency Brokers
Forums
All threads
New threads
New posts
Trending
Search forums
What's new
New threads
New posts
Latest activity
Log in
Register
Search
Search titles only
By:
Search titles only
By:
Menu
Install the app
Install
Reply to thread
Forums
Trading Platforms
MetaTrader 4
Need favour understanding how to loop through candles - how cycles work in MQL4
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Message
[QUOTE="Enivid, post: 184111, member: 1"] Operator [ICODE]for[/ICODE] initiates a cycle. For example, you want to print all numbers from 1 to 10. The straightforward way to do that is to just put 10 lines of [ICODE]Print()[/ICODE] functions: [CODE=mql4]Print("1"); Print("2"); // And so on... Print("10");[/CODE] But it is blunt and inefficient. Imagine if you wanted to print all numbers from 1 to 1,000,000? So in programming, you have cycles to repeat actions multiple times. Using a cycle with a [ICODE]for[/ICODE] operator, you can print the numbers from 1 to 10 much easier: [CODE=mql4]for (int i = 1; i <= 10; i++) Print(i);[/CODE] When the cycle starts, the variable [ICODE]i[/ICODE] is assigned the value of "1". On each iteration of the cycle, the command [ICODE]Print(i)[/ICODE] is executed. At the end of each iteration, the command [ICODE]i++[/ICODE] is executed ([ICODE]i++[/ICODE] is the same as [ICODE]i = i + 1[/ICODE]). When i gets to "11", the cycle is finished - before it gets to [ICODE]Print("11")[/ICODE]. I hope this helps. [/QUOTE]
Insert quotes…
Verification
Post reply
Top
Bottom
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.
Accept
Learn more…