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

Variable to Market order?

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

    Variable to Market order?

    Hi,

    Is it possible to assign to a variable the entry price executed by a market order (EnterLong)? I've tried:

    double value = EnterLong(1, "Entry");

    However I get an error with this...I simply want to "save" the price used for entry for later usage. Thank you.

    #2
    After you get filled save the value of Position.AvgPrice.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Thank you.

      Comment


        #4
        Hi,

        For some reason this is returning a value of "0"...I don't understand why:

        EnterLong(1, "LO trace"); EnterPlace = Position.AvgPrice;

        Can somebody explain why my Print statements show the value for "EnterPlace" is always "0"?

        Comment


          #5
          You want to save the value after your order is filled not after you submit your order. So run a check as to when your order gets filled via either Position.MarketPosition or Position.Quantity. Then do the Position.AvgPrice saving.
          Josh P.NinjaTrader Customer Service

          Comment


            #6
            Originally posted by Josh View Post
            You want to save the value after your order is filled not after you submit your order. So run a check as to when your order gets filled via either Position.MarketPosition or Position.Quantity. Then do the Position.AvgPrice saving.
            EntryPrice in EasyLanguage.
            Position.MarketPosition changed or
            Position.Quantity changed
            EntryPrice = Position.AvgPrice

            Comment


              #7
              Huh? Not sure I follow what you are asking.
              Josh P.NinjaTrader Customer Service

              Comment


                #8
                Originally posted by Josh View Post
                Huh? Not sure I follow what you are asking.
                Sorry, Just a memo for myself.

                I was looking for a method to calculate the EntryPrice as with Tradestation.
                What you mentioned seems to work for me. that is all.

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Vikuno1, 11-28-2023, 11:42 PM
                13 responses
                345 views
                1 like
                Last Post PaulMohn  
                Started by Taddypole, 04-26-2024, 02:47 PM
                5 responses
                35 views
                0 likes
                Last Post eDanny
                by eDanny
                 
                Started by kujista, 04-23-2024, 06:23 AM
                6 responses
                51 views
                0 likes
                Last Post NinjaTrader_ChelseaB  
                Started by giulyko00, 04-24-2024, 12:03 PM
                7 responses
                37 views
                0 likes
                Last Post eDanny
                by eDanny
                 
                Started by NM_eFe, Today, 10:13 AM
                0 responses
                12 views
                0 likes
                Last Post NM_eFe
                by NM_eFe
                 
                Working...
                X