fxDreema

    • Register
    • Login
    • Search
    • Back to the main page
    • Categories
    • Recent
    • Tags
    • Popular
    • Search

    Mql5 EA build

    Questions & Answers
    2
    22
    5572
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • S
      Spicynote last edited by

      Currently trying to build a bot to trade based off an SMA 60

      Here is how my strategy works.

      Once there are 2 candles above or below the SMA I either short or long based on which side it is above or below.

      I want my EA to trigger a stop loss if it breaks the SMA 60 and I want to test multiple take profit levels to see which level works best for whatever currency pair.

      This is what I got so far but it isn't exactly working on what I have seen so far from testing it.

      0_1549303482898_Bloody hell.ex5

      1 Reply Last reply Reply Quote 0
      • roar
        roar last edited by

        I can't test the .ex5 right now, got an optimization running..
        Please use the windows snipping tool to put a picture, or share a copy of the project:
        0_1549307479441_a6e39f48-ce0f-4a15-9b4d-9a220d05d46b-image.png

        Need small help? Tag me in your post
        Need big help? https://www.fiverr.com/big_algo/automate-your-winning-strategy-in-mql4-or-mql5

        1 Reply Last reply Reply Quote 1
        • S
          Spicynote last edited by

          https://fxdreema.com/shared/Mgjp3tFEd

          @roar

          roar 2 Replies Last reply Reply Quote 0
          • roar
            roar @Spicynote last edited by

            @spicynote
            This will need some fixing. Remember that the ea algorithm runs on every new tick (as we are "on Tick").
            Now it checks every tick if the candle is above MA 60, and if that is TRUE, then it buys.
            It will not open new buys (even if price is above MA) before we wait 2 bars, that's what the "every n bars" does.
            You shouldn't put any closing conditions after the opening condition - that means that you want to close the trade on the same second you open it.

            I'll make a working example in a minute

            Need small help? Tag me in your post
            Need big help? https://www.fiverr.com/big_algo/automate-your-winning-strategy-in-mql4-or-mql5

            1 Reply Last reply Reply Quote 1
            • roar
              roar @Spicynote last edited by roar

              @spicynote
              Here: https://fxdreema.com/shared/Y3lUXgVrb
              Moving backwards in time is best done with the candle ID.
              ID 0 = current, updating candle
              ID 1 = latest completed candle
              ID 2 = 2nd completed candle
              etc.

              Connecting blocks vertically means "AND".
              I connected 2 blocks with condition: "candle close is above 60 MA", with different candle IDs, so the combination reads as "latest candle is above 60 MA, AND the one before it is also above 60 MA"

              Need small help? Tag me in your post
              Need big help? https://www.fiverr.com/big_algo/automate-your-winning-strategy-in-mql4-or-mql5

              1 Reply Last reply Reply Quote 1
              • S
                Spicynote last edited by Spicynote

                When I test it out is there any way to see all the visual ques on the meta trader 5 chart of where it bought and sold?

                Thanks m8 ,

                @roar

                1 Reply Last reply Reply Quote 0
                • S
                  Spicynote last edited by Spicynote

                  Also I am not very familiar with Mt5's strategy tester. Is there a place after you use strategy tester to see the whole rundown of how your bot performed?

                  Thank you,

                  Spicy

                  1 Reply Last reply Reply Quote 0
                  • S
                    Spicynote last edited by Spicynote

                    Nvm found it. For some reason it wont let me delete the previous comment.

                    1 Reply Last reply Reply Quote 0
                    • S
                      Spicynote last edited by

                      I will attempt to build it with the id's included this time. When running the example I realized that it still is buying and selling multiple times on one candle for whatever reason. I think once I rebuild it according to the id's I should understand it more intimately.

                      roar 1 Reply Last reply Reply Quote 0
                      • roar
                        roar @Spicynote last edited by

                        @spicynote The reason here is probably our closing condition: it checks candle close and MA with ID 0 (the current candle), and the price can naturally cross the moving average multiple times in one bar time. Use ID 1 in the closing condition to fix,
                        or put "once per bar" in the project

                        Need small help? Tag me in your post
                        Need big help? https://www.fiverr.com/big_algo/automate-your-winning-strategy-in-mql4-or-mql5

                        1 Reply Last reply Reply Quote 0
                        • S
                          Spicynote last edited by

                          It shouldn't purchase until 2 candles have been established above or below it. The system should make a purchase on the opening of the 3rd candle. @roar

                          roar 1 Reply Last reply Reply Quote 0
                          • roar
                            roar @Spicynote last edited by

                            @spicynote
                            The EA doesnt currently care about the current candle for the trade opening, it only looks the ID 1 and 2. To trade only on candle open, use "once per bar" at the very top of your project

                            Need small help? Tag me in your post
                            Need big help? https://www.fiverr.com/big_algo/automate-your-winning-strategy-in-mql4-or-mql5

                            1 Reply Last reply Reply Quote 0
                            • S
                              Spicynote last edited by

                              Where is the option to do that? @roar

                              1 Reply Last reply Reply Quote 0
                              • roar
                                roar last edited by

                                @spicynote
                                Like dis:
                                0_1549380028337_Screenshot 2019-02-05 at 17.19.13.png

                                Need small help? Tag me in your post
                                Need big help? https://www.fiverr.com/big_algo/automate-your-winning-strategy-in-mql4-or-mql5

                                1 Reply Last reply Reply Quote 0
                                • S
                                  Spicynote last edited by

                                  @roar I am confused on how these sequence of blocks would execute according to my strategy/ Wouldn't it still continue to long/short according to this after another bar pops up?

                                  You got a discord it will be easier to communicate through that

                                  All the best,

                                  Spicy

                                  roar 1 Reply Last reply Reply Quote 0
                                  • roar
                                    roar @Spicynote last edited by roar

                                    @spicynote
                                    The code inside "once per bar" -block will execute on every tick. However, the block will continue the execution flow to blocks 8 and 9 only at the first tick of the bar. When new bar appears, it will once again execute only on first tick.
                                    Go ahead and compile the .ex5 and backtest it (in visual mode), that is the best and quickest way to learn. When I do something new, I compile and test 10 new versions of my EA in 10 minutes, its all about the repeating process. You can copy some block groups, turn some blocks off, experiment and find out which does what.

                                    I'd like to keep the process in this forum, for (1) building a knowledge base for everyone and (2) separating my free time, I only come here when I want to escape my busy life, I should be studying right now lol

                                    Need small help? Tag me in your post
                                    Need big help? https://www.fiverr.com/big_algo/automate-your-winning-strategy-in-mql4-or-mql5

                                    1 Reply Last reply Reply Quote 0
                                    • S
                                      Spicynote last edited by

                                      @roar

                                      tried basing it off the info you gave still doesnt work :(.

                                      Oh well back to the drawing board

                                      1 Reply Last reply Reply Quote 0
                                      • S
                                        Spicynote last edited by

                                        So i tried re building it from scratch i noticed that i couldnt find a way for it to tell the program to wait until the blocks past above the MA 3 time before buying on the opening of the 3rd candle.

                                        Also another problem i keep running into is to get it to stop purchasing above the 3rd candle

                                        This is built through the mt5 builder so if anybody could help me it would be much appreciated

                                        Thank you,

                                        Spicy

                                        roar 1 Reply Last reply Reply Quote 0
                                        • roar
                                          roar @Spicynote last edited by roar

                                          @spicynote
                                          I tested the project I shared earlier: https://fxdreema.com/shared/Y3lUXgVrb
                                          Found a little bug - close sell condition was "below" instead of "above".
                                          Now the EA works as designed.
                                          It surely does make some stupid trades, but lets not blame the poor algorithm. It just does what we tell it to do
                                          0_1549663990925_40fff653-330e-450e-9269-ecd6c05768f8-image.png

                                          Need small help? Tag me in your post
                                          Need big help? https://www.fiverr.com/big_algo/automate-your-winning-strategy-in-mql4-or-mql5

                                          1 Reply Last reply Reply Quote 0
                                          • S
                                            Spicynote last edited by

                                            @roar It to zoomed out to see very clearly.

                                            But, I notice there are two shorts right next to each other without breaking supports.

                                            Perhaps i didnt explain it clear enough.

                                            roar 1 Reply Last reply Reply Quote 0
                                            • 1
                                            • 2
                                            • 1 / 2
                                            • First post
                                              Last post

                                            Online Users

                                            A
                                            E
                                            R
                                            S
                                            B
                                            N
                                            M
                                            A

                                            18
                                            Online

                                            146.7k
                                            Users

                                            22.4k
                                            Topics

                                            122.6k
                                            Posts

                                            Powered by NodeBB Forums | Contributors