NexusFi: Find Your Edge


Home Menu

 





P&L indicator for NT7 or NT8


Discussion in NinjaTrader

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




 
Search this Thread

P&L indicator for NT7 or NT8

  #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?
Increase in trading performance by 75%
The Elite Circle
Better Renko Gaps
The Elite Circle
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
How to apply profiles
Traders Hideout
ZombieSqueeze
Platforms and Indicators
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Just another trading journal: PA, Wyckoff & Trends
34 thanks
Tao te Trade: way of the WLD
24 thanks
Bigger Wins or Fewer Losses?
19 thanks
GFIs1 1 DAX trade per day journal
16 thanks
Vinny E-Mini & Algobox Review TRADE ROOM
13 thanks
  #3 (permalink)
 
sam028's Avatar
 sam028 
Site Moderator
 
Posts: 3,765 since Jun 2009
Thanks Given: 3,825
Thanks Received: 4,629



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 - Downloads - Top
no new posts