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

URGL from positions tab

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

    URGL from positions tab

    I have tried the following but it prints the URGL from strategies tab (historical), not the actual current position URGL from positions tab. I am looking for a function to get the actual current unrealized p&l from the positions tab. Thanks.

    if (!Historical && Position.MarketPosition != MarketPosition.Flat)

    {
    Print("Open PnL: " + Position.GetProfitLoss(Close[0], PerformanceUnit.Points));

    }

    #2
    Hello EthanHunt,

    Thank you for your post.

    There is no means to pull the Unrealized PnL of account's position from the Positions tab.
    You could use the following but the Close[0] (being the instrument the strategy is enabled on) would need to be instrument that the position is open for:

    This is unsupported code:
    Code:
    			foreach (Account acct in Cbi.Globals.Accounts)
    			{
    				if (acct.Positions != null)
    				{
    					PositionCollection positions = acct.Positions;
    					foreach (Position pos in positions)
    					{
    						Print(pos.GetProfitLoss(Close[0], PerformanceUnit.Currency));
    					}
    				}
    			}

    Comment


      #3
      I am just looking for the instrument position URGL, not the account URGL. Thanks.

      Comment


        #4
        Hello EthanHunt,

        Thank you for your patience.

        What do you refer to as the URGL?

        Position.GetProfitLoss would be the Unrealized Profit and Loss of the current position for the strategy.

        Comment


          #5
          I am looking for the actual position URGL. This seems to be different in the "positions" tab and "strategies" tab. The Positions tab seems to reflect actual URGL while the Strategies tab seems to reflect historical as if you'd been in the position from the beginning of the latest signal. So if I start a strategy there is an existing signal with URGL reflected in strategies tab but when it syncs, my actual position starts. When I print Position.GetProfitLoss it prints the amounts that match the Strategies tab URGL (historical as if been in position from the beginning).

          Comment


            #6
            Hello EthanHunt,

            Thank you for your response.

            There is no means around this. The GetProfitLoss will pull the strategy's position PnL which includes that of any historical positions that are open currently. The strategy and account position PnL would not be the same at the moment a historical position of the strategy is opened on the account as the entry points would likely be different.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by BarzTrading, Today, 07:25 AM
            2 responses
            14 views
            1 like
            Last Post BarzTrading  
            Started by devatechnologies, 04-14-2024, 02:58 PM
            3 responses
            19 views
            0 likes
            Last Post NinjaTrader_BrandonH  
            Started by tkaboris, Today, 08:01 AM
            0 responses
            3 views
            0 likes
            Last Post tkaboris  
            Started by EB Worx, 04-04-2023, 02:34 AM
            7 responses
            162 views
            0 likes
            Last Post VFI26
            by VFI26
             
            Started by Mizzouman1, Today, 07:35 AM
            1 response
            10 views
            0 likes
            Last Post NinjaTrader_Gaby  
            Working...
            X