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 itsthefriz, Yesterday, 09:16 PM
                1 response
                9 views
                0 likes
                Last Post NinjaTrader_PaulH  
                Started by Stanfillirenfro, Today, 03:41 AM
                2 responses
                16 views
                0 likes
                Last Post Stanfillirenfro  
                Started by trader3000a, Today, 04:16 AM
                1 response
                4 views
                0 likes
                Last Post NinjaTrader_Marco  
                Started by schmidtbc16, Yesterday, 03:36 PM
                1 response
                13 views
                0 likes
                Last Post NinjaTrader_ChelseaB  
                Started by RT001, Yesterday, 03:25 PM
                2 responses
                20 views
                0 likes
                Last Post RT001
                by RT001
                 
                Working...
                X