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

How to get values from "sim101" account?

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

    How to get values from "sim101" account?

    Hello,
    Developing a strategy, I want to get values from the sim account.
    I have been looking for this information in help guide and support forum, but still I can not get values....
    I tried to code that, getting information from support forum and help guide.
    In my code I write:
    ...
    private Account myAccount;
    private double winlosstoday;
    ...
    if (State == State.SetDefaults)
    {...
    Calculate = Calculate.OnPriceChange;
    ....
    ....
    lock (Account.All)
    myAccount = Account.All.FirstOrDefault(a => a.Name == "Sim101");
    }

    protected override void OnBarUpdate()
    {

    ...
    ....
    winlosstoday = myAccount.Get(AccountItem.RealizedProfitLoss, Currency.UsDollar);
    if( winlosstoday < -300)
    Print(" RealizedPofitLoss:"+ myAccount.Get(AccountItem.RealizedProfitLoss, Currency.UsDollar));
    .......
    }


    But when I Print the value of RealizedProfitLoss, It always is zero!!!!

    How can I get correctly AccountItem values from the "sim101" account???


    #2
    Hello Parmenides48,

    This does appear to be the correct code.






    What is the RealizedPnL showing on the Accounts tab of the Control Center?

    May we have a screenshot of this?

    Keep in mind historical orders placed in the strategy are not real-time orders that affect the account position.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hello,
      Today this strategy is running in real time, and now I can see in the output window and in the control center/ accounts tab the information that I want to Print.
      See attached images.
      On the weekend and with the markets closed, this strategy running in historical bars doesn't show any information about changes in the RealizedProfitLoss...,
      showing always zero.
      In my strategy I want to stop trading if daily RealizedProfitLoss crosses certain level of losses .
      But to get the information of RealizedProfitLoss after every closed trade,
      I understand that is not possible to get that Account information running the strategy in historical bars?

      Attached Files

      Comment


        #4
        Hello Parmenides48,

        The Account information and the PositionAccount information can be accessed in historical data.

        If there have been no trades on a day during the weekend when the market is closed, then the PnL would be 0...

        Is the account showing a value with RealizedPnL on the accounts tab of the Control Center during the weekend?


        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Hello.
          I don´t know if during the weekend the accounts tab of the Control Center shows a value with RealizedPnL, because I didn't look that, I only was seeing the output window , in order to see the different values of RealizedPnL with the strategy running in historical bars.... I should look that next weekend.....
          But you say that I can access to the different values of RealizedPnL values ( or other account values) in historical bars,
          then, I have to add some code to my code to see all RealizedPnL values in historical bars, or I have to write a different code to get all historical values of sim101 account?
          Now I am running again this strategy , and in output window I see in real time the RealizedPnL values, but all historical values shows zeros.....!

          Comment


            #6
            Hello Parmenides48,

            Below is a link to a video demonstrating that the <account>.Get(AccountItem.RealizedProfitLoss, Currency.UsDollar)); works the same in historical data of a strategy as it does when the strategy is processing real-time data.


            The code is the same.

            However, the account RealizedPnL is not the same as the strategy RealizedPnL.

            Which are you wanting?

            The historical trades in a strategy are not placed to any account and do not affect the account performance.

            Do you want the strategy RealizedPnL and not the account RealizedPnL?
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              Hello again,
              my purpose is to get information from the Account.
              Now, I am testing the strategy in a sim account, with historical bars,and after every closed trade I want to know The RealizedPnL ,
              getting that information from the sim account.
              In the future it must be a real account in real time.
              By your explanation, I understand that I have to get strategy RealizedPnL and not from the account.
              Now I am going to see that link (to the video) that explain that.
              Thanks.

              Comment


                #8
                Hello Parmenides48,

                Are you understanding that historical orders are the same as a backtest and are never submitted to the account?

                Historical orders in a strategy are backtest theoretical orders. These are not live real-time orders that are placed to the account.

                If you want the account RealizedPnL this is not going to include any historical orders that were never actually placed to the account..

                https://ninjatrader.com/support/foru...442#post782442
                Last edited by NinjaTrader_ChelseaB; 02-26-2019, 09:45 AM.
                Chelsea B.NinjaTrader Customer Service

                Comment


                  #9
                  I have seen that video,
                  the code is the same,
                  running that code, written inside the strategy, the account RealizedPnL is shown in the output window and in the Accounts Tab,
                  but only in real time,
                  in the output window, all historical bars before real time show account RealizedPnL = 0 !!!

                  Then , if historical trades don´t affect the account performance, as you say,
                  I can´t get information of account RealizedPnL with historical trades!!!!!

                  How can I get strategy RealizedPnL information after every trade to control the the daily win or loss with that strategy????

                  Comment


                    #10
                    Hello Parmenides48,

                    Are you referring to the new video I have recorded for you and linked in post #6 that demonstrates the State is Historical and the RealizedPnL for the account is 12.5?

                    You can get the Strategy RealizedPnL for historical trades with the SystemPerformance collection. This is not part of the Account PnL because the orders are never submitted live to an account.

                    Below are links to the help guide.
                    https://ninjatrader.com/support/help.../cumprofit.htm
                    https://ninjatrader.com/support/helpGuides/nt8/en-us/systemperformance.htm


                    Below is a link to an example of a daily loss limit. This does not use the account realized pnl and uses the strategy pnl.
                    http://ninjatrader.com/support/forum...325#post490325
                    Chelsea B.NinjaTrader Customer Service

                    Comment


                      #11
                      Yes , I was referring to the video in post #6.
                      Now I am going to see the links you send me.
                      Thanks a lot.

                      Comment


                        #12
                        Hello Parmenides48,

                        The video I created for you in post #6 clearly shows that the account performance for the Sim101 is being returned accurately when the strategy is in historical.

                        The State is historical, the Sim101 RealizedProfitLoss shown by the script is 12.5 and this is also shown on the Accounts tab of the Control Center.

                        When you mention "the account RealizedPnL is shown in the output window and in the Accounts Tab, but only in real time, in the output window, all historical bars before real time show account RealizedPnL = 0 !!!"

                        This is 100% incorrect.

                        Please watch the video again. A manual trade is placed with Chart Trader. The profit is 12.5. The RealizedProfitLoss printed by the script never shows a 0. It shows 12.5.

                        The output from the print appears as:

                        2/26/2019 7:43:20 AM | State: Historical | <Sim101>.Get(AccountItem.RealizedProfitLoss, Currency.UsDollar): 12.5.

                        The state is historical. The account RealizedProfitLoss is 12.5. This is the same that is shown on the Accounts tab of the Control Center.
                        Chelsea B.NinjaTrader Customer Service

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by Waxavi, Today, 02:10 AM
                        0 responses
                        4 views
                        0 likes
                        Last Post Waxavi
                        by Waxavi
                         
                        Started by TradeForge, Today, 02:09 AM
                        0 responses
                        10 views
                        0 likes
                        Last Post TradeForge  
                        Started by Waxavi, Today, 02:00 AM
                        0 responses
                        2 views
                        0 likes
                        Last Post Waxavi
                        by Waxavi
                         
                        Started by elirion, Today, 01:36 AM
                        0 responses
                        4 views
                        0 likes
                        Last Post elirion
                        by elirion
                         
                        Started by gentlebenthebear, Today, 01:30 AM
                        0 responses
                        4 views
                        0 likes
                        Last Post gentlebenthebear  
                        Working...
                        X