Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to avoid crossed orders

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

    How to avoid crossed orders

    Today I started live trading and obviously orders got crossed.

    I tried to sell 1 fdax in order to close a position and exactly at the same second my strategy wanted to go short with a sell short order and due to overmargining an error was triggered and my strategy stopped :-((

    Can this situation be avoided by using the command:

    if (position.MarketPosition == MarketPosition.Flat)
    {
    <new entry>
    }
    ...

    thanks
    brima

    #2
    Yes, that would work.
    RayNinjaTrader Customer Service

    Comment


      #3
      And when exactly is the condition
      (position.MarketPosition == MarketPosition.Flat) true?

      as soon as the flattening order is
      a) PendingSubmitt
      b) Accepted
      c) Working
      d) Filled

      Comment


        #4
        As soon as the position is flat determined by incoming executions.
        RayNinjaTrader Customer Service

        Comment


          #5
          Does that mean as soon as an flattening order has category "Execution" in the log file?

          Comment


            #6
            brima,

            check my reply to a similar instance at

            http://www.ninjatrader-support.com/v...ead.php?t=8615
            mrlogik
            NinjaTrader Ecosystem Vendor - Purelogik Trading

            Comment


              #7
              Originally posted by brima View Post
              Does that mean as soon as an flattening order has category "Execution" in the log file?
              An order can be made up of multiple executions, but in concept your understanding is correct.
              RayNinjaTrader Customer Service

              Comment


                #8
                @mrlogik

                unfortunately I'm not working with the advanced order handling yet, my code is as follows:

                protected override void Initialize()
                {
                SetStopLoss(CalculationMode.Ticks, stoplossticks);
                CalculateOnBarClose = false;
                }

                protected override void OnBarUpdate()
                {
                #region ENTRY
                if ( (<EntryCondition == true>) & (Position.MarketPosition == MarketPosition.Flat))

                {
                EnterShort(1)
                or
                EnterLong(1)
                }
                #endregion

                #region EXIT
                if ( (<ExitCondition == true>) & (Position.MarketPosition != MarketPosition.Flat))
                {
                ExitShort(1)
                or
                ExitLong(1)
                }
                #endregion
                }

                Hopefully that makes sense and works fine now.

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Jeremytang, 07-14-2018, 06:45 PM
                21 responses
                439 views
                0 likes
                Last Post mav8rick  
                Started by LeonK, Yesterday, 09:26 PM
                1 response
                8 views
                0 likes
                Last Post bltdavid  
                Started by NicholasJoannette, Yesterday, 03:01 PM
                2 responses
                11 views
                0 likes
                Last Post NicholasJoannette  
                Started by rach1994, Yesterday, 12:20 PM
                1 response
                35 views
                0 likes
                Last Post bltdavid  
                Started by litamm89, Yesterday, 11:00 AM
                5 responses
                22 views
                1 like
                Last Post rafael_delima86  
                Working...
                X