PureBytes Links
Trading Reference Links
|
Hello Tomasz,
Thankyou very much for the extreamly fast response. In my post, to
keep it short I actually over simplified my problem and as a result I
think misled you.
I actually wanted the function to return an element at a time into
the loop for further calculations - I just put the plot statement to
see what actually coming across which actually caused the confusion.
I have attached parts of my real code which does not appear to work -
calling the StochRSI function within a loop. Also is there an easy
way to monitor what is being returned. Please help. Thankyou in
advance
//{==============================
function StochRSI(i,Periods)
{
res=(RSI(Periods)-LLV(RSI(Periods),Periods))/(HHV(RSI
(Periods),Periods)-LLV(RSI(Periods),Periods));
result = res[i];//return ith element of the array
return result;
}
//{==============================
//: other codes
//: other codes
//{==============================
for (i = 1; i < BarCount-1; i++ )
{//begin MAIN LOOP
//:
//:
Periods = PreCalculatedArrayOutSidetheLoop[i]; //Periods vary with i
Entry2 =(C[i]*1.1>BBandBot(WPrice[i],BBpds[i], deviations[i] ) ) AND
( StochRSI(i,Periods) > 30 );
//:
//:
}
//{==============================
--- In amibroker@xxxxxxxxxxxxxxx, "Tomasz Janeczko" <groups@xxx>
wrote:
>
> 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@xxx>
> 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/
|