Herman,
You do not have to use VarSet() at all if you name your variables in a structured way. VarGet() will get the same variable if the variable name is the same. a = VarGet("myVar"); is the same as a = myVar; This means you can substitute any variable name you want.
VarSelect( "RSI1,MA1,SAR1", n);
Just pick the nth item and use it for the name.
On the other hand, if you did not want to pre-calculate all the possible results, you could do a select case on the item name and return that array.
That is what I do in the Flexible Parameters Example code:
//================================================================ // Useful Multiple Filter Selector // Can use seperate period param for each type // add more filter types from your favorites // function multiFilter(FilterType, array, Periods) { switch(FilterType) { case("none"): f = C; break; case("MA"): f = MA( array, Periods ); break; case("WMA"): f = WMA( array, Periods ); break; case("EMA"): f = EMA( array, Periods ); break; case("DEMA"): f = DEMA( array, Periods ); break; case("TEMA"): f = TEMA( array, Periods ); break; case("LR"): f = LinearReg( array, Periods ); break; case("Median"): f = Median( array, Periods ); break; default: f = C; } return f; }
Best regards, Dennis
On Feb 6, 2008, at 11:10 AM, Herman wrote:
Thanks Dennis, its not the solution I had in mind but assigning indicators to varset() will solve the problem. it just takes a bit more coding.
I was looking for a direct solution, like VarSelect( RSI(), MA(), SAR(), ... , n);
thanks and best regards, herman
For tips on developing Real-Time Auto-Trading systems visit:
Wednesday, February 6, 2008, 11:03:23 AM, you wrote:
> | Herman,
VarGet(""var"+n);
Best regards, Dennis
On Feb 6, 2008, at 10:31 AM, Herman wrote:
Would anyone know how to implement this function:
VarSelect( var1, var2, var3, ... , Varn, n);
where the number of array arguments is variable and the array returned is selected by the last argument?
The intend is to be able to optimize several of these functions and look for synergy between the arrays. For example each array could be a different indicator.
I seem to be missing something here...
TIA, herman | |