MQL4 Programming Tutorial 1.04 - Functions

Поділитися
Вставка
  • Опубліковано 5 лис 2024

КОМЕНТАРІ • 68

  • @thomasswenddal772
    @thomasswenddal772 3 роки тому +11

    I'm enjoying the way you rather verbally process your thought process as your coding and explaining. That is the way many of us consolidate an idea to it's best result. Keep up the fine work. Thanks!

    • @toolkitfortraders
      @toolkitfortraders  3 роки тому +1

      That's a great point, some Zoheb OGT mentioned to me. I'm thinking of doing a live full EA coding session. Where I'll talk through everything I do.

  • @OneGlanceTrader
    @OneGlanceTrader 3 роки тому +17

    You should do a live classroom base "Let's Build An EA Together" - I would be first to join!

  • @jimmi7402
    @jimmi7402 Рік тому +1

    As your previous instructional video... Great job!! Thanks for posting these lessons

  • @fogmaninfogland2630
    @fogmaninfogland2630 3 роки тому +2

    Great...Great...Great I have finally started to understand mql4 coding. I have gone to the mql4 web site been totally confused. Looked all over the youtube site and tried to follow other sites that were trying to explain mql4 but never could get it. Until now! Thanks so much and please keep up the good work.

  • @JohnSmith-pd4mf
    @JohnSmith-pd4mf 3 роки тому +2

    Thanks Alistair. I am playing catch up, and writing notes like a school boy alongside the practical. I am now at the stage where I need to re-watch the videos. That didn't take long... Lol. Determined to dis-prove that ‘old dogs’ proverb!

  • @RobChristensen
    @RobChristensen Рік тому +1

    For those who are watching after March 2023, the Normalized function seems to refer to the number of integers in the double including both sides of the decimal place. I put in a 1 and it worked.

  • @ilmudunia3142
    @ilmudunia3142 2 роки тому +1

    This is a good revision on my general coding knowledge about function and variable. I can't really grasp the functions functionality before. I guess, looking it as a factory that receive raw materials to produce an output, kind of make sense.
    Thank you for the simple explanation.

  • @JohnSmith-pd4mf
    @JohnSmith-pd4mf 3 роки тому +2

    OK, still playing catch up and I haven't watched lesson 5 yet but here is what I did to lose the decimal places: I changed "double point_spread;" to "int point_spread;" It worked and I feel stupidly chuffed with myself! Haha! Although I see from another viewer this wasn't the solution, it's the first time something clicked and I had the confidence to tinker. Cheers!

    • @toolkitfortraders
      @toolkitfortraders  3 роки тому +3

      Int is a good idea as it has no decimals. But it's the joy of coding there's many ways to get it right, you can be creative.

  • @ROHITBHAGAT-eq6jk
    @ROHITBHAGAT-eq6jk Рік тому +1

    thanks
    a lot was searching this kind of videos for 1 year lol

  • @mahmoudasal9863
    @mahmoudasal9863 Рік тому

    You made it very clear and simple ... thank u so much 👏

  • @lj9720
    @lj9720 3 роки тому +1

    You are doing an amazing job man TY very much for the effort and everything. Your website is really cool and easy to acces too.

  • @justinb217
    @justinb217 3 роки тому +3

    great educational video as always

  • @thiphuonguyentran6532
    @thiphuonguyentran6532 3 роки тому +11

    Here the solution for your problem for the Normalize :
    point_spread = NormalizeDouble(point_spread, 0);

    • @toolkitfortraders
      @toolkitfortraders  3 роки тому +2

      Winner winner chicken dinner!😀

    • @stevenjohnstone5833
      @stevenjohnstone5833 3 роки тому

      All you are teaching is how to create confusion. If you make an error you should correct it. Not just leave it unresolved, which gives the impression that you do not know too much.

    • @olakunle5139
      @olakunle5139 2 роки тому +2

      @@stevenjohnstone5833 Go away

  • @junjun2341
    @junjun2341 3 роки тому +2

    Very good I hope I can use the EA that creates by you and learn how is EA work from your code.

  • @j.vincent3801
    @j.vincent3801 Рік тому +2

    Question, pBid and pAsk were never defined or given values or anything, how does the computer know to use the Ask/Bid prices from using pAsk and pBid instead of plain Ask and Bid?

    • @toolkitfortraders
      @toolkitfortraders  Місяць тому

      When you call the function you put in your parameter values then, in MQL4 you can use the inbuilt variables for bid and ask and put them into your function.

  • @Heissuma
    @Heissuma 7 місяців тому

    The lesson are great, i learned a lot
    2024 you video is till helping people ❤
    But i have encountered a problem
    I input _point but there is no suggestion and it did not change colour but remain black
    Why please

  • @76jmcc
    @76jmcc 3 роки тому +1

    Thank you very much by the course

  • @whathuh6965
    @whathuh6965 3 роки тому +4

    @15:50, that's not a complete function even if you include the p variables. It will return compilation errors "Undeclared Identifier" for pAsk and pBid, and "Void function returns a value". I must commend you for teaching, but please ensure you fact check your examples prior to uploading content.

  • @danilopartoriza8038
    @danilopartoriza8038 2 роки тому +2

    In Line 51, it should be
    current_spread = current_spread/_Point;
    then Line 52 should be
    point_spread = NormalizeDouble(current_spread,0);
    void OnTick()
    {
    //Calculate and display the current spread
    double current_spread;
    current_spread = CalculateSpread(Bid,Ask);
    string spread_message = "The current spread is: ";
    Comment(spread_message,current_spread);

    }
    //+------------------------------------------------------------------+
    double CalculateSpread(double pBid, double pAsk)
    {
    // create a spread variable, and give the bid ask spread as a value.

    double current_spread = pAsk - pBid;
    //divide by _Point variable, to give spread in points
    double point_spread;
    current_spread = current_spread/_Point;
    point_spread = NormalizeDouble(current_spread,0);
    return point_spread;
    }

  • @GoAndStay
    @GoAndStay Рік тому

    Really enjoy the course. Is there a basic programming course you could recommend? For instance, at 18 min you talk about functions and giving the inputs (pAsk) and sometimes leaving it blank. I would like something that will explain the difference to me. And I assume the principles are the same over almost all programming languages.

    • @Letsgrowtogethertraders
      @Letsgrowtogethertraders 6 місяців тому +1

      I don't really understand the question you are trying to ask but if the small p is confusing you he said the is no need for you to write it. It's just a way for him to tell that those are just inputs parameters so that he does confuse it along the way. The small p stands for parameters which is the input parameters sir.
      I think your confusing is cleared or atleast tried to be cleared.
      Am new to programming so don't be so shocked liked why a response after a whole year am new and am inspired to learn and make money so that I can teach others two.
      😅😅

  • @axtrion888
    @axtrion888 3 роки тому +1

    Just curious, why did you do the illustration right to left and not left to right?

  • @midnightchart
    @midnightchart 2 роки тому +1

    2022 and love it

  • @sedeghosiguian7026
    @sedeghosiguian7026 Рік тому +1

    What I want to do or need to do if ... buy volume 1rst buy =0.01,2 buy=0.01. If loose buy=0.2. And 5 buy =0.2,10buy=0.2, 15 buy =0.2. Buy= 0.01 but if loose = 0.2

    • @toolkitfortraders
      @toolkitfortraders  Місяць тому +1

      You need to keep track of the number of trades in a variable and add to it if a trade is a loser.

    • @sedeghosiguian7026
      @sedeghosiguian7026 Місяць тому +1

      But,how to do it?

    • @toolkitfortraders
      @toolkitfortraders  Місяць тому

      Im not sure I understand what you are trying to do. Can you explain again?

    • @sedeghosiguian7026
      @sedeghosiguian7026 Місяць тому

      0.01, then 0.01,then 0.01 then 0.01 then 0.05. But if it loose buy 0.2.. then 0.01,then 0.01.

  • @terryrich4285
    @terryrich4285 8 місяців тому +1

    Very new to coding so probably a newb question but.. why would you create a function with a "void" output? Seems to defeat object of a function

    • @toolkitfortraders
      @toolkitfortraders  Місяць тому

      Sometimes you just want to do an action, without getting anything back. You use a function to open a trade for instance and not return the ticket or another function to create a button on the chart, for these you may decide you don't need to capture the return. As you'll practice you'll find examples of this...

  • @williamjunior7304
    @williamjunior7304 3 роки тому +3

    Hello I dont know if you still reply to comments of old videos or even if you can see them, but i think i found the solution to the reason your code didnt work as planned. I havent watched the next video so as i type this I dont know if you solved it there. If you can please tell me if I got it right.
    void OnTick()
    {
    //---
    double current_spread;
    current_spread = Calculatespread(Bid, Ask);
    string spread_message = "The Spread on this pair is: ";
    Comment(spread_message,current_spread);
    }
    double Calculatespread(double pBid, double pAsk)
    {
    double currentspread = pAsk - pBid;
    double point_spread;
    //convert the spread value to points
    point_spread = currentspread/_Point;
    //remove decimal point from the currentspread.
    double no_decimalspread;
    no_decimalspread = NormalizeDouble(point_spread,0);
    return no_decimalspread;

    }
    Ps: Im really enjoying the course so far. Thanks.

    • @toolkitfortraders
      @toolkitfortraders  2 роки тому +3

      Hey that looks like it'd work, does it? That's the cool thing about coding, it's actually quite creative and there is not one solution. The fact you've done some research and had a go is really cool!

    • @williamjunior7304
      @williamjunior7304 2 роки тому

      @@toolkitfortraders Hey, Yes it does work. Thanks for the reply. I moved on to the book 'Expert Advisor Programming' by Andrew Young and Finished it, I Still go back to reference it when I'm stuck on a coding problem. I just want to thank you for your videos. Coding Expert Advisors is really fun and challenging and it has reignited my passion for Trading. Please resume creating videos, They help more than you know.

  • @benfox7237
    @benfox7237 3 роки тому +2

    Is there a reference somewhere for the built in functions and variables in MQL4?

    • @benfox7237
      @benfox7237 3 роки тому +1

      Nevermind found it! docs.mql4.com/

    • @toolkitfortraders
      @toolkitfortraders  3 роки тому +2

      @@benfox7237 you got it. It can be a bit confusing sometimes, the terminology is not always consistent and the explanations are sometimes short. If you have any questions, lmk.

  • @hoseinharami1630
    @hoseinharami1630 Рік тому +1

    Thanks a lot

  • @youtraders
    @youtraders 2 роки тому +1

    here I am still wondering why the ask - bid variable is the opposite

  • @RianHidayat-cz7yi
    @RianHidayat-cz7yi 8 місяців тому +1

    how about time? what is code if I want to the MT4 open position every only at 21:00 my pc time?
    where i have to store data? double? int? or string?

    • @toolkitfortraders
      @toolkitfortraders  Місяць тому

      Time can be stored in a datetime type variable, check the MQL4 reference for that

  • @nadz786786786
    @nadz786786786 3 місяці тому

    I'm confused about this lesson, you did not tell us the order of how to write the code and what is the structure of the sentences, the same way we learn we need a verb pronounce in a sentence etc

  • @SSEnrich
    @SSEnrich Рік тому

    string myName is camelcase no? Typical for javascript, but not used in mql4. Am I correct?

  • @ldu9019
    @ldu9019 3 роки тому

    How can I calculate the highest price in a certain time range?

  • @WealthyReader
    @WealthyReader 3 роки тому +1

    I've watched this particular tutorial about three times now and still did not get it, any help please!...

  • @axtrion888
    @axtrion888 3 роки тому +1

    Why would you write a function just to void it, sir?

    • @toolkitfortraders
      @toolkitfortraders  2 роки тому

      Void just means that nothing is returned from the function. Void functions still work, but they typically are used to complete a task.

  • @Maestroluu
    @Maestroluu 11 місяців тому +1

    26:36 it says i have 2 errors i dont know what's wrong ?

  • @joefanrenaissanceman8260
    @joefanrenaissanceman8260 3 роки тому +2

    This lesson would have been so much better if you took the time to debug your code and show how just because the code compiles doesn't mean it is right.

  • @mmhazby
    @mmhazby Рік тому

    Did you just turn "NormalizeDouble" function into a comment after spending 10 minutes on it ???
    Seems like the result of this lesson was exact same result as last one. So what was the point of that NormalizeDouble function again?
    Last lesson was perfect but this one was very very very confusing

    • @jokesontopofyou
      @jokesontopofyou Рік тому

      So the problem with that commented line of code is the variable used in NormailzeDouble should be "point_spread" instead of current_spread... point_spread = NormalizeDouble(point_spread, 0);