How many to buy?

Questions about MultiCharts and user contributed studies.
familytrading
Posts: 33
Joined: 24 Sep 2009
Location: Monterey, CA
Been thanked: 3 times
Contact:

How many to buy?

Postby familytrading » 11 Jun 2014

I have searched and don't think I have found a very good solution for this. We have a master portfolio that is trading real time at a different broker in a substantial account. Lets call that program our Pool.

Now I have a new client that wants to trade a similar risk reward profile in his account of the above pool but does not want to commit the capital to trade such. He could enter the pool but wants to have the individual account data on a daily basis.

As an example:

The pool trades 30 different strategies and can have a maximum load of 220 contracts of the same symbol. Now, lets say the following idea needs to be implemented:

Within the pool if we have a position like:

-24 contracts to + 24 contracts the new accounts position would be 0
+25 to +49 would be +1 in new account
+50 to +74 would be +2
+75 to +99 would be +3
+100 to +124 would be +4
+125 or > would be 5

A similar matrix for the short side.

So the first issue is to capture all of the present positions of the 30 strategies in the Pool and have a net real time position. Lets say that is 28, then in real time, upon this number changing to a new value, the system would have to see what our position in the single account was and either add, subtract or do nothing to its account total. If that account total changes, then make a real time trade to the broker with the account.

Simple in concept and if I was in Excel, would be easy to do the calculations. Here are my concerns.

If I use RTD Server to print out the status quantity of each of the pool's strategy, and total that column any time it changed, then I would have the total number of contracts in the pool in real time. Within Excel, I could use a table look up and see what the corresponding number of contracts we needed for the outside account, and that gives us a value. If that value is the same as the previous value in the additional account, I do nothing, but if it changes, I have to either add or sell contracts from the new account.

None of my strategies bars change faster than minutes, but can Excel keep up with all of the strategies without a "write" error or doing something stupid?

I know using VBA I can do the calculations within Excel to do the array look up and that will give me a new quantity. It is also easy to make sure this is a new quantity. Now the other question is can I get this value back into MC, have MC see if the value changed and then make the necessary buys or sells?

I'm not sure this can all work, and I'm real worried about the asynchronous behavior of the signals in real time, so I was avoiding using 30 indicators in the pool with the Global variable but maybe I was making too big of a deal out of this and GV would stand up. If so, then I could do the array look up in MC and change the quantities there and eliminate Excel issues.

Has anyone out there done anything similar to this or am I the first pig to go after this?

Thanks in advance

arjfca
Posts: 1292
Joined: 23 Nov 2010
Has thanked: 725 times
Been thanked: 223 times

Re: How many to buy?

Postby arjfca » 12 Jun 2014

Hello
To transfer data between MC and Excel, you could use Global Variable.

You could code Global Variable in Excel.
MC and Excel get access to the same named variable.
Some Excel function

Code: Select all

Public Declare Function GV_SetNamedString Lib "C:\Program Files (x86)\TS Support\MultiCharts\GlobalVariable.dll" _
(ByVal strElementLoc As String, ByVal intSetValue As String) As Long

Public Declare Function GV_GetNamedString Lib "C:\Program Files (x86)\TS Support\MultiCharts\GlobalVariable.dll" _
(ByVal strElementLoc As String, ByVal strOther As String) As String
I'm using mainly data in a CSV string. To split info I use SplitString function. Look on MC. i had posted the code for Excel and MC

Martin


Return to “MultiCharts”