Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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 pechtri, 06-22-2023, 02:31 AM
          9 responses
          122 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by frankthearm, 04-18-2024, 09:08 AM
          16 responses
          66 views
          0 likes
          Last Post NinjaTrader_Clayton  
          Started by habeebft, Today, 01:18 PM
          1 response
          5 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by benmarkal, Today, 12:52 PM
          2 responses
          15 views
          0 likes
          Last Post benmarkal  
          Started by f.saeidi, Today, 01:38 PM
          1 response
          8 views
          0 likes
          Last Post NinjaTrader_BrandonH  
          Working...
          X