Code example for displaying UNREALIZED PnL for ALL open positions for 1 Account? - Traders Hideout | futures io social day trading
futures io futures trading


Code example for displaying UNREALIZED PnL for ALL open positions for 1 Account?
Updated: Views / Replies:3,869 / 31
Created: by vincentmarchi Attachments:4

Welcome to futures io.

(If you already have an account, login at the top of the page)

futures io is the largest futures trading community on the planet, with over 90,000 members. At futures io, our goal has always been and always will be to create a friendly, positive, forward-thinking community where members can openly share and discuss everything the world of trading has to offer. The community is one of the friendliest you will find on any subject, with members going out of their way to help others. Some of the primary differences between futures io and other trading sites revolve around the standards of our community. Those standards include a code of conduct for our members, as well as extremely high standards that govern which partners we do business with, and which products or services we recommend to our members.

At futures io, our focus is on quality education. No hype, gimmicks, or secret sauce. The truth is: trading is hard. To succeed, you need to surround yourself with the right support system, educational content, and trading mentors – all of which you can find on futures io, utilizing our social trading environment.

With futures io, you can find honest trading reviews on brokers, trading rooms, indicator packages, trading strategies, and much more. Our trading review process is highly moderated to ensure that only genuine users are allowed, so you don’t need to worry about fake reviews.

We are fundamentally different than most other trading sites:
  • We are here to help. Just let us know what you need.
  • We work extremely hard to keep things positive in our community.
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts.
  • We firmly believe in and encourage sharing. The holy grail is within you, we can help you find it.
  • We expect our members to participate and become a part of the community. Help yourself by helping others.

You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

Reply
 4  
 
Thread Tools Search this Thread
 

Code example for displaying UNREALIZED PnL for ALL open positions for 1 Account?

  #11 (permalink)
Elite Member
Wrocław, Poland
 
Futures Experience: Intermediate
Platform: NinjaTrader, Racket
Favorite Futures: Ockham's razor
 
gregid's Avatar
 
Posts: 651 since Aug 2009
Thanks: 321 given, 605 received

Here is the reference in NT help guide:
NinjaTrader Version 7

Reply With Quote
The following user says Thank You to gregid for this post:
 
  #12 (permalink)
Elite Member
Dallas Texas United States
 
Futures Experience: Advanced
Platform: NinjaTrader
Favorite Futures: ES
 
vincentmarchi's Avatar
 
Posts: 9 since Feb 2013
Thanks: 5 given, 3 received

My brother, you are the bomb diggity dizzle! Thank you for the direction! I will work on this and post results when I get it working! Thank you soooo much! Genius!

Reply With Quote
 
  #13 (permalink)
Elite Member
Berlin Germany /Alicante Spain
 
Futures Experience: Intermediate
Platform: NinjaTrader
Broker/Data: DDT/Rithmic, Global/CQG, IB, Mirus(Ninja)/MarketDelta
Favorite Futures: Futures
 
Posts: 148 since Jan 2010
Thanks: 362 given, 66 received



vincentmarchi View Post
My brother, you are the bomb diggity dizzle! Thank you for the direction! I will work on this and post results when I get it working! Thank you soooo much! Genius!

Have you found a way to show total unrealized P/L of all actual open positions in NinjaTrader and could you provide a code snippet?
I try to run several (about 10) charts with automated strategy on each and I want to track the total P/L if all position together every minute, first for statistic, later I want to change strategies to stop trading.

As I read here I could code a multiinstrument strategy but I think that s very difficult for me, therefore I want first only to track open P/L to the output window or a dataseries or something else similar.

Reply With Quote
The following user says Thank You to resist for this post:
 
  #14 (permalink)
Elite Member
Berlin Germany /Alicante Spain
 
Futures Experience: Intermediate
Platform: NinjaTrader
Broker/Data: DDT/Rithmic, Global/CQG, IB, Mirus(Ninja)/MarketDelta
Favorite Futures: Futures
 
Posts: 148 since Jan 2010
Thanks: 362 given, 66 received

here is a picture what I mean, I want to track the total profit of this minute 23:
Please register on futures.io to view futures trading content such as post attachment(s), image(s), and screenshot(s).

