fxDreema

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

    Every "n"bars issue.

    Questions & Answers
    2
    12
    4133
    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
      Stroker last edited by

      I need to check conditions: "if trade, every "n" bars", but it´s very imprecise, some times put the arrow in the trade candle and some times put it 4 candles before.

      However it close trades every "n" bars very accurate. What I´m doing wrong?

      https://fxdreema.com/shared/OiafPDcne

      0_1496657762143_upload-ae7ebe2c-3c78-44f6-a3d6-fdbdfc5e92ce

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

        I'm not sure if I understand what you mean, but remember that you have put the "every n bar" blocks AFTER the "if trade" block. This means the EA doesn't actually count every bar because there is the condition.
        Try switching the "every bar" counter to top position?

        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
          Stroker last edited by

          I´m looking to change Variables at first bear bar (with ID 1) after trade. I need to wait two candles to check the candle close on ID 1 and ID 2.

          I tried it with counters, flags, candleCount... and it doesn´t work. I understand than candles close it´s not accurate, but two candles more or less is too much, I´m doing something wrong.

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

            Hmm, how about playing with a variable of your own, something like this:

            On each bar:

            • Modify variable beardetector to 0 when trade opens
            • If last candle (ID1) open is above last candle (ID1) close (thats a bear) -> Modify variable beardetector to 1
            • You can also reset the beardetector to 0 when last candle is bullish, same logic

            Now you can just check if beardetector is 1 and continue from there.

            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
              Stroker last edited by

              The EA must buy after a bearish row, and here is the problem, because "when trade opens" the candle ID 1 is bearish on all trades.

              I need to check every candle close after trade, not before. Seems easy to put a counter but with candle counters is not accurate.
              In the example on the top you can see how the counter with "If trade, every 3 bars, Draw arrow. Sometimes draw in the trade candle, sometimes in the next...

              Your help is much appreciated.

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

                You can also use a simple variable to count the bear row.
                For example, if you are seeking for 3 bears:

                On each bar:
                Condition: Last candle open is higher than close
                if true -> modify variable RowCounter to RowCounter +1
                if false -> modify variable RowCounter to 0

                Now you can make condition: RowCounter is above or equals 3
                -> buy -> to reset, modify variable RowCounter to 0

                built example: https://fxdreema.com/shared/17r2DukKd

                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
                  Stroker last edited by

                  The block "Bears in a row" works fine to open trades. But when I need to count candles in a trade It´s inaccurate. With this example the EA must close trades every 10 bars or at third bullish bar after a trade:

                  https://fxdreema.com/shared/ED03ge53b

                  But it doesn´t works.

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

                    I think the "every n bars" counts in a way you dont mean it.
                    If you mean to close every trade at some maximum age, you could just use the "close trades" block's age filter.
                    For example close every trade older than 10 hours, "close trades" with filter "Filter trades by age" 10*60=600 minutes.

                    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
                      Stroker last edited by

                      https://fxdreema.com/shared/cH6baD7Id

                      Thanks Roar, now is working fine, with check age. But now I need to get "current time frame" to change the Variables. For example I have a 10 min expiration in a 1 min timeframe, if the EA start in a 5 min timeframe, multiply by 5 the variable "mins to close".

                      Is this possible with a block or need a custom code?

                      Thanks.

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

                        I haven't done anything like that, so cannot give any definite help 😞
                        Well, in the formula block, you could choose left operand as market properties - timeframe, and multiply it with some variable in right operand. I don't know if the timeframe is just a minute value, though.. Could be worth a try 😄

                        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
                          Stroker last edited by

                          https://fxdreema.com/shared/KQXDpp3ad

                          Wow! It works!

                          Thanks again!

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

                            Wow, that went better than expected 😄
                            You are welcome!

                            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
                            • 1 / 1
                            • First post
                              Last post

                            Online Users

                            H
                            J
                            E
                            T
                            E
                            B
                            A

                            17
                            Online

                            146.6k
                            Users

                            22.4k
                            Topics

                            122.6k
                            Posts

                            Powered by NodeBB Forums | Contributors