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

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
    BertrandNinjaTrader Customer Service

    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,
        BertrandNinjaTrader Customer Service

        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?
            BertrandNinjaTrader Customer Service

            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.
                  BertrandNinjaTrader Customer Service

                  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.
                      BertrandNinjaTrader Customer Service

                      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.
                          BertrandNinjaTrader Customer Service

                          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.
                              BertrandNinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by rocketman7, Today, 09:41 AM
                              4 responses
                              15 views
                              0 likes
                              Last Post rocketman7  
                              Started by selu72, Today, 02:01 PM
                              1 response
                              9 views
                              0 likes
                              Last Post NinjaTrader_Zachary  
                              Started by WHICKED, Today, 02:02 PM
                              2 responses
                              12 views
                              0 likes
                              Last Post WHICKED
                              by WHICKED
                               
                              Started by f.saeidi, Today, 12:14 PM
                              8 responses
                              21 views
                              0 likes
                              Last Post f.saeidi  
                              Started by Mikey_, 03-23-2024, 05:59 PM
                              3 responses
                              56 views
                              0 likes
                              Last Post Sam2515
                              by Sam2515
                               
                              Working...
                              X