Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Multiple order get executed

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Multiple order get executed

    I have below code which executes wired way, I debugged with no clue, it occurs in live data not in playback test.

    if (CrossAbove(DEMA1, SMA55, 1))
    {

    ExitShort(); // to exist all long positions
    EnterLong(1, "First Long A"); // start fresh long
    Print( "First Long A");

    }

    //other condition for adding to existing position
    { ..... }


    If my position is 10, the above block exits shorts of 10 then immediately adds 10 long and one for my "first long A" .
    What is wrong with this code or we have a bug here?

    #2
    Hello Akee5,

    Thanks for your post.

    All entry methods will automatically detect a position in the opposite direction and will issue orders to close the position (Called "Close Position") and then issue additional order(s) to leave the strategy in the desired position.

    What is happening is that you are submitting the ExitShort which will exit the 10 short orders with a buy order of 10 and you are submitting EnterLong(1) at the same time so the EnterLong sees the 10 short and will issue 10 buy Close position orders first and then enters the single buy order leaving you with 11 contracts long (10 from closing and 1 for new position).

    The issue here is the timing of orders. What you need to do is to change the exit condition so that you are not entering and exiting at the same time, or simply remove the exit order now that you know that the entry order will close any existing position in the opposite direction.



    Comment


      #3
      If I have 10 short and then go for EnterLong(1, "First Long A"); will will close one lot or all 10 shorts?

      Comment


        #4
        Hello Akee5,

        Thanks for your reply.

        "If I have 10 short and then go for EnterLong(1, "First Long A"); will will close one lot or all 10 shorts?" It will close all short positions and leave you 1 long,

        Comment


          #5
          It worked thanks for your help. (it closes all shorts )

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by NullPointStrategies, Today, 05:17 AM
          0 responses
          43 views
          0 likes
          Last Post NullPointStrategies  
          Started by argusthome, 03-08-2026, 10:06 AM
          0 responses
          124 views
          0 likes
          Last Post argusthome  
          Started by NabilKhattabi, 03-06-2026, 11:18 AM
          0 responses
          65 views
          0 likes
          Last Post NabilKhattabi  
          Started by Deep42, 03-06-2026, 12:28 AM
          0 responses
          42 views
          0 likes
          Last Post Deep42
          by Deep42
           
          Started by TheRealMorford, 03-05-2026, 06:15 PM
          0 responses
          46 views
          0 likes
          Last Post TheRealMorford  
          Working...
          X