Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Assigning execution.MarketPosition to a variable

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

    Assigning execution.MarketPosition to a variable

    Hi all,

    Doing something dumb, but I'm trying to assign the value generated in iExecution related to market position in a variable for later processing.

    I'm trying the following in the iExecution section:

    Code:
    protected override void OnExecution(IExecution execution)
    	{
    		trade_TypeofTrade = execution.MarketPosition;
    	}
    and have been attempting to define "trade_TypeofTrade" as a string, int, etc.

    If I want to store the execution.MarketPosition variable, what would be the correct code?

    Thanks in advance!

    #2
    Originally posted by Spiderbird View Post
    Hi all,

    Doing something dumb, but I'm trying to assign the value generated in iExecution related to market position in a variable for later processing.

    I'm trying the following in the iExecution section:

    Code:
    protected override void OnExecution(IExecution execution)
    	{
    		trade_TypeofTrade = execution.MarketPosition;
    	}
    and have been attempting to define "trade_TypeofTrade" as a string, int, etc.

    If I want to store the execution.MarketPosition variable, what would be the correct code?

    Thanks in advance!
    Have you tried
    Code:
    trade_TypeofTrade = execution.MarketPosition.ToString();

    Comment


      #3
      Hello Spiderbird,

      Thank you for your inquiry.

      MarketPosition is an enum type.

      If you would like trade_TypeofTrade to be of the same type, you would want to create trade_TypeofTrade as a MarketPosition.

      Example:
      Code:
      private MarketPosition trade_TypeofTrade;
      You would then be able to store the execution's MarketPosition to trade_TypeofTrade without converting it.

      However, if you would like your trade_TypeofTrade to be a string variable, you could use the code koganam has provided.
      Zachary G.NinjaTrader Customer Service

      Comment


        #4
        Hi Koganam! Thanks for your help as always. I went the route Zachary suggested and everything is working now. Thanks to you both for your time.

        Comment


          #5
          Originally posted by NinjaTrader_ZacharyG View Post
          Hello Spiderbird,

          Thank you for your inquiry.

          MarketPosition is an enum type.

          If you would like trade_TypeofTrade to be of the same type, you would want to create trade_TypeofTrade as a MarketPosition.

          Example:
          Code:
          private MarketPosition trade_TypeofTrade;
          You would then be able to store the execution's MarketPosition to trade_TypeofTrade without converting it.

          However, if you would like your trade_TypeofTrade to be a string variable, you could use the code koganam has provided.
          thank you NinjaTrader_Zachary

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          566 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          330 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          101 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          547 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          548 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X