I have designed a number of what I call engine formulas such as MAs, Ranges, Swing Pivots, Signals etc... which are all located in one directory and then can be called multiple times from other studies rather than repeating the same functions and/or routines within each study itself, thereby making design much quicker and very flexible for new studies and enabling easier maintenance on the core routines/functions which are found in only one place. I know that the trade off might be speed access but I have balanced this against ease of development and maintenance and have tried to write code as efficiently as possible to allow multiple calls without killing cpu performance.
However I am stuck with calling the same function using callFunction from a study loaded multiple times i.e. on how to give that call a unique identifier which has worked very well using set and get GlobalValue on multiple calls from the same study or calls from other studies which are uniquely identified. I would like an elegant way to get a solution rather than making a number of copies of the same study and manually uniquely identifying each study.
Is there any way to perform this instancing capability using GlobalValue. Just to show an example of what I am after.
1. I have a file say called MAStd.efs that makes the calls where before preMain() & main() I give a unique ID & setup as:-
var sDesG = "MAStd" // main ID for study
setGlobalValue(sDesG, true); // at the moment not useful
var aArrPS1 = new Array(); // empty arrays created for populating
// values for each callFunction
then within main() I will write a call such as:-
nResult = callFunction("/Functions/fnMA.eff", "fnMA", aArrPS1,
sPS1MAType, ......, sDesG+"PS1");
NOTE; further calls can be made uniquely from within this study by using different identifiers such as sDesG+"PS2" etc...
From other studies they will already have a unique main ID given by sDesG and so each individual call will be uniquely identified.
Once the call is made the formula engine kicks in and returns the appropriate result for MAStd.efs to display.
Within the file fnMA.eff the input from MAStd.efs is handled as follows:-
function fnMA(aArray, sPriceMAType, ......, ID); )
ID = "fnMA"+ID // further identifier added for this function,
... process the input
... return the result
} //end function
The ID that will be for the call described before is "fnMAMAStdPS1" which has to be unique otherwise any routines accessed here will cause incorrect data being passed to other calls if they have the same ID.
When there are no previous values to be accessed and it is a straightforward consecutive calculation then a value is returned and in fact the unique ID does not matter at all to get the right result. No global functions need to be set or played with. When a previous value is required such as in EMAs then further global IDs are created to hold those results for reuse however everything will be based on the ID construction already described before.
As I have mentioned as long as the studies are uniquely identified and the calls from each study are also uniquely identified then you can call the engine formula as many times as you like with no problems. So GlobalVaules are not required in
straightforward calculations but are used to hold values whether
as arrays or individually for later processing.
I have tried to utilize the setGlobalValue function to try to change it for each study that starts out with the same name by then trying to rename each study uniquely ie:-
if (getGlobalValue(sDesG) == true){
sDesG = sDesG+1;
setGlobalValue(sDesG, true);
}
This has not worked as each study is then ID'd the same
I tried to use getValue ("rawtime") and other date functions all to no avail as each would give the same result for the same studies that started out with the same main ID.
I would appreciate any thoughts/comments to assist me to get this last need 'nailed' down and working.
Robert
However I am stuck with calling the same function using callFunction from a study loaded multiple times i.e. on how to give that call a unique identifier which has worked very well using set and get GlobalValue on multiple calls from the same study or calls from other studies which are uniquely identified. I would like an elegant way to get a solution rather than making a number of copies of the same study and manually uniquely identifying each study.
Is there any way to perform this instancing capability using GlobalValue. Just to show an example of what I am after.
1. I have a file say called MAStd.efs that makes the calls where before preMain() & main() I give a unique ID & setup as:-
var sDesG = "MAStd" // main ID for study
setGlobalValue(sDesG, true); // at the moment not useful
var aArrPS1 = new Array(); // empty arrays created for populating
// values for each callFunction
then within main() I will write a call such as:-
nResult = callFunction("/Functions/fnMA.eff", "fnMA", aArrPS1,
sPS1MAType, ......, sDesG+"PS1");
NOTE; further calls can be made uniquely from within this study by using different identifiers such as sDesG+"PS2" etc...
From other studies they will already have a unique main ID given by sDesG and so each individual call will be uniquely identified.
Once the call is made the formula engine kicks in and returns the appropriate result for MAStd.efs to display.
Within the file fnMA.eff the input from MAStd.efs is handled as follows:-
function fnMA(aArray, sPriceMAType, ......, ID); )
ID = "fnMA"+ID // further identifier added for this function,
... process the input
... return the result
} //end function
The ID that will be for the call described before is "fnMAMAStdPS1" which has to be unique otherwise any routines accessed here will cause incorrect data being passed to other calls if they have the same ID.
When there are no previous values to be accessed and it is a straightforward consecutive calculation then a value is returned and in fact the unique ID does not matter at all to get the right result. No global functions need to be set or played with. When a previous value is required such as in EMAs then further global IDs are created to hold those results for reuse however everything will be based on the ID construction already described before.
As I have mentioned as long as the studies are uniquely identified and the calls from each study are also uniquely identified then you can call the engine formula as many times as you like with no problems. So GlobalVaules are not required in
straightforward calculations but are used to hold values whether
as arrays or individually for later processing.
I have tried to utilize the setGlobalValue function to try to change it for each study that starts out with the same name by then trying to rename each study uniquely ie:-
if (getGlobalValue(sDesG) == true){
sDesG = sDesG+1;
setGlobalValue(sDesG, true);
}
This has not worked as each study is then ID'd the same
I tried to use getValue ("rawtime") and other date functions all to no avail as each would give the same result for the same studies that started out with the same main ID.
I would appreciate any thoughts/comments to assist me to get this last need 'nailed' down and working.
Robert
Comment