NexusFi: Find Your Edge


Home Menu

 





P&L indicator for NT7 or NT8


Discussion in NinjaTrader

Updated
    1. trending_up 2,248 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?
Saylors 41-Month HODL Breaks: Strategy Sells 32 BTC as $ …
Prediction Markets & Event Contracts
CFTC Opens First COT Report Review in 20 Years -- Asks W …
Traders Hideout
$134M Ground Entry Contract in Disputed Final Review Aft …
Prediction Markets & Event Contracts
Prediction Markets Expiry Day: Trump Eyes War Exit, $230 …
Prediction Markets & Event Contracts
March Jobs Report Update: 178K Beat vs 59K Expected, Wag …
Traders Hideout
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Sober Journey With S&P
21 thanks
2026 Jlab journal
10 thanks
Lady Vols Primer: Trading Volatility Journal
6 thanks
Algo automated / semi-automated trading anyone?
6 thanks
2026 Fire Horse
5 thanks
  #3 (permalink)
 
sam028's Avatar
 sam028 
Site Moderator
 
Posts: 3,756 since Jun 2009
Thanks Given: 3,825
Thanks Received: 4,632



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 accountstring myInstrument) {        

  
double avgprice 0.0;
  
int posCountquantity;
  
String accNamedfullnameposition;
  for (
int i=0;<= NinjaTrader.Cbi.Globals.Accounts.Count 1i++) {
    
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)
Follow me on X 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 accountstring myInstrument) {        

  
double avgprice 0.0;
  
int posCountquantity;
  
String accNamedfullnameposition;
  for (
int i=0;<= NinjaTrader.Cbi.Globals.Accounts.Count 1i++) {
    
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