fxDreema

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

    Going insane trying to figure out problem with this simple expert

    Questions & Answers
    2
    3
    234
    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.
    • T
      tonyramirez last edited by

      When backtesting this expert behaves in weird ways I can't explain. All it should do is:

      Branch 1

      1. If there is no position
      2. Buy if the SMA is higher than it was the previous bar

      Branch 2

      1. If there is a position
      2. Close the position after x bars

      I'm not going into all the weird stuff that happens but one thing that it always does is buy and sell within one second whenever conditions are met for the first time. After that it seems to behave as you would expect.

      I can't understand why it would perform this buy followed by an immediate sell when the algorithm says to wait x bars (and on all subsequent trades the rule is followed)

      Link to project below

      https://fxdreema.com/shared/cbRvWooob

      Thanks

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

        @tonyramirez "every n bars" doesn't respect your positions with its calcuations, it will always fall out of sync - the block is kinda useless...

        Use the pink loop block with "check age" to close the trades.

        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

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

          @roar Thanks, I'll give that a try. However, I don't think it has anything to do with what's going on. The problem appears regardless of how many n bars you set to close the trade. As for the 'every n bars' on the left branch - I shouldn't even need to use it but if I don't, even weirder things happen which I'm not even sure how to describe.

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

          Online Users

          S
          C
          F
          W

          11
          Online

          146.8k
          Users

          22.4k
          Topics

          122.6k
          Posts

          Powered by NodeBB Forums | Contributors