Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Get ProfitLoss value in indicator?

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

    Get ProfitLoss value in indicator?

    I have attached several strategies (lets say 1 or 2) on chart.
    i want an indicator to plot on lower chart, which will show a line (starting from 0) how the profit/loss, like any typical oscillator line.

    very simple, i think.

    I've found this snippet, but cant make it work:
    Code:
    double proft=0;
    			foreach (Account acct in Cbi.Globals.Accounts)
    			{
    				if (acct.Positions != null)
    				{
    					PositionCollection positions = acct.Positions;
    					foreach (Position pos in positions)
    					{
    						proft += pos.GetProfit();
    						//Print(pos.Account.Name + " " + pos.Instrument + " " + pos.MarketPosition + " " + pos.Quantity + " " + pos.AvgPrice);
    					}
    				}
    			}
    			  Plot0.Set(proft);

    this one says error , that Performance object not found):

    print(Performance.AllTrades.TradesPerformance.Gros sProfit);
    Last edited by ttodua; 06-12-2017, 12:59 PM.

    #2
    Hello selnomeria,

    You should use GetProfitLoss rather than GetProfit.

    See the following section of our helpguide.


    Please let us know if you need further assistance.
    Alan P.NinjaTrader Customer Service

    Comment


      #3
      i think my question was clear.
      i want to return total PL. forget the script i posted, and please offer something, that will give me correct results...
      because the above solution gives me quite different line:

      Comment


        #4
        any reply? thnks in advance.

        Comment


          #5
          Hello,

          I do not have a sample in NT7 however I do have one written in NT8 which will set a plot equal to the PL of the strategy that will match what the trade performance gives.

          You could use this as a reference for building one in NT7.

          Please see the following two sections of the NT7 helpguide which will help you convert the strategy.




          Please let us know if you need further assistance.
          Attached Files
          Alan P.NinjaTrader Customer Service

          Comment


            #6
            I think the problem lies in one variable, which i addresses, and wanted a reply from you...

            that is "Performance" variable (SystemPerformance in NT8 as i see).

            in indciators, that object cant be referred, because gives error " Performance object not found"...
            is there any way to access Performance object from Indicator? that is whole my question i think...
            i have found no way, as i 've said in below posts..

            Comment


              #7
              Hello selnomeria,

              There is no supported way to access a performance object from an indicator.

              See the Performance section of the helpguide,


              Please let us know if you need further assistance.
              Alan P.NinjaTrader Customer Service

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
              0 responses
              579 views
              0 likes
              Last Post Geovanny Suaza  
              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
              0 responses
              334 views
              1 like
              Last Post Geovanny Suaza  
              Started by Mindset, 02-09-2026, 11:44 AM
              0 responses
              101 views
              0 likes
              Last Post Mindset
              by Mindset
               
              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
              0 responses
              554 views
              1 like
              Last Post Geovanny Suaza  
              Started by RFrosty, 01-28-2026, 06:49 PM
              0 responses
              551 views
              1 like
              Last Post RFrosty
              by RFrosty
               
              Working...
              X