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

[amibroker] Help!! simple looping problem???



PureBytes Links

Trading Reference Links

Hi, This is probably an easy one, but I'm struggling with looping through arrays in afl. Have a look at the simple code below.  
( copy+paste into editor then drag into price pane ).

//Resline.afl
//
OneHigh = H;
TwoHigh = Ref(H,-1);
ThreeHigh = Ref(H,-2);
ResLine = ValueWhen( ThreeHigh < TwoHigh AND TwoHigh > OneHigh,TwoHigh,1);
Plot(ResLine,"ResLine", ParamColor( "Color", colorCycle ), ParamStyle("Style") );

I tried to write a 'for,if' loop to replace the previous code, but it's not working. Can anyone correct the following code sample for me please???  Thank-you to all.

ResLine[0] = 0;

for(i=2; i<BarCount; i++)
{
 if(H[i-2] < H[i-1] AND H[i-1] > H[i]) 
	{
	 ResLine = H[i-1];
	} 
//Plot(ResLine,"ResLine",colorRed, styleLine|styleThick); //inside loop plots multiple lines
}
Plot(ResLine,"ResLine",colorRed, styleLine|styleThick); //outside loop plots single line (most recent value when condition is met)





------------------------------------

**** IMPORTANT PLEASE READ ****
This group is for the discussion between users only.
This is *NOT* technical support channel.

TO GET TECHNICAL SUPPORT send an e-mail directly to 
SUPPORT {at} amibroker.com

TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
http://www.amibroker.com/feedback/
(submissions sent via other channels won't be considered)

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/

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/