fxDreema

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

    Check last n trades closed (but ordered by oldest closing time)?

    Bug Reports
    2
    6
    1874
    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.
    • B
      Babago last edited by Babago

      Hi @fxDreema
      i wonder about the "for each Closed Trade" function..
      I use it to analyze the last n trades profit using the method "Newest to Oldest"
      looking at the mq4 code, here mine two questions:

      1. i thought the function returns the last n trades ordered from Close Time, is that right?
        Or it returns the last n trades opened and already closed?

      2. probably i'm wrong but it looks like the "For each Trade" model does not sort by ticket or date
        and looking around on forums i found this two statements:

      From MQL4 Guide link text
      "Consecutive selection of orders using the SELECT_BY_POS parameter returns information in the sequence in which it was received from the trading server. Sorting of the resulting list of orders cannot be guaranteed."

      and from link text

      "I found that in both 'trade pool' and 'history pool', the list is sorted by time the trade is opened."

      "When back testing this seems to work as you might expect with orders entering the list sequentially. When done in live accounts you are better off considering the ordering as random and sorting it yourself."

      "By the way, the OrdersHistory also contains balance transfers, identifiable as OrderSymbol()==""
      If you have 5 or 6 orders in your history you may be lulled in a false sense of security and think you have the pattern figured out. I just checked it this evening to make sure and of 150 trades in the history there are not just a few out of date order, but lots. The first errors didn't appear until 30 items into the list."

      "There is no explicit documentation of the sorting order of this list, so better considering it as random sorted, as Dabbler suggested. It can depend on brokers also.
      Perhaps there is a more experienced programmer here, who can point the documentation of this. But, if not, when the sequence of list is critical, you should build a custom array of it, then sort yourself."

      With all that said, how can i reliable check the last n trades closed (ordered by oldest closing time)?

      Thank you
      Dave

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

        My expectation is that the trades should be sorted by close time. But to be honest, I don't know all the details. I don't remember seeing wrong trades order, but if you think that something is wrong, give me some project so I can investigate it.

        1 Reply Last reply Reply Quote 0
        • B
          Babago last edited by Babago

          Ok @fxDreema i will investigate.
          I thought you were in holidays so i decided in the meantime to wrote a function inside FxDreema Studio to order the history.
          Works like a charme!
          Never used FxDreema Studio but is a really great addon! Wow!
          Thanks for it, as always!

          1 Reply Last reply Reply Quote 0
          • B
            Babago last edited by

            @fxDreema

            Hope it will help, i made this script https://fxdreema.com/shared/S6V8yaZkc
            Tried on two real accounts with 5 an 100 trades, in both case the results are RANDOM!!! 😄

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

              I think it works good for me:
              0_1535231407047_16c3faf6-f112-4384-b037-faead1c50d79-image.png

              1 Reply Last reply Reply Quote 0
              • B
                Babago last edited by

                Sorry i didn't see your reply..
                very strange, these are my resaults..
                i tried with different account and metatraders..
                ?????

                i covered some numbers just to help you see the random pattern..

                0_1540161835788_Schermata 2018-10-22 alle 00.41.17.png

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

                Online Users

                L

                7
                Online

                146.8k
                Users

                22.4k
                Topics

                122.6k
                Posts

                Powered by NodeBB Forums | Contributors