Announcement

Collapse
No announcement yet.

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;

    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.

          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.

              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.

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by CarlTrading, 03-31-2026, 09:41 PM
                  1 response
                  81 views
                  1 like
                  Last Post NinjaTrader_ChelseaB  
                  Started by CarlTrading, 04-01-2026, 02:41 AM
                  0 responses
                  42 views
                  0 likes
                  Last Post CarlTrading  
                  Started by CaptainJack, 03-31-2026, 11:44 PM
                  0 responses
                  64 views
                  2 likes
                  Last Post CaptainJack  
                  Started by CarlTrading, 03-30-2026, 11:51 AM
                  0 responses
                  66 views
                  0 likes
                  Last Post CarlTrading  
                  Started by CarlTrading, 03-30-2026, 11:48 AM
                  0 responses
                  54 views
                  0 likes
                  Last Post CarlTrading  
                  Working...
                  X