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

GetAtmStrategyRealizedProfitLoss() with one Stop1

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

    GetAtmStrategyRealizedProfitLoss() with one Stop1

    I use different ATMs and only ATMs. I have only 1 Stop1 and 1 Target1. After the ATM position has been closed - I can not use GetAtmStrategyRealizedProfitLoss().

    I want to know the current realized Loss or Profit from the Strategy for the current day.

    Question:
    What should I do?

    #2
    Hello webus,

    Thanks for your post.

    The ATM method GetAtmStrategyRealizedProfitLoss() provides the PNL of the just closed trade. You would have to create your own variable to accumulate the PNL of all ATM trades taken by the strategy.

    For example, something like this:

    else if (atmStrategyId.Length > 0 && GetAtmStrategyMarketPosition(atmStrategyId) == Cbi.MarketPosition.Flat)
    {
    /* Retrieve the profit or loss from the just-closed ATM strategy and round it to the nearest tick. This only updates after all targets or stops are filled (the position is flat).
    GetAtmStrategyRealizedProfitLoss can return values such as 99.9999999998 or 100.00000000012, which would be rounded to 100. */
    realizedProfitLoss = Instrument.MasterInstrument.RoundToTickSize(GetAtm StrategyRealizedProfitLoss(atmStrategyId));

    // Sum the profit to the running total.
    totalPL = totalPL + realizedProfitLoss;
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Hi NinjaTrader_PaulH,

      Originally posted by NinjaTrader_PaulH View Post
      Hello webus,

      Thanks for your post.

      The ATM method GetAtmStrategyRealizedProfitLoss() provides the PNL of the just closed trade. You would have to create your own variable to accumulate the PNL of all ATM trades taken by the strategy.

      For example, something like this:

      else if (atmStrategyId.Length > 0 && GetAtmStrategyMarketPosition(atmStrategyId) == Cbi.MarketPosition.Flat)
      {
      /* Retrieve the profit or loss from the just-closed ATM strategy and round it to the nearest tick. This only updates after all targets or stops are filled (the position is flat).
      GetAtmStrategyRealizedProfitLoss can return values such as 99.9999999998 or 100.00000000012, which would be rounded to 100. */
      realizedProfitLoss = Instrument.MasterInstrument.RoundToTickSize(GetAtm StrategyRealizedProfitLoss(atmStrategyId));

      // Sum the profit to the running total.
      totalPL = totalPL + realizedProfitLoss;
      It seems to me that I did the same thing, but the function returned 0.
      Now I redid everything from scratch as you indicated and it all worked. This is strange, but thanks.

      Comment


        #4
        Originally posted by NinjaTrader_PaulH View Post
        Hello webus,

        Thanks for your post.

        The ATM method GetAtmStrategyRealizedProfitLoss() provides the PNL of the just closed trade. You would have to create your own variable to accumulate the PNL of all ATM trades taken by the strategy.

        For example, something like this:

        else if (atmStrategyId.Length > 0 && GetAtmStrategyMarketPosition(atmStrategyId) == Cbi.MarketPosition.Flat)
        {
        /* Retrieve the profit or loss from the just-closed ATM strategy and round it to the nearest tick. This only updates after all targets or stops are filled (the position is flat).
        GetAtmStrategyRealizedProfitLoss can return values such as 99.9999999998 or 100.00000000012, which would be rounded to 100. */
        realizedProfitLoss = Instrument.MasterInstrument.RoundToTickSize(GetAtm StrategyRealizedProfitLoss(atmStrategyId));

        // Sum the profit to the running total.
        totalPL = totalPL + realizedProfitLoss;
        Could you tell me how I can find out the current profit / loss in the account currency (in dollars)?

        Comment


          #5
          Hello webus,

          Thanks for your post.

          Take a look at this page: https://ninjatrader.com/support/help...ount_class.htm You could incorporate the example to your strategy as an easy way to see how it works then adjust as needed.
          Paul H.NinjaTrader Customer Service

          Comment


            #6
            Hi NinjaTrader_PaulH,
            Originally posted by NinjaTrader_PaulH View Post
            Hello webus,

            Thanks for your post.

            Take a look at this page: https://ninjatrader.com/support/help...ount_class.htm You could incorporate the example to your strategy as an easy way to see how it works then adjust as needed.
            Could you please explain in more detail how I can get current realized or unrealized profit in dollars from my ATM strategy?

            Here is what I see in "OnAccountItemUpdate ()". I see only "*****" and it’s not obvious how to get this data normally:
            Click image for larger version  Name:	Screenshot_4.jpg Views:	0 Size:	59.2 KB ID:	1100384


            My Question:
            I need to receive a profit or loss in dollars from the current strategy, and not from the entire account. Ideally, I would like to receive a Realized loss in dollars during the closing of the ATM position.
            Is it possible in NT8?


            Last edited by webus; 05-18-2020, 12:53 PM.

            Comment


              #7
              Hello webus,

              Thanks for your reply and clarification.

              My misunderstanding as I already advised on how to get the ATM strategy realized PNL in post #2 which you acknowledged in post #3.

              Paul H.NinjaTrader Customer Service

              Comment


                #8
                Hi NinjaTrader_PaulH,
                Originally posted by NinjaTrader_PaulH View Post
                Hello webus,

                Thanks for your reply and clarification.

                My misunderstanding as I already advised on how to get the ATM strategy realized PNL in post #2 which you acknowledged in post #3.
                Sorry, maybe I'm confusing something .. Is the unit of measurement for this function Dollars?
                So,
                Code:
                double realizedProfitLoss = s.Instrument.MasterInstrument.RoundToTickSize(GetAtmStrategyRealizedProfitLoss());
                realizedProfitLoss == -0.0005 - meaning that the realized loss is $ 0.0005, am I right?

                Comment


                  #9
                  Hello webus,

                  Thanks for your reply.

                  The ATM strategy method GetAtmStrategyRealizedProfitLoss() will return as currency.
                  Paul H.NinjaTrader Customer Service

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by trilliantrader, 04-18-2024, 08:16 AM
                  4 responses
                  18 views
                  0 likes
                  Last Post trilliantrader  
                  Started by mgco4you, Today, 09:46 PM
                  1 response
                  7 views
                  0 likes
                  Last Post NinjaTrader_Manfred  
                  Started by wzgy0920, Today, 09:53 PM
                  0 responses
                  9 views
                  0 likes
                  Last Post wzgy0920  
                  Started by Rapine Heihei, Today, 08:19 PM
                  1 response
                  10 views
                  0 likes
                  Last Post NinjaTrader_Manfred  
                  Started by Rapine Heihei, Today, 08:25 PM
                  0 responses
                  10 views
                  0 likes
                  Last Post Rapine Heihei  
                  Working...
                  X