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

Re: [amibroker] Is it possible to add default values to functions ?



PureBytes Links

Trading Reference Links

Hi - Function will bomb if you don't pass it expected # of args, but I think 
you could set it up so that, for example,  it will use default if you pass 
it 0 for periods:

function KAMA(P,Periods)
{

Periods = IIF( Periods == 0, 14, Periods );

Direction = P - Ref(P,-periods);
Volatility = Sum(abs(P-Ref(P,-1)),periods);
Volatility =IIf(Volatility>0,Volatility,0.00001);
ER = abs(Direction/Volatility);
FastSC = 2/(2 + 1);//FastSC = 2/(2 + 1);//Standard
SlowSC = 2/(30 + 1);//SlowSC = 2/(30 + 1);
SSC = ER * (FastSC - SlowSC) + SlowSC;
Constant = SSC^2;
return AMA( P, Constant );
}


----- Original Message ----- 
From: "Klaus Korneker" <korneker@xxxxxx>
To: <amibroker@xxxxxxxxxxxxxxx>
Sent: Tuesday, February 21, 2006 12:53 PM
Subject: [amibroker] Is it possible to add default values to functions ?


> Hello,
>
> is it possible to add default values to functions.
>
> I want to define any function as shown below. However if i add nothing 
> into
> the brackets, the default value for periods should be used.
> IS this possible ?
>
>
> function KAMA(P,Periods)
> {
> Direction = P - Ref(P,-periods);
> Volatility = Sum(abs(P-Ref(P,-1)),periods);
> Volatility =IIf(Volatility>0,Volatility,0.00001);
> ER = abs(Direction/Volatility);
> FastSC = 2/(2 + 1);//FastSC = 2/(2 + 1);//Standard
> SlowSC = 2/(30 + 1);//SlowSC = 2/(30 + 1);
> SSC = ER * (FastSC - SlowSC) + SlowSC;
> Constant = SSC^2;
> return AMA( P, Constant );
> }
>
>
>
> Regards
>
> Klaus
>
>
>
>
>
> 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 other support material please check also:
> http://www.amibroker.com/support.html
>
>
> Yahoo! Groups Links
>
>
>
>
>
>
> 




------------------------ Yahoo! Groups Sponsor --------------------~--> 
Try Online Currency Trading with GFT. Free 50K Demo. Trade 
24 Hours. Commission-Free. 
http://us.click.yahoo.com/RvFikB/9M2KAA/U1CZAA/GHeqlB/TM
--------------------------------------------------------------------~-> 

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 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/

<*> 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/