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

Referencing position profit or loss within an indicator

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

    Referencing position profit or loss within an indicator

    This one has me stumped.

    I am trading live using the ATM in the DOM ladder. I don't always have an ATM strategy going, instead setting my entries and exits manually. I want to be alerted (either audibly or by drawing an object on the chart) when a certain condition occurs while a position is open.

    For example, say I have an indicator that alerts me whenever three price bars in a row have 3 equal highs. Now suppose I want the indicator to alert me only if 3 equal highs occur during a profitable open position.

    How would I do this? I see methods like GetAtmStrategyMarketPosition() but they require a position ID, which I don't know how to obtain. Another method AvgProfit() seem to take into account past positions, not just the open ones. OnPositionUpdate() requires a strategy, not an indicator. So does the Positions object.

    How would I obtain the current open position's running profit or loss within an indicator, not a strategy? The DOM window is able to display this value, so how would I access it from an indicator? For all open positions as well as individual open positions?

    -A

    #2
    anachronist,

    Unfortunately there is no supported way to grab discretionary trades from NinjaScript. Automated and manual trading are separate, and each strategy is separate from one another. This would be possible using a single automated strategy that trades itself however.

    Please let me know if I may assist further.
    Last edited by NinjaTrader_AdamP; 02-06-2012, 08:56 AM.
    Adam P.NinjaTrader Customer Service

    Comment


      #3
      AdamP, thank you for the reply.

      I have a number of situations where I'd want an indicator to show me something only when a position is open.

      May I suggest: In support of those customers who use NinjaTrader for discretionary live trading with the help of indicators, please expose the methods that appear to be already available (used by your DOM window code and elsewhere) to allow an indicator to access the current open position profit for an instrument.

      Thanks.
      -Alex

      Comment


        #4
        anachronist,

        I will suggest this to our developers and get you a tracking ID for the suggestion.

        Please let me know if I may assist further.
        Adam P.NinjaTrader Customer Service

        Comment


          #5
          anachronist,

          Your suggestion has ID #294

          Please let me know if I may assist further.
          Adam P.NinjaTrader Customer Service

          Comment


            #6
            I backup this request.

            Comment


              #7
              SARdynamite,

              I have added your vote to the tracking ID.
              Adam P.NinjaTrader Customer Service

              Comment


                #8
                i would like to third this request please

                Comment


                  #9
                  years have past and this request is still pending? lots of people have showed interest in this indicator. i understand this isn't supported, but with all the briliant programers in your team, one should be able to put this together

                  Comment


                    #10
                    Hello calhawk01,

                    Thanks for your post.

                    Your feedback will be taken into consideration. Any changes are being taken into consideration for NinjaTrader 8/ This has been developments main focus.
                    BrandonNinjaTrader Customer Service

                    Comment


                      #11
                      Quite similar, I Need to get Access to the average open Price of the Position object. If it cannot be done in an indicator, can I write a strategy to check for open Position and visualise some Price Levels on the Chart depending on the avg open Price of the Position, or will the strategy Close a Position that had been manually opened?

                      Thanks,
                      Martin

                      Comment


                        #12
                        Hello Martin,

                        Thank you for your response.

                        The Strategy will only pull performance of it's own position, the indicator cannot though. There are unsupported means to pulling account information.

                        Comment


                          #13
                          Hi Patrick,

                          would you mind to send a code snippet how to read Overall Position size and avg entry Price of an Instrument, even that this is not supported. It would really help me a lot!
                          I Need to write an indicator to visualise Exit Levels of an open Position where I can scale into over time that the indicator will update accordingly.

                          Thanks,
                          Martin

                          Comment


                            #14
                            Hello mstreck,

                            Below is a snippet for pulling account information such as positions:
                            Code:
                            foreach (Account acct in Cbi.Globals.Accounts)
                            {
                            if (acct.Positions != null)
                            {
                            PositionCollection positions = acct.Positions;
                            foreach (Position pos in positions)
                            {
                            Print(pos.Account.Name + " " + pos.Instrument + " " + pos.MarketPosition + " " + pos.Quantity + " " + pos.AvgPrice);
                            }
                            }

                            Comment


                              #15
                              That is awesome. Thank you, exactly what I need.

                              Cheers,
                              Martin

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by maybeimnotrader, Today, 05:46 PM
                              0 responses
                              6 views
                              0 likes
                              Last Post maybeimnotrader  
                              Started by quantismo, Today, 05:13 PM
                              0 responses
                              6 views
                              0 likes
                              Last Post quantismo  
                              Started by AttiM, 02-14-2024, 05:20 PM
                              8 responses
                              166 views
                              0 likes
                              Last Post jeronymite  
                              Started by cre8able, Today, 04:22 PM
                              0 responses
                              8 views
                              0 likes
                              Last Post cre8able  
                              Started by RichStudent, Today, 04:21 PM
                              0 responses
                              5 views
                              0 likes
                              Last Post RichStudent  
                              Working...
                              X