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 following user says Thank You to resist for this post:
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.
The following user says Thank You to ratfink for this post:
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.
Last edited by ratfink; August 9th, 2015 at 03:01 PM.
The following 3 users say Thank You to ratfink for this post:
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.