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

Chart Trader RealizedProfitLoss Value

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

    Chart Trader RealizedProfitLoss Value

    Hi,


    Just need to help getting this value...

    On the Chart Trader it shows the Realized/UnRealized ProfitLoss value..

    So once a order is flat you see the RealizedProfitLoss value in the Chart Trader.

    Click image for larger version  Name:	image.png Views:	0 Size:	11.5 KB ID:	1237373

    How to I get this value once trade is flat...

    I've tried a few ways but not coming up as the same...

    ​if (atmStrategyId.Length > 0 && GetAtmStrategyMarketPosition(atmStrategyId) == MarketPosition.Flat)
    {

    realizedProfitLoss = Instrument.MasterInstrument.RoundToTickSize(GetAtm StrategyRealizedProfitLoss(atmStrategyId));

    double totalPnl += realizedProfitLoss

    Print("RealizedProfitLoss : " + totalPnl);


    }





    I also looked into AccountItem.RealizedProfitLoss ...

    Is there a method for looking up the Chart Trader RealizedProfitLoss value?

    Thanks
    Bruce
    Last edited by traderhawk; 03-01-2023, 07:48 AM.

    #2
    Hello traderhawk,

    That is the Position PnL, are you using an ATM strategy that was submitted from a NinjaScript strategy? The code used are using is only for the use case of where a NinjaScript strategy used the ATM methods to submit an ATM and control it. If you are manually trading that code wont work for that purpose.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Yes I'm using an ATM Strategy..

      AtmStrategyCreate(OrderAction.Buy, OrderType.StopLimit, limitPrice, stopPrice, TimeInForce.Gtc, orderId, "MainStrategy", atmStrategyId, (atmCallbackErrorCode, atmCallBackId) =>
      {
      //check that the atm strategy created did not result in error, and that the requested atm strategy matches the id in callback
      if (atmCallbackErrorCode == ErrorCode.NoError && atmCallBackId == atmStrategyId)
      {
      /some code
      }

      Is the Position PnL available from code?​

      The position PnL value also changes when more trades are taken so its not related just to the current atmStrategyId its a total PnL as from what I see.. but it does show the unrealizedProfitLoss during a running order...and when that order is flat the remaining number is a total..

      Comment


        #4
        Hello traderhawk,

        You can use the Unrealized PnL for that purpose:



        Your NinjaScript strategy won't have access to the total PnL in this use case because you are using ATM's. If you have multiple positions opened by multiple ATM's you would have to run GetAtmStrategyUnrealizedProfitLoss for each of the active ATM's and then add all of the PnL together to get a total.

        The SampleATMStrategy script that comes with the platform shows the correct way to check the ATM status and get its unrealized PnL, your code would be very similar to that to check the PNL.
        JesseNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by JoMoon2024, Today, 06:56 AM
        0 responses
        6 views
        0 likes
        Last Post JoMoon2024  
        Started by Haiasi, 04-25-2024, 06:53 PM
        2 responses
        19 views
        0 likes
        Last Post Massinisa  
        Started by Creamers, Today, 05:32 AM
        0 responses
        6 views
        0 likes
        Last Post Creamers  
        Started by Segwin, 05-07-2018, 02:15 PM
        12 responses
        1,786 views
        0 likes
        Last Post Leafcutter  
        Started by poplagelu, Today, 05:00 AM
        0 responses
        3 views
        0 likes
        Last Post poplagelu  
        Working...
        X