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 DayTradingDEMON, Today, 09:28 AM
          1 response
          12 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by cmtjoancolmenero, Yesterday, 03:58 PM
          8 responses
          31 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by helpwanted, Today, 03:06 AM
          2 responses
          22 views
          0 likes
          Last Post NinjaTrader_LuisH  
          Started by navyguy06, Today, 09:28 AM
          0 responses
          5 views
          0 likes
          Last Post navyguy06  
          Started by rjbtrade1, 11-30-2023, 04:38 PM
          2 responses
          77 views
          0 likes
          Last Post DavidHP
          by DavidHP
           
          Working...
          X