[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[amibroker] Re: How to implement: VarSelect( var1, var2, var3, ... , Varn, n);
PureBytes Links
Trading Reference Links
|
Small bug in my "cold" (heh): The "js = GetScriptObject();" line
needs to be moved to after the <% ... %> script block. It worked for
me where it was because I had a previous script block.
--- In amibroker@xxxxxxxxxxxxxxx, "liberte721" <daniel.laliberte@xxx>
wrote:
>
> You can use jscript to pass any number of arguments and select a
> value. I provide two ways in the cold that follows. The first way
> (selectVar) selects an AFL variable by its name and returns that.
I
> did this because I thought we could only pass simple numbers and
> strings to functions, but we can pass AFL arrays as well, so the
> second function, selectValue, selects the nth value and returns
that.
>
> Keep in mind that all your expressions will be evaluated, thus
> increasing the computation time. It might be better to follow the
> suggestion to conditionally evaluate only the code you need.
>
> EnableScript("jscript");
> // Get script object to access the functions.
> js = GetScriptObject();
>
> <%
> function selectVar( n )
> // Return the value of the AFL variable named by the nth argument
> after n, origin 0.
> {
> var args = arguments;
> var selectVarName = args[ n + 1 ];
> var value = AFL(selectVarName);
> return value;
> }
>
> function selectValue( n )
> // Return the nth value after n.
> // Values can be numbers or arrays.
> {
> var value = arguments[ n + 1 ];
> return value;
> }
> %>
>
> // Assign number or array to each variable
> foo0 = 0;
> foo1 = barindex();
> foo2 = Close;
>
> myvar = js.selectVar(1, "foo0", "foo1", "foo2");
> //Plot(myvar, "my var", colorBlack, styleOwnScale);
>
> myval = js.selectValue(2, 0, barindex(), Close);
> Plot(myval, "myval", colorRed, styleOwnScale);
>
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
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/amibroker/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/amibroker/join
(Yahoo! ID required)
<*> To change settings via email:
mailto:amibroker-digest@xxxxxxxxxxxxxxx
mailto:amibroker-fullfeatured@xxxxxxxxxxxxxxx
<*> To unsubscribe from this group, send an email to:
amibroker-unsubscribe@xxxxxxxxxxxxxxx
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
|
- Prev by Date:
[amibroker] Re: Calling a function
- Next by Date:
Re: [amibroker] Re: How to implement: VarSelect( var1, var2, var3, ... , Varn, n);
- Previous by thread:
[amibroker] Re: How to implement: VarSelect( var1, var2, var3, ... , Varn, n);
- Next by thread:
Re: [amibroker] Re: How to implement: VarSelect( var1, var2, var3, ... , Varn, n);
- Index(es):
|
|
|