NexusFi: Find Your Edge


Home Menu

 





P&L indicator for NT7 or NT8


Discussion in NinjaTrader

Updated
    1. trending_up 1,916 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: 68 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?
DOM in QTrader vs Bookmap
Platforms and Indicators
Time, Futures, Scalping, Treasurys
Treasury Notes and Bonds
Knowledge Nuggets from the Web
The Elite Circle
RSI Values Scale
NinjaTrader
IBD Accumulation/Distribution Rating
NinjaTrader
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Big Mike in Ecuador
11 thanks
Just another trading journal: PA, Wyckoff & Trends
8 thanks
Want your NinjaTrader indicator created, free?
3 thanks
Gradient Divergence Trading
2 thanks
Knowledge Nuggets from the Web
2 thanks
  #3 (permalink)
 
sam028's Avatar
 sam028 
Site Moderator
 
Posts: 3,765 since Jun 2009
Thanks Given: 3,825
Thanks Received: 4,630



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 Twitter Reply With Quote
  #4 (permalink)
 
Bullywig's Avatar
 Bullywig 
Chicago
 
Experience: Intermediate
Platform: NinjaTrader
Broker: NinjaTrader Brokerage
Trading: FDAX, NQ, HG, SI, CL
Posts: 68 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


© 2024 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 - Privacy Policy - Sitemap - Downloads - Top
no new posts