then I get minute 24:
Please register on futures.io to view futures trading content such as post attachment(s), image(s), and screenshot(s).

and next next next minute - so I get a picture how PnL was developing until closing strategies automatically.

Reply With Quote
The following 2 users say Thank You to resist for this post:
 
  #15 (permalink)
Elite Member
Birmingham UK
 
Futures Experience: Intermediate
Platform: NinjaTrader
Broker/Data: IG/eSignal
Favorite Futures: Dax
 
ratfink's Avatar
 
Posts: 3,336 since Dec 2012
Thanks: 11,276 given, 7,090 received


resist View Post
so I get a picture how PnL was developing until closing strategies automatically.

Had a quick go at this and a basic solution seems to work quite well.

The attached file includes two indicators, rfkPositionMonitor that you add to any one single chart, it will plot a value for the combined currency total of open positions and report to the output window on each bar close. Assumes the chart session spans all others, your choice of timeframe, I've used 1 minute for testing here.

You need to specify the account name to monitor in the Parameters section, default is Sim101.

The second is a slave feed indicator (rfkPositionFeed) that you add to one chart of any instrument you wish to monitor, it simply provides a global feed of closing price for the monitor to use. Alternatively you could just cut and paste the rfkCList.set line into your strategy then you don't need the feed indicator.

The totalValue is global so can be accessed wherever you want.

Have a look/play and we can discuss problems or ways to go or just do your own thing if it's a good enough base. It seems to work fine but treat as Alpha code, I will start a support thread if required, or you may just want to cut/paste code into strategies and/or your own monitor scheme instead.

Cheers

Travel Well
Attached Files
Register to download File Type: zip rfkPositionMonitor_1_0A1.zip (4.2 KB, 38 views)
Reply With Quote
The following 3 users say Thank You to ratfink for this post:
 
  #16 (permalink)
Elite Member
Cedar Rapids, iowa
 
Futures Experience: Intermediate
Platform: Ninjatrader
Broker/Data: Ninjatrader - Continuum
Favorite Futures: 6E, TF, 6J
 
Tasker_182's Avatar
 
Posts: 626 since Aug 2009
Thanks: 426 given, 1,126 received

Answer
This post has been selected as an answer to the original posters question Answer


resist View Post
Have you found a way to show total unrealized P/L of all actual open positions in NinjaTrader and could you provide a code snippet?
I try to run several (about 10) charts with automated strategy on each and I want to track the total P/L if all position together every minute, first for statistic, later I want to change strategies to stop trading.

As I read here I could code a multiinstrument strategy but I think that s very difficult for me, therefore I want first only to track open P/L to the output window or a dataseries or something else similar.

Why not just use the Market Analyzer? You can add columns to show realized and unrealized, current position, position size as well as a totaling row.

Please register on futures.io to view futures trading content such as post attachment(s), image(s), and screenshot(s).

"Money is better than poverty, if only for financial reasons." - Woody Allen
Reply With Quote
The following 4 users say Thank You to Tasker_182 for this post:
 
  #17 (permalink)
Elite Member
ITAJAI SC/BRAZIL
 
Futures Experience: Beginner
Platform: NinjaTrader
Broker/Data: Clear Corretora
Favorite Futures: DOLFUT, WINFUT
 
Posts: 184 since Jun 2014
Thanks: 760 given, 132 received

@Tasker_182, with MA you cannot disable trading automatcally, by bots. At least until NT8 I believe.

@ratfink, I hope test it too.
Do we have to declare any using clause before adding to a strategy that line you suggested ?

Reply With Quote
The following user says Thank You to MrTrader for this post:
 
  #18 (permalink)
Elite Member
Birmingham UK
 
Futures Experience: Intermediate
Platform: NinjaTrader
Broker/Data: IG/eSignal
Favorite Futures: Dax
 
ratfink's Avatar
 
Posts: 3,336 since Dec 2012
Thanks: 11,276 given, 7,090 received


MrTrader View Post
@Tasker_182, with MA you cannot disable trading automatcally, by bots. At least until NT8 I believe.

@ratfink, I hope test it too.
Do we have to declare any using clause before adding to a strategy that line you suggested ?

Nope. Just refer to it using the class name prefix, same as in the indycode.

