Announcement

Collapse
No announcement yet.

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.

    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.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by NullPointStrategies, Today, 05:17 AM
        0 responses
        53 views
        0 likes
        Last Post NullPointStrategies  
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        130 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        70 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        44 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        49 views
        0 likes
        Last Post TheRealMorford  
        Working...
        X