• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

PositionEventArgs and nested Position property differ

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

    PositionEventArgs and nested Position property differ

    The entry was long, then I hit the Closse button, or a Sell Mkt button matching the same quantity, and this code gives me conflicting values:
    Code:
    void OnPositionUpdate(object sender, PositionEventArgs e){
    	try{
    		_Dispatcher.InvokeAsync(() => {
    			Print(string.Format("e.MarketPosition: {0}", e.MarketPosition));
    			Print(string.Format("e.Position.MarketPosition: {0}", e.Position.MarketPosition));
    		});
    	}catch (Exception error){ _Dispatcher.InvokeAsync(() => Print(error.ToString())); }
    }
    Shouldn't these two values be the same? Output:
    e.MarketPosition: Flat
    e.Position.MarketPosition: Long
    Why are the properties of the nested Position member of the PositionEventArgs instance different.

    #2
    Hello xcondor,

    Thanks for your inquiry.

    Considering the help guide documentation for Account.PositionUpdate suggests to use PositionEventArgs.MarketPosition and the result is what we would expect, I would suggest moving forward with e.MarketPosition.

    Nonetheless, since there is not any clear documentation on PositionEventArgs and expected usage, I am consulting with Product Management on the matter.

    I'll update this post as more information becomes available.
    JimNinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_Jim View Post
      Nonetheless, since there is not any clear documentation on PositionEventArgs and expected usage, I am consulting with Product Management on the matter.
      It appears that e.Position is the position from BEFORE the update event fired.

      Comment


        #4
        Hello xcondor,

        Position.MarketPosition is the position that gets added or removed. If we add a print for e.ToString(), we can see the Add and Remove operations.

        instrument='ES 06-18' account='Sim101' avgPrice=2671.75 quantity=1 marketPosition=Long operation=Add
        e.MarketPosition: Long
        e.Position.MarketPosition: Long

        instrument='ES 06-18' account='Sim101' avgPrice=0 quantity=0 marketPosition=Flat operation=Remove
        e.MarketPosition: Flat
        e.Position.MarketPosition: Long
        Upon entering with a Buy Market, we see the current MarketPosition read as long, and an operation of adding a long Position.MarketPosition is seen.

        Upon exiting with a Sell Market, we see the current MarketPosition read as flat, and an operation of removing a long Position.MarketPosition is seen.

        If you have any additional questions, please don't hesitate to ask.
        JimNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by rickyblah12, Yesterday, 08:17 PM
        1 response
        11 views
        0 likes
        Last Post NinjaTrader_PaulH  
        Started by Johnny Santiago, Today, 04:50 AM
        0 responses
        4 views
        0 likes
        Last Post Johnny Santiago  
        Started by jamarc, Today, 02:30 AM
        0 responses
        4 views
        0 likes
        Last Post jamarc
        by jamarc
         
        Started by mrlucky1x, Yesterday, 08:07 PM
        0 responses
        4 views
        0 likes
        Last Post mrlucky1x  
        Started by uday12, Yesterday, 07:21 PM
        0 responses
        5 views
        0 likes
        Last Post uday12
        by uday12
         
        Working...
        X