Hello everyone,
I hope someone here will have useful ideas.
External to MC, I am calculating Kelly fractions (% to invest) for different strategies, which considers both returns and their covariances. I have a whole bunch of strategies, and would like each of them to somehow look up this external value (to be recalculated weekly). I prefer to not manually type these values into MC strategies as there are many of them and errors are bound to be made.
The number of contracts to trade per strategy in MC should be calculated from a realtime account (equity) look-up together with the Kelly fraction.
The realtime account look-up is not hard to do, but I have no idea how to import the Kelly values into different strategies. My external programme could produce an excel file or csv, but I don't know how to:
1) reference that file from within MC strategy code, and
2) match the correct Kelly fractions from this file to each strategy
Surely there is a way to do this?
Any help or suggestions are warmly welcomed.
External inputs / values into strategies? e.g. csv lookup? [SOLVED]
- Henry MultiСharts
- Posts: 9165
- Joined: 25 Aug 2011
- Has thanked: 1264 times
- Been thanked: 2957 times
Re: External inputs / values into strategies? e.g. csv looku
Hello Thutch,
You can read from a file with the help of a custom Dll.
It is not provided from the box, you need to write it or search for it over the Internet (as far as I am concerned ELCollections provides an opportunity to read from a file-use our forum search to find it).
In order to call an outside dll from Power Language you need to use DefineDLLFunc code word.
DefineDLLFunc: “dll name”, the parameter dll returns, “the name of the function you refer to (inside the external dll)”, the type of the data you send to the external dll.
You can read from a file with the help of a custom Dll.
It is not provided from the box, you need to write it or search for it over the Internet (as far as I am concerned ELCollections provides an opportunity to read from a file-use our forum search to find it).
In order to call an outside dll from Power Language you need to use DefineDLLFunc code word.
DefineDLLFunc: “dll name”, the parameter dll returns, “the name of the function you refer to (inside the external dll)”, the type of the data you send to the external dll.
Code: Select all
DefineDLLFunc: "dlltest.dll", int, "MC_TEST", int;
- furytrader
- Posts: 354
- Joined: 30 Jul 2010
- Location: Chicago, IL
- Has thanked: 155 times
- Been thanked: 217 times
Re: External inputs / values into strategies? e.g. csv looku
The ELCollections.dll, which is free on the Internet and can be found here:
viewtopic.php?t=2483
... adds a bunch of new commands to EasyLanguage which can be used to retrieve data from .csv files and search it quickly. I've written several strategies that use % probability data generated in a .csv file to evaluate current setups.
The ELCollections.dll .zip file also contains a good user's guide about how to use it.
That's where I would start.
viewtopic.php?t=2483
... adds a bunch of new commands to EasyLanguage which can be used to retrieve data from .csv files and search it quickly. I've written several strategies that use % probability data generated in a .csv file to evaluate current setups.
The ELCollections.dll .zip file also contains a good user's guide about how to use it.
That's where I would start.
- TJ
- Posts: 7745
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2224 times
Re: External inputs / values into strategies? e.g. csv looku
If you using MultiCharts 64 bit version,
please download your add-on here:
viewtopic.php?f=16&t=10094
please download your add-on here:
viewtopic.php?f=16&t=10094
Re: External inputs / values into strategies? e.g. csv looku
Ok, so I eventually understood that these functions need to be imported into MC. And then I read the guide and followed an example.The ELCollections.dll, which is free on the Internet and can be found here:
viewtopic.php?t=2483
... adds a bunch of new commands to EasyLanguage which can be used to retrieve data from .csv files and search it quickly. I've written several strategies that use % probability data generated in a .csv file to evaluate current setups.
The ELCollections.dll .zip file also contains a good user's guide about how to use it.
I can't say I understand it too well, but it does seem to work. Here is the result for some code that calculates the number of contracts to trade per strategy based on an external file called 'last_live_ctrl.csv' (and it runs together with a silly strategy):
Code: Select all
Vars:
millicontracts(0),
equity(0),
Num(MapSC.New),
RowMap(MapSN.New),
ColList(0),
RowNum(0);
MapSC.ReadFile(Num,"C:/Users/Administrator/Desktop/live/last_live_ctrl.csv");
// renames the ctrl file 'Num'
MapSC.BuildRowMap(Num,RowMap,"file");
// "file" is the column with the model name
ColList = MapSC.Get(Num, "millicontractsPerDollarEquity");
// get the contracts column from Num
RowNum = MapSN.Get(RowMap, "CL_trade.csv");
// get the row for the specific model
millicontracts = (ListN.Get(ColList, RowNum));
// assign the millicontracts value
equity = GetRTAccountEquity("DU....");
// paper trading account
If marketposition = 0 then buy floor(millicontracts * equity / 1000) contracts next bar at low limit;
If marketposition > 0 then sell next bar at high limit;
If marketposition = 0 then sellshort floor(millicontracts * equity / 1000) contracts next bar at high limit;
If marketposition < 0 then buytocover next bar at low limit;
Re: External inputs / values into strategies? e.g. csv looku
Hello To communicate between MC and Excel I use XLinput dll and Global VariableHello everyone,
I hope someone here will have useful ideas.
External to MC, I am calculating Kelly fractions (% to invest) for different strategies, which considers both returns and their covariances. I have a whole bunch of strategies, and would like each of them to somehow look up this external value (to be recalculated weekly). I prefer to not manually type these values into MC strategies as there are many of them and errors are bound to be made.
The number of contracts to trade per strategy in MC should be calculated from a realtime account (equity) look-up together with the Kelly fraction.
The realtime account look-up is not hard to do, but I have no idea how to import the Kelly values into different strategies. My external programme could produce an excel file or csv, but I don't know how to:
1) reference that file from within MC strategy code, and
2) match the correct Kelly fractions from this file to each strategy
Surely there is a way to do this?
Any help or suggestions are warmly welcomed.
- XLINPUT could read and write to Excel Sometime it fail because the link between them is fragile. You can't code Excel or play with formula while a communication link is established between them. Timing will cause a problem and MC indicator or signal will bring an error and close the indicator.
- Global variable work very well too.
Martin
Re: External inputs / values into strategies? e.g. csv looku
Ok, so I eventually understood that these functions need to be imported into MC. And then I read the guide and followed an example.The ELCollections.dll, which is free on the Internet and can be found here:
viewtopic.php?t=2483
... adds a bunch of new commands to EasyLanguage which can be used to retrieve data from .csv files and search it quickly. I've written several strategies that use % probability data generated in a .csv file to evaluate current setups.
The ELCollections.dll .zip file also contains a good user's guide about how to use it.
I can't say I understand it too well, but it does seem to work. Here is the result for some code that calculates the number of contracts to trade per strategy based on an external file called 'last_live_ctrl.csv' (and it runs together with a silly strategy):
Code: Select all
Vars:
millicontracts(0),
equity(0),
Num(MapSC.New),
RowMap(MapSN.New),
ColList(0),
RowNum(0);
MapSC.ReadFile(Num,"C:/Users/Administrator/Desktop/live/last_live_ctrl.csv");
// renames the ctrl file 'Num'
MapSC.BuildRowMap(Num,RowMap,"file");
// "file" is the column with the model name
ColList = MapSC.Get(Num, "millicontractsPerDollarEquity");
// get the contracts column from Num
RowNum = MapSN.Get(RowMap, "CL_trade.csv");
// get the row for the specific model
millicontracts = (ListN.Get(ColList, RowNum));
// assign the millicontracts value
equity = GetRTAccountEquity("DU....");
// paper trading account
If marketposition = 0 then buy floor(millicontracts * equity / 1000) contracts next bar at low limit;
If marketposition > 0 then sell next bar at high limit;
If marketposition = 0 then sellshort floor(millicontracts * equity / 1000) contracts next bar at high limit;
If marketposition < 0 then buytocover next bar at low limit;
Hello,
Would you pls tell how did you define all necessary funktions by "DefineDLLFunc:"?
Best Regards
Re: External inputs / values into strategies? e.g. csv lookup?
Look for the elcollection. There is some exemple on the site on how to read a csv file.
I did wrote a little function that will read a specific data on a csv string that is available. Look for splitstring I did wrote it for MC and Excel
Basically,
Splitring(CSV string, position);
Splitstring("Marc, Paul, Ann,Denis",2) will return "Paul" Paul is the 2' data in the csv string
Martin
I did wrote a little function that will read a specific data on a csv string that is available. Look for splitstring I did wrote it for MC and Excel
Basically,
Splitring(CSV string, position);
Splitstring("Marc, Paul, Ann,Denis",2) will return "Paul" Paul is the 2' data in the csv string
Martin
Re: External inputs / values into strategies? e.g. csv lookup?
Ok!
My problem is that I do not find any documentation telling how to define the dlls functions!
Which parameters and types they get and what they return.
These informations needed to define those first lines as....
Externals: "MapSC.Readfile", .......
And so on!
Best regards
Shahram
My problem is that I do not find any documentation telling how to define the dlls functions!
Which parameters and types they get and what they return.
These informations needed to define those first lines as....
Externals: "MapSC.Readfile", .......
And so on!
Best regards
Shahram
Re: External inputs / values into strategies? e.g. csv looku
Hello Thutch,
You can read from a file with the help of a custom Dll.
It is not provided from the box, you need to write it or search for it over the Internet (as far as I am concerned ELCollections provides an opportunity to read from a file-use our forum search to find it).
In order to call an outside dll from Power Language you need to use DefineDLLFunc code word.
DefineDLLFunc: “dll name”, the parameter dll returns, “the name of the function you refer to (inside the external dll)”, the type of the data you send to the external dll.Code: Select all
DefineDLLFunc: "dlltest.dll", int, "MC_TEST", int;
Hi,
Would you pls. tell how I define DLL functions of ELCollection?
I can not find any documentation with all the funktions with their parameters.
For example:
External: "ELCollections.dll", ????,"MapSC.New", ????, ????;
Best regards
Shahram
- ABC
- Posts: 723
- Joined: 16 Dec 2006
- Location: www.abctradinggroup.com
- Has thanked: 125 times
- Been thanked: 410 times
- Contact:
Re: External inputs / values into strategies? e.g. csv lookup? [SOLVED]
Shahram,
there is no need to do that. Simply import the ELD with the functions, read the documentation and study the examples on how to use the functions.
Regards,
ABC
there is no need to do that. Simply import the ELD with the functions, read the documentation and study the examples on how to use the functions.
Regards,
ABC