In fact I just realised you can probably call the existing indicators directly from strategies but i haven't tested it. Irrelevant as they're just guinea/pounds pigs/fowl or whatever.

Travel Well
Reply With Quote
The following 2 users say Thank You to ratfink for this post:
 
  #19 (permalink)
Elite Member
Berlin Germany /Alicante Spain
 
Futures Experience: Intermediate
Platform: NinjaTrader
Broker/Data: DDT/Rithmic, Global/CQG, IB, Mirus(Ninja)/MarketDelta
Favorite Futures: Futures
 
Posts: 148 since Jan 2010
Thanks: 362 given, 66 received

@ ratfink

I tested it. itīs a great step in the right direction ithink. thank you.

You have to open a multi instrument chart and to put in the feed indicator for each instrument once in that multiindicator chart, also position indicator once, than it works.

I added to the position indicator a snippet to print an output of the total open profit to output window, too. That works already, too.

to add one line to my strategies or to add the feed indicator in the also on my workspace opened 11 single instrument charts didnīt work, feed and position have to be in same chart. nd there has to be a feed with input of each instrument.

Next step is the question how to tell my strategies to TP or SL (betteer to §close§) all open positions when a profit threshold (depending also on the quantity of positions) is hit - wilkl be difficult I think.

Is here somewhere a thred where somebody else tried that?

Reply With Quote
The following 2 users say Thank You to resist for this post:
 
  #20 (permalink)
Elite Member
Birmingham UK
 
Futures Experience: Intermediate
Platform: NinjaTrader
Broker/Data: IG/eSignal
Favorite Futures: Dax
 
ratfink's Avatar
 
Posts: 3,336 since Dec 2012
Thanks: 11,276 given, 7,090 received



resist View Post
@ ratfink

I tested it. itīs a great step in the right direction ithink. thank you.

You have to open a multi instrument chart and to put in the feed indicator for each instrument once in that multiindicator chart, also position indicator once, than it works.

I added to the position indicator a snippet to print an output of the total open profit to output window, too. That works already, too.

to add one line to my strategies or to add the feed indicator in the also on my workspace opened 11 single instrument charts didnīt work, feed and position have to be in same chart. nd there has to be a feed with input of each instrument.

Next step is the question how to tell my strategies to TP or SL (betteer to §close§) all open positions when a profit threshold (depending also on the quantity of positions) is hit - wilkl be difficult I think.

Is here somewhere a thred where somebody else tried that?

Hi @resist, Glad you found it a useful start.

I have no idea why you don't see it working when feed and monitor are in different charts, that's how this was tested and I run loads of my own other similar stuff, both single and multi-threaded, with no problems.

The only issue to be aware of is if you are editing and recompiling anything then all instances in active charts/strats need an F5 so they get to use the same assembly. Otherwise just opening closing workspaces, adding and removing indicators or whatever works as normal.

Communication back to the strategy is easy too, I can add an example of that when I am next on PC (ChromeBook only at moment.)

Cheers

[nb no space in futures.io (formerly BMT) user name notifications eg @ratfink]

Travel Well
Reply With Quote
The following 2 users say Thank You to ratfink for this post:

Reply



futures io > > > Code example for displaying UNREALIZED PnL for ALL open positions for 1 Account?

Thread Tools Search this Thread
Search this Thread:

Advanced Search



Upcoming Webinars and Events (4:30PM ET unless noted)

Linda Bradford Raschke: Reading The Tape

Elite only

Adam Grimes: TBA

Elite only

NinjaTrader: TBA

January

Ran Aroussi: TBA

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
Possible to track outside account positions in TWS? swinger IB Trader Workstation 1 February 18th, 2015 01:51 AM
Only Close Open Positions? davetapson AmiBroker 0 September 23rd, 2014 04:59 AM
Open Traders Positions Athan The Elite Circle 10 March 31st, 2013 01:29 AM
Displaying net PNL patbateman NinjaTrader 0 September 30th, 2012 09:02 PM
Account position: How to differentiate positions arjfca The Elite Circle 5 February 5th, 2011 03:27 PM


All times are GMT -4. The time now is 01:57 AM.

Copyright © 2017 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io
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.
no new posts
Page generated 2017-12-11 in 0.14 seconds with 40 queries on phoenix via your IP 54.226.34.209