PureBytes Links
Trading Reference Links
|
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);
------------------------ Yahoo! Groups Sponsor --------------------~-->
Make a clean sweep of pop-up ads. Yahoo! Companion Toolbar.
Now with Pop-Up Blocker. Get it for free!
http://us.click.yahoo.com/L5YrjA/eSIIAA/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/
|