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)
Short report:
I tried with Replay101 account and I think it works also if feed indicatr is in another chart than position indicator but position indicator has always to be started last.
It also works from strategy directly (see above) but I think itīs running out of sync.
If you restart position indicator and next restart strategy than it seems that it is sync and right values.
I also put in a position counter and average position calculation (total value / counter).
Just now I am thinking about calling position indicator directly in each strategy, but that would mean that position indicator is not started once but because I run multiple strategies (separate for long and short and as I told before separate for each contract) about 22 times.
Now I have doubts if there could occur problems with the global settings when position indicator is called more than one time.
I would call the indicator that way:
private rfkPositionMonitor ratfink; // Variables section
ratfink=rfkPositionMonitor ("Replay101"); // initialize section - account name I would make a get set later
What do you think about multiple times calling position indicator via strategy?
The idea is that the position indicator only exists once, it should not be called from multiple places.
The feed indicator (or code) can be called any number of times, but is only required to be called once per instrument.
A synchronisation issue should only show up if some things are running COBC=false and some are running COBC=true, even then it will be a transient currency amount that your strategy positions would be experiencing anyway. Unless of course there are bugs to fix.
You can simply access the ongoing total value directly in your strategy e.g.:
Happy to work on developing this as we go, but it shouldn't need to be complicated.
Just checked in my setup, I have the Feeds running in COBC=false (this is the code default), otherwise price update can be delayed due to Ninja random chart/strat/indy processing order.
To get a test/illustration clear in your mind, do the following:
1) Make no changes to your existing strategies.
2) Create a separate Ninja Workspace, will be running in background.
3) Add two charts to this new workspace.
3a) To the first chart add one series for each of your instruments, e.g. 1min, or your t/f choice.
3b) To each instrument series in this chart add one feed indicator, making sure to select the correct series source each time. They will be invisible as Overlay is true and no plots are made.
4) Make the other chart of whatever series has the widest session span e.g. ES, again 1min or your t/f choice.
4a) Just add the positionMonitor to this other chart. If COBC is true (the code default) it will be a delayed position update at that bar, or if switched to false it will be a live rolling update.
You should see that the position total plots fine all the while regardless of when you start and stop strategies, or use ChartTrader.
If only one instrument is active you should see the the monitor value matches ChartTrader's value (can be in a third chart) so long as the monitor is switched to COBC=false. I left the default set at true to match strategies which are usually run in COBC=true.
Let me know if this helps.
Thought: If it is easier/better maybe use the Market Analyser route that @Tasker_182 suggested?
Edit: just realised you maybe can't get back the info you want that way, I don't know the MA hardly at all.
I am working a lot backtesting my strategies using your indicator and I can confirm that itīs working fine if you start strategy (of course) after starting indicator. I have still position and feed in one multichart together, strategies are taking the global variable of totalvalue.
Working with MA makes no sense to me because I need the total value or average value in my strategy (I also added a calculation for average value as global variable, itīs working, too but has not improved strategy).
As I made some interesting observations my question to you:
Could you add a second account - I would like to test opening "dummy" positions on SIM parallel with real account. I think you got my question, if not, again: I want to open e.g. YM, CL, ES trades on SIM and CL on trading account but I need the total of all 4 positions.