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

Re: [amibroker] Problem using IIf() and arrays to track peaks andvalleys



PureBytes Links

Trading Reference Links

Ara --
I tried your suggestion, but that is not it.  Thanks for taking a shot 
at it.

I believe that the problem is with this statement:

recentpeak = IIf(isfalling AND NOT Ref(isfalling,-1), Ref(C,-1), Ref
 > (recentpeak,-1));

For some reason, when the condition "isfalling AND NOT 
Ref(isfalling,-1)" is false, recentpeak is set to its initialized value 
instead of to its previous value.
-- Keith

Ara Kaloustian wrote:

> I thinkg the lines below are the problem. isrising and is falling are 
> being
> used in defining themselves ... creating a circular reference.
>
> Maybe if you used Ref(isrising,-1) instead of rising ....
>
> isrising = IIf(C>Ref(C,-1) OR C==Ref(C,-1) AND isrising, True, False);
> isfalling = IIf(C<Ref(C,-1) OR C==Ref(C,-1) AND isfalling, True, False);
>
> ----- Original Message -----
> From: "keithmccombs" <kmccombs@xxxxxxxxxxxx>
> To: <amibroker@xxxxxxxxxxxxxxx>
> Sent: Saturday, September 18, 2004 9:20 PM
> Subject: [amibroker] Problem using IIf() and arrays to track peaks and
> valleys
>
>
> > I am having problems with some code that should find recent peaks and
> > valleys and track them.  For example after a price changes from
> > rising to falling, the last price would be a peak and the
> > array 'recentpeak' should be set to that value and follow it until
> > the next peak occurs.  Please see code below.  TIA. -- Keith
> > ============
> >
> > // is price rising or falling (or neither)
> > isrising[0] = isfalling[0] = False;  // initialize
> > isrising = IIf(C>Ref(C,-1) OR C==Ref(C,-1) AND isrising, True, False);
> > isfalling = IIf(C<Ref(C,-1) OR C==Ref(C,-1) AND isfalling, True,
> > False);
> >
> >
> > recentpeak[0] = 1000;  // initialize
> > recentvalley[0] = 0;   // initialize
> > // if it just changed to falling then last value was a peak
> > // set value of the peak and follow it until next peak
> > recentpeak = IIf(isfalling AND NOT Ref(isfalling,-1), Ref(C,-1), Ref
> > (recentpeak,-1));
> > //PROBLEM: recentpeak is set to proper value but then goes to zero on
> > next bar!!!!
> > //  I can't see how it can possible be set to zero.
> >
> > // similar logic for a valley
> > recentvalley = IIf(isrising AND NOT Ref(isrising,-1), Ref(C,-1), Ref
> > (recentvalley,-1));
> >
> > Buy = Cover = Cross(C, recentpeak);
> > Sell = Short = Cross(recentvalley, C);
> > GraphXSpace=5;
> > Plot(C, "Close", colorBlack, styleLine);
> > Plot(recentpeak, "Recent Peak", colorGreen, styleLine);
> > Plot(recentvalley, "Recent Valley", colorRed, styleLine);
> >
> >
> >
> >
> >
> > Check AmiBroker web page at:
> > http://www.amibroker.com/
> >
> > Check group FAQ at:
> http://groups.yahoo.com/group/amibroker/files/groupfaq.html
> > Yahoo! Groups Links
> >
> >
> >
> >
> >
>
>
>
>
> Check AmiBroker web page at:
> http://www.amibroker.com/
>
> Check group FAQ at: 
> http://groups.yahoo.com/group/amibroker/files/groupfaq.html
>
>
> *Yahoo! Groups Sponsor*
> ADVERTISEMENT
> click here 
> <http://us.ard.yahoo.com/SIG=129dcc8c7/M=295196.4901138.6071305.3001176/D=groups/S=1705632198:HM/EXP=1095655676/A=2128215/R=0/SIG=10se96mf6/*http://companion.yahoo.com> 
>
>
>
> ------------------------------------------------------------------------
> *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
>       <mailto:amibroker-unsubscribe@xxxxxxxxxxxxxxx?subject=Unsubscribe>
>        
>     * Your use of Yahoo! Groups is subject to the Yahoo! Terms of
>       Service <http://docs.yahoo.com/info/terms/>.
>
>


[Non-text portions of this message have been removed]



------------------------ Yahoo! Groups Sponsor --------------------~--> 
$9.95 domain names from Yahoo!. Register anything.
http://us.click.yahoo.com/J8kdrA/y20IAA/yQLSAA/GHeqlB/TM
--------------------------------------------------------------------~-> 

Check AmiBroker web page at:
http://www.amibroker.com/

Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.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/