• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

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.

    https://ninjatrader.com/support/help...ount_class.htm
    https://ninjatrader.com/support/help.../en-us/get.htm
    https://ninjatrader.com/support/help...ccountitem.htm


    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.
            https://drive.google.com/file/d/1aSu...w?usp=drivesdk

            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 Gunter, Today, 12:18 PM
                        1 response
                        5 views
                        0 likes
                        Last Post NinjaTrader_ChelseaB  
                        Started by aslane, Today, 02:27 PM
                        0 responses
                        4 views
                        0 likes
                        Last Post aslane
                        by aslane
                         
                        Started by dadarara, Yesterday, 06:38 AM
                        1 response
                        7 views
                        0 likes
                        Last Post NinjaTrader_ChelseaB  
                        Started by jvanelli, Today, 01:19 PM
                        1 response
                        2 views
                        0 likes
                        Last Post jvanelli  
                        Started by TrendFollowingCapital, Today, 05:45 AM
                        1 response
                        6 views
                        0 likes
                        Last Post NinjaTrader_ChelseaB  
                        Working...
                        X