PureBytes Links
Trading Reference Links
|
Hello,
Yes it is possible.
Your code does not work because it is coded without any sense.
Inside your loop you generate (BarCount) plots (that many !!!) while you should generate
ONE plot only.
Also LLV and HHV support variable period therefore it makes NO SENSE
to call this funciton in the loop to vary the period.
Correct code for variable-period stochastic is WAY EASIER and SHORTER - actually one line
And it does not require any looping.
//{==============================
//{ this is variable period already !
function Stoch(array,Periods)
{
return(array-LLV(array,Periods))/(HHV(array,Periods)-LLV(array,Periods));
}
Periods = 14 + 20 * Random(); // THIS IS VARIABLE !
SR = Stoch(C,Periods);
Plot (SR,"",colorRed);
Best regards,
Tomasz Janeczko
amibroker.com
----- Original Message -----
From: "iceboundbug" <iceboundbug@xxxxxxxxxxxx>
To: <amibroker@xxxxxxxxxxxxxxx>
Sent: Wednesday, May 09, 2007 12:01 PM
Subject: [amibroker] Mixing a loop with a function - can it be done using Ami ?
> Hello all,
>
> I would appreciate if some one can tell me whether it is possible to
> Mix a loop with a function as detailed before - the code beloe does
> not work.
>
> The reason why I want to do this complicated way is to vary the
> period later on.
>
> Thanks in advance
>
> //{==============================
> //{ Set up base Stoch Series function}
> function Stoch(Bar,Periods)
> {
> {
> result1=(C-LLV(C,Periods))/(HHV(C,Periods)-LLV(C,Periods));
> result = result1[Bar];
> }
> return result;
> }
> //{==============================
> Periods = 14; // later on I want to vary this; hence this approach
> for (Bar = 1 ; Bar < BarCount-1; Bar++ )
> {
> SR = Stoch(bar,Periods);
> Plot (SR[bar],"",colorRed);
> }
>
>
>
>
>
> 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
>
>
>
>
>
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/
|