Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

BarsInProgress use out of OnBarUpdate

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

    BarsInProgress use out of OnBarUpdate

    how can i use GetProfitLoss() for a position on Bars[1] when calling GetProfitLoss() from a timer tick event and not from OBU()?

    same goes for all other methods that are usually being called from OBU() like MarketPosition() and so on...

    #2
    savekad, what you pass in as price would be used as 'current price' for the PnL calculations - you would just need to be aware that the price would be represented by the last updates state of the bars object in OnBarUpdate().

    Comment


      #3
      but how do i know what position it calculates PL for if i have two positions for two instruments on the same strategy script?

      Comment


        #4
        For this purpose please try working with Positions[index].GetProfitLoss().

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by CarlTrading, 03-31-2026, 09:41 PM
        1 response
        65 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 04-01-2026, 02:41 AM
        0 responses
        35 views
        0 likes
        Last Post CarlTrading  
        Started by CaptainJack, 03-31-2026, 11:44 PM
        0 responses
        59 views
        1 like
        Last Post CaptainJack  
        Started by CarlTrading, 03-30-2026, 11:51 AM
        0 responses
        62 views
        0 likes
        Last Post CarlTrading  
        Started by CarlTrading, 03-30-2026, 11:48 AM
        0 responses
        51 views
        0 likes
        Last Post CarlTrading  
        Working...
        X