Dark Theme
Light Theme
Trading Articles
Article Categories
Article Tools
Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to
register in order to view the content of the threads and start contributing to our community.
It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
Updated November 11, 2018
trending_up
1,916 views
thumb_up
4 thanks given
group
6 followers
forum
3 posts
attach_file
1 attachments
November 9th, 2018, 02:08 PM
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?
Can you help answer these questions from other members on NexusFi?
Best Threads (Most Thanked) in the last 7 days on NexusFi
November 10th, 2018, 07:13 AM
Posts: 3,765 since Jun 2009
Thanks Given: 3,825
Thanks Received: 4,630
Bullywig
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)
November 10th, 2018, 08:04 PM
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
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!
Last Updated on November 10, 2018