Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Realized Profits

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

    Realized Profits

    Hi,
    I am currently using "ATM Strategy" to place buy/sell orders within my strategy.

    AtmStrategyCreate(OrderAction.Buy, OrderType.Limit, Low[0], 0, TimeInForce.Day, orderId, "AtmStrategyTemplate", atmStrategyId, (atmCallbackErrorCode, atmCallBackId) => {

    I am trying to get the cumulated realized profit, but could not get using the below code from the "Sample PnL" in the reference section.

    if (Bars.IsFirstBarOfSession)
    {
    // Store the strategy's prior cumulated realized profit and number of trades
    priorTradesCumProfit = SystemPerformance.RealTimeTrades.TradesPerformance .Currency.CumProfit;

    /* NOTE: Using .AllTrades will include both historical virtual trades as well as real-time trades.
    If you want to only count profits from real-time trades please use .RealtimeTrades. */
    }

    CumProfit = SystemPerformance.RealTimeTrades.TradesPerformance .Currency.CumProfit - priorTradesCumProfit;


    Please help.

    #2
    Hello pvincent,

    Thank you for your post.

    Executions from ATM Strategies will not have an impact on the hosting NinjaScript strategy position and PnL - the NinjaScript strategy hands off the execution aspects to the ATM, thus no monitoring via the regular NinjaScript strategy methods will take place (also applies to strategy performance tracking). This means that nothing will be recorded in SystemPerformance for the ATM and SystemPerformance.RealTimeTrades.TradesPerformance .Currency.CumProfit would return 0.

    The simplest way to get the realized PnL would be to get that for the newly closed strategy right before resetting the AtmStrategyId. You could then add that value to a variable holding a running cumulative total if you like, or if you just need the profit for that particular trade you'd just have that as well:



    I'm attaching a simple example that simply prints the realized PnL before resetting to take the next entry.

    Please let us know if we may be of further assistance to you.
    Attached Files

    Comment


      #3
      Thank you. I will check this.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by NullPointStrategies, Yesterday, 05:17 AM
      0 responses
      62 views
      0 likes
      Last Post NullPointStrategies  
      Started by argusthome, 03-08-2026, 10:06 AM
      0 responses
      134 views
      0 likes
      Last Post argusthome  
      Started by NabilKhattabi, 03-06-2026, 11:18 AM
      0 responses
      75 views
      0 likes
      Last Post NabilKhattabi  
      Started by Deep42, 03-06-2026, 12:28 AM
      0 responses
      45 views
      0 likes
      Last Post Deep42
      by Deep42
       
      Started by TheRealMorford, 03-05-2026, 06:15 PM
      0 responses
      50 views
      0 likes
      Last Post TheRealMorford  
      Working...
      X