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)
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.
here is a picture what I mean, I want to track the total profit of this minute 23:
then I get minute 24:
and next next next minute - 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.
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.
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?
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]