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

[amibroker] Still Problem using IIf() and arrays to track peaks and valleys



PureBytes Links

Trading Reference Links

I am still having a problem using IIf() and arrays to track peaks and 
valleys.  I just tried to simplify and comment the code so people 
could more easily see my problem.  TIA for your help. -- Keith

======= code starts here ================
// is price falling
isfalling = 0;  // initialize array
isfalling = IIf(C<Ref(C,-1) OR C==Ref(C,-1) AND Ref(isfalling, -1), 
1, 0);
//extra code for troubleshooting
Plot(IIf(isfalling,500,400), "isfalling", colorRed, styleLine); // 
below recent RUT2K


recentpeak = 650;  // initialize to value higher than recent RUT2K 
price
// if price just changed to falling then last value was a peak
// set value of recentpeak to 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 650 on 
the next bar!!!!
//  This means that if conditional statement is false then recentpeak 
is NOT set
//    to Ref(recentpeak,-1) as it should be but just stays at inital 
value of 650.

GraphXSpace=5;
Plot(C, "Close", colorBlack, styleLine);  // testing with RUT which 
is near 500
Plot(recentpeak, "Recent Peak", colorGreen, 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/