| 
 PureBytes Links 
Trading Reference Links 
 | 
  
I believe that the code below is what you are looking for. Looking at a chart you should see identical plots over top of each other. My apologies to any with color blindness. 
Mike 
//Resline.afl  //  >H;  TwoHigh = Ref(H,-1);  ThreeHigh = Ref(H,-2);  ResLine = ValueWhen( ThreeHigh < TwoHigh AND TwoHigh > OneHigh,TwoHigh,1);  Plot(ResLine,"ResLineArray", colorBlue, styleLine | styleLine); 
  ResLine = NULL; 
  for (i = 2; i < BarCount; i++) {     if (ThreeHigh[i] < TwoHigh[i] && TwoHigh[i] > OneHigh[i]) {        ResLine[i] = TwoHigh[i];     } else {        ResLine[i] = ResLine[i - 1];     }  } 
  Plot(ResLine,"ResLineLoop",colorYellow, styleDashed, null, null, null, 1); 
  
 --- In amibroker@xxxxxxxxxxxxxxx, "Anthony Faragasso" <ajf1111@xxx> wrote: > > Thomas, >  > the second code snippet does not plot like the first code snippet... >  > I believe that is what he is after... >  > Anthony >  > ----- Original Message -----  > From: Thomas Z.  > To: amibroker@xxxxxxxxxxxxxxx  > Sent: Sunday, November 01, 2009 4:29 PM > Subject: AW: [amibroker] Re: Help!! simple looping problem??? >  >  > Hi, >  > //Resline.afl > // > >> 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" ) ); >  > ResLine[0] = 0; >  > for ( i = 2; i < BarCount; i++ ) > { > if ( H[i-2] < H[i-1] AND H[i-1] > H[i] ) > { > ResLine[i] = H[i-1]; > } > } >  > Plot(ResLine,"ResLine",colorBlue, styleLine|styleThick); >  > Thomas > www.patternexplorer.com >  > -----Ursprüngliche Nachricht----- > Von: amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx] Im Auftrag > von christianvost > Gesendet: Sonntag, 1. November 2009 22:05 > An: amibroker@xxxxxxxxxxxxxxx > Betreff: [amibroker] Re: Help!! simple looping problem??? >  > Hi Thomas, > Thanks for the suggestion. I tried this, but the results didn't match the > previous code sample. I just got spiking lines where the indicator reset > itself to zero, after each iteration? I'm assuming that this code correction > goes in at line 7? could you please make the correction to the looping > sample and re-post? I'd really appreciate it. > Many thanks, Chris. >  > --- In amibroker@xxxxxxxxxxxxxxx, "Thomas Z." tzg@ wrote: > > > > Hi, > >  > > you need to change it to: ResLine[i] = H[i-1]; > >  > > Thomas > > www.patternexplorer.com > >  > >  > > -----Ursprüngliche Nachricht----- > > Von: amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx] Im > Auftrag > > von christianvost > > Gesendet: Sonntag, 1. November 2009 10:37 > > An: amibroker@xxxxxxxxxxxxxxx > > Betreff: [amibroker] Help!! simple looping problem??? > >  > > 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 > > // > > >> > 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 > > >  > ------------------------------------ >  > **** 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 >
  
 
    
    
 
__._,_.___
  
**** 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/ 
 
  
     
  
 
      
   
__,_._,___
 |