Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

MarketDataType

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

    MarketDataType

    Is there a way to determine whether the value from MarketDataType.Last represents a long position or short position?

    #2
    Hello pman777,
    Thanks for your post.

    MarketDataType would not have any concept of a position. You can use the PositionAccount object to check for the account position or the Position object to check the strategies position. If you wanted to check for a long or short position you would use the MarketPosition property for those objects.

    For example, to check if the strategy is in a long position you would do something similar to the following snippet:
    Code:
    if(Position.MarketPosition == MarketPosition.Long)


    Josh G.NinjaTrader Customer Service

    Comment


      #3
      thanks Josh, for context, I'm not looking to analyze my position or strategy ... i'm evaluating past large lot trades via OnMarketData and was hoping to also determine what type of position those trades were.

      Comment


        #4
        pman777,

        You would just need to check and see if the Last price was greater/lesser than the Ask/Bid. You can see an example of this in the BuySellPressure and BuySellVolume default indicators.
        Josh G.NinjaTrader Customer Service

        Comment


          #5
          thanks Josh!

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Mindset, 04-21-2026, 06:46 AM
          0 responses
          87 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by M4ndoo, 04-20-2026, 05:21 PM
          0 responses
          132 views
          0 likes
          Last Post M4ndoo
          by M4ndoo
           
          Started by M4ndoo, 04-19-2026, 05:54 PM
          0 responses
          67 views
          0 likes
          Last Post M4ndoo
          by M4ndoo
           
          Started by cmoran13, 04-16-2026, 01:02 PM
          0 responses
          118 views
          0 likes
          Last Post cmoran13  
          Started by PaulMohn, 04-10-2026, 11:11 AM
          0 responses
          67 views
          0 likes
          Last Post PaulMohn  
          Working...
          X