[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [amibroker] Re: How to implement: VarSelect( var1, var2, var3, ... , Varn, n);



PureBytes Links

Trading Reference Links

Herman,

You are right about that.  This was just a simple example with only a period argument.  In my real system, this function is larger and called by a more complex function (and also includes the results of other pre-computed filters in the list).  You could add any number of arguments that would be required by the most complex filter you want to have, or you could have global variables that are set up by parameters for the arguments needed by each particular filter.

It is a very versatile construct for specifying functions dynamically.

Best regards,
Dennis


Clever...probably the switch might be the most versatile solution...

They can even be nested to provide F1(F2)..

thanks again guys!

herman

For tips on developing Real-Time Auto-Trading systems visit:

Wednesday, February 6, 2008, 11:49:17 AM, you wrote:

>
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 = Cbreak;
  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
 
__._,_.___

Please note that this group is for discussion between users only.

To get support from AmiBroker please send an e-mail directly to
SUPPORT {at} amibroker.com

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/

For other support material please check also:
http://www.amibroker.com/support.html




Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe

__,_._,___