Page 1 of 502 1 2 LastLast
Results 1 to 10 of 11

Thread: 3 Programming Function meanings?

  1. #1

    3 Programming Function meanings?

    Hello
    Can Someone kindly explain in easy terms with an example these issues:

    1) What Does Sleep(3000) operator(or whatver u call it) do in betwen codes.
    I have seen it many times in between if statements in many codes!

    Two) Exactly what exactly does break; Function do?

    3)What various types of Extern varaiables are available? Such as Strings, double and their usage?

    4) Can MQL5 will be quite different from MQL4? I assume its released. . .any guess how different?

    If possible, can somebody link to/post/pm some simple information abt Understanding, or even coding(as of now) MQL4.
    I have lot of complied stuff/links etc.. . But time spent doesnt really fix the simple information I want (as of today)

    Thanks in advance!
    Regards

  2. #2
    Can I use the sleep command?

    If not how would I make the EA sleep after the condition has been fulfilled?



    Inserted Code if(DropProtection ! =0) complete = OrdersTotal(); for(I = total - 1; I gt;= 0; I--) (OrderType() == OP_SELL)) if (((type == _OP_BUY) (iOpen(NULL,PERIOD_M15,1) gt; iClose(NULL,PERIOD_M15,1)) (iOpen(NULL,PERIOD_M15,1)- iClose(NULL,PERIOD_M15,1) gt;(DropProtection*0.0001))))//Tested Yes //if(((type == _OP_SELL) (iClose(NULL,PERIOD_M15,1) gt; iOpen(NULL,PERIOD_M15,1)) // (iClose(NULL,PERIOD_M15,1)- iOpen(NULL,PERIOD_M15,1) gt;(DropProtection*0.0001))))// Tested No if(PrintComments) Print(Drop Protection closed all transactions.) ; glOrderClose(); Sleep (SleepAfterDrop * 3600000);
    It shuts the Trade therefore it gets to the glOrderClose() but it reopens a different immediately.

    If someone could show me the way to place this sleep command so it functions, I'd really appreciate it.

    thanks

  3. #3
    Okay ForexSaint I will take a try here.

    1. Sleep, Is a pause statement in the current operation. It can be used for various reasons and normally at a loop.
    Think of it like the pause button in your dvd player. You stop the movie in its current place to go make popcorn and then comeback to it. My wife adores this she is able to turn a two hour movie in an all night adventure...

    Say you have a trade to get a buy in your ea, however you do not need to have the buy performed right away. You can use the sleep function to pause the buy and then have it go back to your buy parameters. So it'd sleep(60) and then after that time go back to the commerce function. There are different reasons for its use, however this is the type of thing.

    2. Break, Is a change statement used mostly with the switch function. Say when you have some kind of change in your commerce or indior you would use the switch function and then make a case statement for parameters to be used due. The break statement would then inform the fisrt case to stop functioning and guide it. I have also seen some programmers use it in the end of each function they code., prior to going onto the next function in the indior, it will not hurt.

    Best example I can think of here is a shi channel. If you got one take a peek inside and you will notice the switch. What it does is creates a switch for the interval chart you're considering, and lets it use parameters that are different for each chart period of time. Basically it tells the channel to utilize fractal counts on each chart interval. (I've deleted that function in my Shi indior).

    3. Variables can turn into a factor. There are many sorts, extern int usually names a parameter say you need spacing. You'd something like . .extern int y_spacing =10. . So you want.
    Extern string. . You might be making a remark . . Extern string note_1 = y_spacing is motion or maybe you wish to call a font type..extern string font_type=Arial

    You can extern bool to call a true or false function..extern bool change_color =Authentic

    you might have extern color=Green

    Double is used as a smoothing process, state you're making a calculation that emerges at a fraction. It will be smoothed by Double's use . You see it in alot of areas it does not need to be, however it does not hurt if it is there. I guess it is simpler to use it in place of to find out whether it is really needed.

    You can also have global variables that will be in the beginning and used throughout the process and then you can have local variables that can be used inside a particular function only.

    Best thing to do is open up some codes and just follow them from start to finish and you will start to see the light, though my light does turn into a dim flashlight at times, it can be fruing to code but then again fun as it eventually works.

    You can begin with the simple guide here http://book.mql4.com/. I do believe there is also a guide oncliqforexin case you utilize search. There is also another one from forex-tsd. Com... You can also look up my posts and somewhere you will find I've submitted the first course guide on ff.

    As for mq5, as far as I have read it hasn't yet been published as of yet. It keeps becoming a delay for whatever reason. So that they can get used to it, it is assumed to be set out for programmers initially. Then eventually the brokers will start to implement the platform. . I would guess a year off until traders view it.

    Post your questions you will find some quite generous and knowledgeable folks ( more than me) Hanover, Zen Loew, Ronald to list a couple here that help, as time allows.

    Great Luck
    Tom

  4. #4
    Thank you twj1usa to your time explaining all
    yes coding is fruing initially. . .Yes I will look into that link!
    Thanks once more for explaining like that!

    Best Regards

  5. #5
    I will elaborate a bit on the usage of the break statement.

    It is mainly utilized to exit a conditional loop before it's reached the end of all its cycles (aka iterations).

    Not only in switch constructions, you may also use it inside a for loop, or a while loop.

    Within the MQL context, the most common usage of break statement inside a loop is when you want to look for a loion on the chart (a particular candle) that matches with a specific condition, and you just don't quite know where.

    Let us assume you think that loion you're trying to find is someplace within the previous 100 candles. But of cos you're not likely to allow it loop through 100 times even when the conditional was met in the first couple of candles.

    Here's a code example of how I'm looking for the most recently past candle where the stochastic is above 80.

    Inserted Code extern int Stoch_Kperiod=8; extern int Stoch_Dperiod=3; extern int Stoch_Slowing=3; extern int Stoch_Method=MODE_SMA; extern int Stoch_Price=0; double Get_Stochastic_Value(int index) return ( iStochastic(NULL, 0, Stoch_Kperiod, Stoch_Dperiod, Stoch_Slowing, Stoch_Method, Stoch_Price, MODE_MAIN, index) ); int start() int overbought_candle_index = 0; for (int I = 1; I lt;= 100; I ) if (Get_Stochastic_Value(I) gt; 80) overbought_candle_index = Id; rest; Print(The final recognized overbought candle is in position: , overbought_candle_index);
    so assuming at the second iteration, when I=2, the stochastic is above 80, there is no need to experience the rest of the 98 cycles, the break statement will exit that whole for loop. This helps us get the EA or indior to work and reduce runtime processing.

    Once you've known the break statement. Its probably a fantastic idea to look at the continue statement.

    regards,
    Zen

  6. #6
    Thanks for taking your time zen to explain it!
    Like I am new to MQL4 programming... got the fundamentals. . .of over.... Though some matters went abv mind
    Any way Cheers

  7. #7
    Quote Originally Posted by ;
    As I am new to MQL4 coding... got the basics. . .of over.... Though some things went abv mind
    Any way Cheers
    Your posting seems like you are generally not experienced in coding in any way. This (for itself) isn't anything you must worry about since 95% of people using computers (in an effective manner) dont use them to plan them but rather use other people's apps to get their job completed.

    However: for having the ability to comprehend the cryptic words written in this strange looking alien speech you see if you open the Metaeditor and also consider the code of some Expert Advisor or Indior that you want to have an idea about the concept of programming per se, and this may only be achieved by learning what it really means to plan a machine and it may only be learned by actually trying to get it done.

    Machine in this context may be anything, it may for example mean a microprocessor and programming it would be done in assembler, it might alo mean Microsoft Excel and programming it would mean either putting formulations to spreadsheet cells or/and writing Visual Basic macros containing commands which should be executed at certain occasions in a specific order to make it [Excel, the machine] perform complied items it wouldnt be able to perform without your carefully crafted app. The machine may be Metatrader and programming it would be writing Scripts, Experts and Indiors in mql4 that's the language of the machine, exactly like assembler is that the terminology of this microcontroller and VB and formulations would be the terminology of Excel.

    Learning to program means loe such a machine which may be easily programmed. A beginner shouldn't use a system for which writing appliions is a pain even for seasoned developers. You should begin learning all these theories in an environment where it is easy to create, run and debug your apps, where the system will tell you what it didnt know (and why) in a clean and friendly manner. An environment where you can find out whats happening if something doesnt work as anticipated. Attempting to learn programming Metatrader without ever having programmed anything must be a fruing experience.

    A seasoned programmer knows egies how to narrow down the cause of an error even in unclear circumstances, he's prepared for all sorts of things that could go wrong, sometimes he can also smell it before it occurs, just because of his rich experience.

    You really ought to try to begin learning programming using something which is easy for beginners, powerful enough to perform even more complied and helpful stuff and through providing these properties is motivational and enjoyable.

    (I'll leave room for other posters here in order to suggest appropriate environmants, I strongly suggest Python. I dont recommend anything using C in the name of itbecause also the syntax of C and the syntax of mql is doesnt. You can attempt to learn C/C once you have successfully discovered programming and have 10 years period to waste, I would rather learn practical helpful languages like Python, Ruby, Java, should you love mathematics and statistics you need to learn R and if you truly want to go exceptionally low level and want to generate small efficient machine executables (writing dlls to get metatrader) know Pascal [FPC]. There is not any reason to ever waste any moment of your lifetime for C/C )

    After successfully learning the theories of programming and having practically programmed some thing for a while you can attempt to look at metatrader programming and everything will immediately be *much* much clearer and you'll be completely defenceless whilst trying to fight this beast.

  8. #8
    ForexSaint, have you try to put your cursor/caret at the center then press F1?

  9. #9
    @7bit
    Thank you to get a thorough reply. . .Yes its fruing for certain!

    @AdamnN
    Thanks for that info

    @Asgard
    Hope some1 replies that question. . .here is a bulge for you

    Regards all

  10. #10
    Quote Originally Posted by ;
    asgard, may I ask are you currently utilizing this reside or in egy tester... Sleep won't function in the tester I believe.
    Actually it does works in tester, however secured

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
This website uses cookies
We use cookies to store session information to facilitate remembering your login information, to allow you to save website preferences, to personalise content and ads, to provide social media features and to analyse our traffic. We also share information about your use of our site with our social media, advertising and analytics partners. Read more.