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 charlesugo_1, 05-26-2026, 05:03 PM
          0 responses
          70 views
          0 likes
          Last Post charlesugo_1  
          Started by DannyP96, 05-18-2026, 02:38 PM
          1 response
          152 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by CarlTrading, 05-11-2026, 05:56 AM
          0 responses
          162 views
          0 likes
          Last Post CarlTrading  
          Started by CarlTrading, 05-10-2026, 08:12 PM
          0 responses
          100 views
          0 likes
          Last Post CarlTrading  
          Started by Hwop38, 05-04-2026, 07:02 PM
          0 responses
          288 views
          0 likes
          Last Post Hwop38
          by Hwop38
           
          Working...
          X