Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

OnPositionUpdate

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

    OnPositionUpdate

    Can NT provide some assistance here?
    My thoughts and reading the documentation are that a Position Object is updated each time an event occurs.
    However if I am say long and get stopped out or fill a target I notice that my Direction filter doesn't go to 0 ( 1 is long , -1 is short set in OnExecutionUpdate)
    even though I specifically set Direction to change to 0.
    Am I misunderstanding something here?
    Code:
    protected override void OnPositionUpdate(Cbi.Position position, double averagePrice)
    {
    ​....
                if(position.MarketPosition == MarketPosition.Flat)//only seems to get called when actually exiting a position
                {
                    {
                           ChartControl.Dispatcher.InvokeAsync(() =>
                        {
                            Direction = 0;// no effect??
                            ResetBools();
                            ResetLines();
                            ResetButtons();    
                        });
                    }
                }​
    }
    Last edited by Mindset; 03-15-2025, 10:00 AM. Reason: Correction to code

    #2
    Hello Mindset,

    You would need to use a Print and see what the values are for the passed in Position object to get a better idea of what's happening. It is likely that is providing the position you exited, for example if you were long and exited it the position would report long and not flat.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Hi Jesse
      But if I did exit the long surely the position object should update to flat?
      To my simple mind that's a position update?

      Comment


        #4
        Hello Mindset,

        The position update event is letting you know what position change, not the current position. If you are trying to update to reflect the strategy position you should do that from OnBarUpdate and use the strategies Position object. When that is updated it will reflect the correct current position.
        JesseNinjaTrader Customer Service

        Comment


          #5
          Hi Jesse

          Sorry to labour the point but surely a change in position from long to flat is important to reflect, everywhere.
          And what is the difference between a strategy position update and a 'normal' position update?
          I actually don't use it to reflect the current position because , as you point out, position update does not reflect the current position. Maybe it's me but it took me a long time to figure out that position update only reflects long and short, NOT flat and it seems kind of non sensical.
          Just my 10c.
          I am currently repairing NT8 daily (it's getting really irritating) - so for a long time I thought it was something to do with that.

          Comment


            #6
            Hello Mindset,

            If you are using a strategy you should always use the strategies properties like its Position, that's what the rest of your strategy logic is going to be using so it would be suggested to just use that throughout. If you need flat you need to read the strategies current position, not the event position. In regard to repairing I would suggest making a new case in the technical support forum if you are having to do that. If you are using third party items that are causing that to be the case a clean user folder would be suggested and only import the items you use.
            JesseNinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by herzogvladimir2, Today, 08:10 PM
            0 responses
            2 views
            0 likes
            Last Post herzogvladimir2  
            Started by giogio1, 04-13-2025, 01:42 AM
            2 responses
            33 views
            0 likes
            Last Post giogio1
            by giogio1
             
            Started by mmenigma, 01-23-2024, 09:37 AM
            1 response
            86 views
            0 likes
            Last Post Nin8aTrender  
            Started by wbayne333, 02-22-2021, 01:18 PM
            6 responses
            409 views
            0 likes
            Last Post Nin8aTrender  
            Started by gtheaded, 07-03-2020, 03:47 PM
            3 responses
            370 views
            0 likes
            Last Post Nin8aTrender  
            Working...
            X