Steve, I wanted to thank you again for your help...
I was able to achieve what i was looking to do using your second suggestion. If you would like to take a look at my finished exploration you are welcome. It provides a list of stocks still in an uptrend or down trend based on the Trading Chaos theory of the alligator. These returned tickers are trending and we are able to take additional positions when the stock breaks thru the fractal. I particularly like the number of days column ( which can be sorted ) to tell how many days the 3 moving averages on in an uptrend. The only flaw remaining to correct is stocks that have been trading in the same range ( within 50cents) for long time. which i am still working on to correct... Thank you kindly for your help... it was invaluable. Best regards, Tony Alcamo // exploration adapted on Trading Chaos Theory by Bill Williams A=((H+L)/2); VolAvg = MA( V, 30 ); VolumeIdx = V / VolAvg; AlligatorBlue =Ref(Wilders(A,13),-8); AlligatorRed =Ref(Wilders(A,8),-5); AlligatorGreen=Ref(Wilders(A,5),-3); INTRENDbullish =IIf( AlligatorGreen > AlligatorRed AND AlligatorGreen > AlligatorBlue AND AlligatorRed > AlligatorBlue ,1, 0); NotinTrendBullish = NOT INTRENDbullish ; BullishTrendBars = BarsSince( NotInTrendBullish ); INTRENDbearish=IIf( AlligatorRed > AlligatorGreen AND AlligatorBlue > AlligatorGreen AND AlligatorBlue > AlligatorRed ,1, 0); NotinTrendBearish = NOT INTRENDbearish ; BearishTrendBars = BarsSince( NotInTrendBearish ); h52w =HHV(C,225); Off52wh =(HHV(C,225) - Close)/HHV(C,225) ; l52w =LLV(C,225); Off52wl =(Close-LLV(C,225))/LLV(C,225) ; Filter = (C > 10 AND BullishTrendBars >=1 ) OR (C >15 AND BearishTrendBars >=1); AddTextColumn( IndustryID( 1 ) , "Industry name" ); AddColumn ( Off52wh , "Off52WeekHigh" ); AddColumn ( BullishTrendBars , "BullishDays " ,1); AddColumn ( h52w , "52WeekHigh" ,1.2,colorDefault,IIf( Close==HHV (C,225), colorGreen, IIf( off52wh < 0.10, colorYellow, colorDefault ))); AddColumn ( Close , "Close" ); AddColumn ( BearishTrendBars , "BearishDays " ,1); AddColumn ( l52w , "52WeekLow" ,1.2,colorDefault,IIf( Close==LLV (C,225), colorRed, IIf( off52wl < 0.10, colorOrange, colorDefault ))); AddColumn ( Off52wl , "Off52WeekLow" ); AddColumn ( VolumeIDX , "VolumeIDX" ,1.2,colorDefault,IIf( VolumeIDX >1.5, colorGreen, colorDefault ) ); AddColumn ( Volume , "Volume" ,1 ,colorDefault,IIf( Volume >500000, colorGreen, IIf( Volume > 250000, colorYellow, colorRed) ) ); // end of exploration --- In [email protected], "Steve Dugas" <[EMAIL PROTECTED]> wrote: > > Tony - 2nd arg of For Loop means to continue looping *while* the condition > is true, not *until* it is true. You have initialized Stop to zero but then > told the Loop to keep looping as long as Stop >0. You should change the ">" > to "==" ( 2 equal signs ), *but*... > > Now that I have looked closer at your code, it is also wrong that you are > using array-based IIF inside the loop - to walk the arrays, you should be > using IF ( non-array ) and [] subscripts to check each element one at a > time. It is usually easier to just use array-based AFL - does the code I > gave you yesterday work? > > Steve > > ----- Original Message ----- > From: "Tony" <[EMAIL PROTECTED]> > To: <[email protected]> > Sent: Sunday, September 23, 2007 1:34 AM > Subject: [amibroker] Re: Could someone point in the right direction... > > > > Steve, > > Thank you for your response. > > I tried changing the 2nd argument to a test (but it still does not > > work (see below). I still get the same results. Any suggestions? > > > > I will explore your second option. > > Thank you. > > > > Tony > > > > > > > > CheckAlligator = 0; > > stop =0; > > NumberOfDays =0; > > for ( i=-1; stop > 0 ; i--) > > { > > > > CheckAlligator =IIf( Ref(AlligatorGreen,i) > Ref(AlligatorRed,i) AND > > Ref(AlligatorGreen,i) > Ref(AlligatorBlue, i) AND > > Ref(AlligatorRed,i) > Ref(AlligatorBlue, i) ,1, 0); > > > > // if in uptrend increment the NumberOfDays variable > > if (CheckAlligator == 1 ) > > NumberOfDays = 1 + NumberOfDays; > > else > > stop = 1; > > > > }// end for loop > > > > > > > > > > --- In [email protected], "Steve Dugas" <sjdugas@> wrote: > >> > >> > >> Hi - In 2nd arg of for loop header, you are assigning a value of > > zero > >> instead of testing for it, so I am guessing the expression returns > > zero and > >> so is never true. Might be easier to do this without a loop, > > something > >> like... > >> > >> InTrend = AlligatorGreen > AlligatorRed AND AlligatorRed > > > AlligatorBlue; > >> NotInTrend = NOT InTrend; > >> TrendBars = BarsSince( NotInTrend ); > >> > >> > >> Steve > >> > >> ----- Original Message ----- > >> From: "Tony" <talcamo@> > >> To: <[email protected]> > >> Sent: Saturday, September 22, 2007 10:26 PM > >> Subject: [amibroker] Could someone point in the right direction... > >> > >> > >> > Hi, > >> > > >> > I am trying to write an exploration to loop back thru 3 arrays to > >> > confirm how many days ago there was a crossover of the 3 moving > >> > averages defined below. This is related the the Bill Williams > > Chaos > >> > Theory ( the alligator). Once the exploration is executed I would > > be > >> > able to see which stocks are still in an uptrend and have been in > > an > >> > uptrend for the longest time. > >> > > >> > However in my current formula, the for loop drops out on the very > >> > first pass. I cannot figure out why. It never adds anything to the > >> > NumberOfDays variable. > >> > > >> > I am certain the checkAlligator formula is correct as i tested it > >> > manually. I just added the ref() and the index counter for my > >> > formula, so it could loop back through the data. > >> > > >> > I would be gratefully if someone could explain to me what i a > > doing > >> > incorrectly? or point me in the correct direction. > >> > > >> > Thank you kindly in advance... > >> > > >> > Regards, > >> > > >> > Tony > >> > > >> > > >> > A=((H+L)/2); > >> > > >> > AlligatorBlue=Ref(Wilders(A,13),-8); > >> > AlligatorRed=Ref(Wilders(A,8),-5); > >> > AlligatorGreen=Ref(Wilders(A,5),-3); > >> > CheckAlligator = 0; > >> > NumberOfDays =0; > >> > for ( i=-1; stop = 0 ; i--) > >> > { > >> > > >> > CheckAlligator =IIf( Ref(AlligatorGreen,i) > Ref (AlligatorRed,i) > > AND > >> > Ref(AlligatorGreen,i) > Ref(AlligatorBlue, i) > > AND > >> > Ref(AlligatorRed,i) > Ref(AlligatorBlue, i) ,1, > > 0); > >> > > >> > // if in uptrend increment the NumberOfDays variable > >> > if (CheckAlligator == 1 ) > >> > NumberOfDays = 1 + NumberOfDays; > >> > else > >> > stop = 1; > >> > > >> > }// end for loop > >> > > >> > Filter = C > 1; > >> > AddColumn(i , "index "); > >> > AddColumn(Checkalligator , "Checkalligator"); > >> > AddColumn(NumberOfDays , "NumberOfDays "); > >> > AddColumn(Close , "Close"); > >> > AddColumn(AlligatorGreen, "AlligatorGreen"); > >> > AddColumn(AlligatorRed, "AlligatorRed"); > >> > AddColumn(AlligatorBlue, "AlligatorBlue"); > >> > > >> > > >> > > >> > Please note that this group is for discussion between users only. > >> > > >> > To get support from AmiBroker please send an e-mail directly to > >> > SUPPORT {at} amibroker.com > >> > > >> > For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG: > >> > http://www.amibroker.com/devlog/ > >> > > >> > For other support material please check also: > >> > http://www.amibroker.com/support.html > >> > > >> > Yahoo! Groups Links > >> > > >> > > >> > > >> > > >> > > > > > > > > > > Please note that this group is for discussion between users only. > > > > To get support from AmiBroker please send an e-mail directly to > > SUPPORT {at} amibroker.com > > > > For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG: > > http://www.amibroker.com/devlog/ > > > > For other support material please check also: > > http://www.amibroker.com/support.html > > > > Yahoo! Groups Links > > > > > > > > >
