Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Get P/L for the day in ninjascript

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

    Get P/L for the day in ninjascript

    Is it possible to obtain the current cumulative P/L for the day (such as that displayed in the DOM) in ninjascript?

    #2
    JoshDance, you could check into - http://www.ninjatrader.com/support/h...countvalue.htm

    Comment


      #3
      Bertrand,

      Please forgive my ignorance, and I have not programmed a strategy before. I have CalculateOnClose set to false, and my OnBarUpdate() is a single line:

      Code:
      protected override void OnBarUpdate()
      {
           Print("account value is: " + GetAccountValue(AccountItem.CashValue));
      }
      I have the strategy loaded, connection is established, market is ticking. Yet, I see no output in the output window. What am I missing?

      Comment


        #4
        What connection / account are you running the strategy off? Does the CashValue show as expected in your Accounts tab in the Control Center?

        Thanks,

        Comment


          #5
          Originally posted by NinjaTrader_Bertrand View Post
          What connection / account are you running the strategy off? Does the CashValue show as expected in your Accounts tab in the Control Center?

          Thanks,
          I am running this off my IQFeed connection, simulation account for testing. Regardless of what's in the account tab, I should see something print, and it's not printing anything. But yes, it's showing the expected value.

          By the way, my broker uses TT -- this feed does not allow me to see cash value, etc., so does that mean that even if I get this working that it will not be usable with TT?

          Comment


            #6
            Correct for TT, you can only access value offered through the connected API with this method. Your strategy though could keep track itself of per session PnL then, but this would only reflect PnL for this very strategy instance :



            For your print - are you sure the strategy is enabled? So showing 'green' in your Strategies tab in the Control Center?

            Comment


              #7
              Originally posted by NinjaTrader_Bertrand View Post
              Correct for TT, you can only access value offered through the connected API with this method. Your strategy though could keep track itself of per session PnL then, but this would only reflect PnL for this very strategy instance :



              For your print - are you sure the strategy is enabled? So showing 'green' in your Strategies tab in the Control Center?
              Ok Bertrand, I will give this a look. And it was not enabled in the Strategies tab. I did not know there was a strategies tab, sorry.. as I said, I have never used a strategy before and didn't know they had to be "turned on"

              Comment


                #8
                Originally posted by NinjaTrader_Bertrand View Post
                Your strategy though could keep track itself of per session PnL then, but this would only reflect PnL for this very strategy instance :
                So, just to be clear, I don't have a programmatic trading strategy. I only want, in some way, to be able to determine my day's P/L. I am going to be placing orders through ATM strategies on the DOM, or perhaps no ATMs at all. I want to check my daily P/L, and ensure that it does not fall below some threshold. It seems that the Performance.AllTrades, etc., only applies for the strategy that is code is running from--is that correct? In my case, this will not work, as I may not even be running a strategy. I just want to find out my daily P/L. Is this possible?

                Comment


                  #9
                  Correct, it would be only knowing the Pnl for the specific strategy instance then, not for your manual trading. If your TT account would not offer this info to retrieve via GetAccountValue then you would not be able to set up a monitor script for this task.

                  Comment


                    #10
                    So, knowing everything you know about the NT code, can you help me find a way to do what I'm looking to do? I don't mind even manually entering an account balance into an indicator every day if it can't be retrieved programatically. How about reading the log file? Anything to get this working... there's always a way, and this seems not too far out of the box.

                    Comment


                      #11
                      JoshDance, an untested approach would be - enter start account balance as input to calculate with and add your RealizedPnl that NT would calculate for a TT based account, this would be 'gettable' as well via GetAccountValue.

                      Comment


                        #12
                        Originally posted by NinjaTrader_Bertrand View Post
                        JoshDance, an untested approach would be - enter start account balance as input to calculate with and add your RealizedPnl that NT would calculate for a TT based account, this would be 'gettable' as well via GetAccountValue.
                        Ok, this is probably the value I was looking for. Now, when I place a trade and close it, my strategy disables itself. Is this some setting I need to be overriding?

                        Comment


                          #13
                          Don't close the trade with the 'Close' button on ChartTrader or DOM. This would cancel working orders and close the position and running strategies on that instrument / account.

                          Comment


                            #14
                            Originally posted by NinjaTrader_Bertrand View Post
                            Don't close the trade with the 'Close' button on ChartTrader or DOM. This would cancel working orders and close the position and running strategies on that instrument / account.
                            lol, let me get this right -- the "Close" button disables all running strategies? And there is not an option to change this behavior?

                            Comment


                              #15
                              Correct, it would close the running strategies on the same instrument / account combination.

                              If you work with ATM's press the middle mouse button to close the running ATM including its position only.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                              0 responses
                              576 views
                              0 likes
                              Last Post Geovanny Suaza  
                              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                              0 responses
                              334 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
                              553 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by RFrosty, 01-28-2026, 06:49 PM
                              0 responses
                              551 views
                              1 like
                              Last Post RFrosty
                              by RFrosty
                               
                              Working...
                              X