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

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 aa731, Today, 02:54 AM
              0 responses
              4 views
              0 likes
              Last Post aa731
              by aa731
               
              Started by thanajo, 05-04-2021, 02:11 AM
              3 responses
              470 views
              0 likes
              Last Post tradingnasdaqprueba  
              Started by Christopher_R, Today, 12:29 AM
              0 responses
              10 views
              0 likes
              Last Post Christopher_R  
              Started by sidlercom80, 10-28-2023, 08:49 AM
              166 responses
              2,237 views
              0 likes
              Last Post sidlercom80  
              Started by thread, Yesterday, 11:58 PM
              0 responses
              5 views
              0 likes
              Last Post thread
              by thread
               
              Working...
              X