Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

OnPositionUpdate has reverse position values for MBTrading

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

    OnPositionUpdate has reverse position values for MBTrading

    Hi,

    I got problem of getting correct position data inside OnPositionUpdate method when running from Strategies Tab. The problem is that IPosition object has exactly opposite values when runned on my MBTrading account than if runned at the Sim101 account.

    Let's demonstrate it on simple strategy:
    Code:
    #region Using declarations
    using System;
    using System.ComponentModel;
    using NinjaTrader.Cbi;
    #endregion
    namespace NinjaTrader.Strategy {
    
        public class PositionDemo : Strategy {
    
            protected override void OnPositionUpdate( IPosition position ) {
                Print( position.ToString( ) );
            }
    
            protected override void OnBarUpdate( ) {
                if( Historical ) {
                    // just skip historical run
                    return;
                }
    
                if( Position.MarketPosition == MarketPosition.Flat ) {
                    Print( "EnterLong" );
                    EnterLong( );
                } else {
                    Print( "ExitLong" );
                    ExitLong( );
                }
            }
        }
    }
    When the position is entered, we expect position to be updated to Long, when the position is exited, we expect position to be updated to Flat.

    When I run this on the Sim101 account, I get result as expected.
    EnterLong
    Instrument='NQ 12-12' Account='Sim101' Avg price=2856 Quantity=1 Market position=Long
    ExitLong
    Instrument='NQ 12-12' Account='Sim101' Avg price=0 Quantity=0 Market position=Flat
    But now try to run same strategy on the MBTrading account (at my case demo account).
    EnterLong
    Instrument='NQ 12-12' Account='35009544' Avg price=0 Quantity=0 Market position=Flat
    ExitLong
    Instrument='NQ 12-12' Account='35009544' Avg price=2856,5 Quantity=1 Market position=Long
    As you can see the result is exactly the opposite than result on the Sim101 account, what makes OnPositionUpdate absolutely unusable for me to use for realtime strategies.

    I use NinjaTrader 7.0.1000.11 with MBT Desktop 11.9.0.44.

    #2
    Hello,

    There is a known limitation when using MBT where the position updates can come in before the execution updates.

    You will need to track these positions in OnOrdateUpdate() rather than OnBarUpdate()

    MatthewNinjaTrader Product Management

    Comment


      #3
      Mathew,

      It is really beautiful you know that, because I wasn't informed in any way that I'm going to use some feature that is not fully supported for my broker !! I would put some business logic into my OnPositionUpdate (I already did) and look how things are going wrong only because NinjaTrader is not able to tell me that I'm overriding method that is not working properly for my case.

      This is bad behaviour how to process this situation and this not letting me comfortable because I only can wait what else will fail just because I use something that is not supported for realtime trading with MB Trading.

      Mathew, the NinjaTrader is not just computer game or what, this is application that operate with real money and also it is expensive. So I would expect that once I enable my strategies, than everything has to be fine. All your knowledge about limitations has to be catched to decrease risk.

      Dalibor

      Comment


        #4
        This limitation is listed on the MB Trading disclaimer #4 that is generated when you create the connection. I'm including the entire disclaimer for you to review to ensure you aware of all items related to MBT.


        ---------------------------
        MB Trading
        ---------------------------
        1) MB Trading supports changing the order type of an active order. This is not common practice. NinjaTrader does not support this feature. As a result, if you place a LIMIT order in MBT Navigator, then change it to a MARKET order and then later logon with NinjaTrader, the prior LIMIT order will show up in the order display tab as a working order. This is merely a display issue and will clear itself out the next day.



        2) MB Trading TTO orders are not supported by NinjaTrader.



        3) NinjaTrader will modify your MBT Navigator settings and disable MBT order confirmation box on order placement, change and cancellation.



        4) MB Trading position events are generated before orders are executed. Since NinjaTrader relies on execution events to come prior to position events, you will experience limitations with tracking positions from the Strategies tab of the Control Center and trying to rely on the standard sequence of events (order execution before position) in NinjaScript.



        5) If you are trading non-USD pairs please ensure you have data streaming for related USD conversion pairs prior to placing orders. This is required for accurate PnL reporting.



        6) OCO orders and ATM Strategies with stop and targets are not supported for equities.
        MatthewNinjaTrader Product Management

        Comment


          #5
          Now I understand #4. Than I apologize for my offensive post, I understood that disclaimer wrong when I red this list.

          Thanks

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by andrewtrades, Today, 04:57 PM
          1 response
          5 views
          0 likes
          Last Post NinjaTrader_Manfred  
          Started by chbruno, Today, 04:10 PM
          0 responses
          3 views
          0 likes
          Last Post chbruno
          by chbruno
           
          Started by josh18955, 03-25-2023, 11:16 AM
          6 responses
          436 views
          0 likes
          Last Post Delerium  
          Started by FAQtrader, Today, 03:35 PM
          0 responses
          6 views
          0 likes
          Last Post FAQtrader  
          Started by rocketman7, Today, 09:41 AM
          5 responses
          19 views
          0 likes
          Last Post NinjaTrader_Jesse  
          Working...
          X