fxDreema

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

    How to delete a pending order after x seconds... precisely

    Questions & Answers
    2
    2
    405
    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.
    • G
      GiovanniBumbo last edited by

      Hello.
      I need to close pending orders after x seconds, suppose 10 seconds, but I need to be exactly 10 seconds, not 9, not 11, not anything else...
      I wrote these blocks

      http://prntscr.com/bfwlia

      If a pending order exist, it checks if variable buy_pending_seconds is equal to the given value, if so it sets the variable to 0 and close pending order, else it increments variable buy_pending_seconds by one, and starts again at the next second.

      It seemed to work but today I checked it in a very volatile enviroment (EURGBP) and it looked like it is not precise at all.

      I put a comment to see if the variable was really incremented once per second, and it wasn't so, it was incremented quite randomly.

      I also discovered that there was a lot of pending orders that were not deleted at all... as the counter of the time was stucked.

      Can you please suggest any affordable method to do such a thing?

      Thanks

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

        I would try this: For each Pending Order -> check age -> close

        But remember that if you work under "on Tick", then you will not always get a tick coming exactly 10 seconds after the order. They come when they want, they don't care about time. So if you want precise time, you need to work under "on Timer". It's period can be set from the project settings (the bench icon). But note that "on Timer" does not work in the Tester, because the Tester works with it's generated ticks

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

        Online Users

        A
        L
        S
        A

        12
        Online

        146.7k
        Users

        22.4k
        Topics

        122.6k
        Posts

        Powered by NodeBB Forums | Contributors