NexusFi: Find Your Edge


Home Menu

 





P&L indicator for NT7 or NT8


Discussion in NinjaTrader

Updated
    1. trending_up 2,459 views
    2. thumb_up 4 thanks given
    3. group 6 followers
    1. forum 3 posts
    2. attach_file 1 attachments




 
Search this Thread
  #1 (permalink)
 
Bullywig's Avatar
 Bullywig 
Chicago
 
Experience: Intermediate
Platform: NinjaTrader
Broker: NinjaTrader Brokerage
Trading: FDAX, NQ, HG, SI, CL
Posts: 71 since Oct 2015
Thanks Given: 42
Thanks Received: 22

Does anything exist like this on the forum? A profit and loss indicator that you can place on your chart?



If not, can someone point me in the right direction as far as starting to code this as a custom indicator?


Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
My Rant with AMP Futures
Trading Reviews and Vendors
[WTS] ATAS Lifetime ULTRA license – EU buyers only – …
Platforms and Indicators
I developed a free AI-powered (Kronos) forecasting indic …
The Elite Circle
EA
Platforms and Indicators
requesting .nrd replay files from 2026 spy and qqq
The Elite Circle
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Big Mike in Ecuador
4 thanks
Trading Journal (Neural Network Production Pipeline Mode …
4 thanks
Trading psychology articles
4 thanks
Would you consider buying or leasing an algo?
4 thanks
The Scalpers Journey
2 thanks
  #3 (permalink)
 
sam028's Avatar
 sam028 
Site Administrator
 
Posts: 3,779 since Jun 2009
Thanks Given: 3,840
Thanks Received: 4,709



Bullywig View Post
Does anything exist like this on the forum? A profit and loss indicator that you can place on your chart?



If not, can someone point me in the right direction as far as starting to code this as a custom indicator?

Here is a method I'm using, you'll have to add the plot but that's basically it.
 
Code
                            
private bool findPosition(string account, string myInstrument) {        

  
double avgprice = 0.0;
  
int posCount, quantity;
  
String accName, d, fullname, position;
  for (
int i=0;i <= NinjaTrader.Cbi.Globals.Accounts.Count - 1; i++) {
    
accName = NinjaTrader.Cbi.Globals.Accounts[i].Name;
    if (
accName == account) {
      
posCount = NinjaTrader.Cbi.Globals.Accounts[i].Orders.Positions.Count;
      for(
int j=0;j<posCount;j++) {
        
int p=NinjaTrader.Cbi.Globals.Accounts[i].Positions.Count;
        for (
int k=0;k<p;k++){                            
           
avgprice = NinjaTrader.Cbi.Globals.Accounts[i].Positions[k].AvgPrice;
           
fullname = NinjaTrader.Cbi.Globals.Accounts[i].Positions[k].Instrument.FullName;
           
position = NinjaTrader.Cbi.Globals.Accounts[i].Positions[k].MarketPosition.ToString();
           
quantity = NinjaTrader.Cbi.Globals.Accounts[i].Positions[k].Quantity;
                            
           if (
fullname == myInstrument) {
             Print(
"You're already "+quantity+" "+position+" at "+avgprice+" for "+fullname+" account: "+accName);
               return 
false;
           }
         }
       }
       
int z=0;
     }
   }
return 
true;
} 


Success requires no deodorant! (Sun Tzu)
Reply With Quote
  #4 (permalink)
 
Bullywig's Avatar
 Bullywig 
Chicago
 
Experience: Intermediate
Platform: NinjaTrader
Broker: NinjaTrader Brokerage
Trading: FDAX, NQ, HG, SI, CL
Posts: 71 since Oct 2015
Thanks Given: 42
Thanks Received: 22


sam028 View Post
Here is a method I'm using, you'll have to add the plot but that's basically it.
 
Code
                            
private bool findPosition(string account, string myInstrument) {        

  
double avgprice = 0.0;
  
int posCount, quantity;
  
String accName, d, fullname, position;
  for (
int i=0;i <= NinjaTrader.Cbi.Globals.Accounts.Count - 1; i++) {
    
accName = NinjaTrader.Cbi.Globals.Accounts[i].Name;
    if (
accName == account) {
      
posCount = NinjaTrader.Cbi.Globals.Accounts[i].Orders.Positions.Count;
      for(
int j=0;j<posCount;j++) {
        
int p=NinjaTrader.Cbi.Globals.Accounts[i].Positions.Count;
        for (
int k=0;k<p;k++){                            
           
avgprice = NinjaTrader.Cbi.Globals.Accounts[i].Positions[k].AvgPrice;
           
fullname = NinjaTrader.Cbi.Globals.Accounts[i].Positions[k].Instrument.FullName;
           
position = NinjaTrader.Cbi.Globals.Accounts[i].Positions[k].MarketPosition.ToString();
           
quantity = NinjaTrader.Cbi.Globals.Accounts[i].Positions[k].Quantity;
                            
           if (
fullname == myInstrument) {
             Print(
"You're already "+quantity+" "+position+" at "+avgprice+" for "+fullname+" account: "+accName);
               return 
false;
           }
         }
       }
       
int z=0;
     }
   }
return 
true;
} 


Do you have a full example of a coded strategy with this included? I'm new to coding, and it would help to see something complete so I can see where everything should be placed. Thanks for sending this along though. It tells me it's a bit more complicated than I had anticipated, but nonetheless, worth diving into to see if I can make it work in the end.

Cheers!


Started this thread Reply With Quote




Last Updated on November 10, 2018


© 2026 NexusFi®, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Downloads - Top
no new posts