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

[amibroker] Re: Finding trading range/horizontal channel, can it be done like this?



PureBytes Links

Trading Reference Links

Hi, thanks a lot for your help! It seems to work like that, thanks!
Haven't succeeded to run this because I don't seem to get my if-
statements correct either. The error message i get is "Error 6. 
Condition in IF, WHILE, FOR statements has to be Numeric or Boolean 
type. You can not use array here, please use [] (array subscript 
operator) to access array elements".. :(

Hopefully someone can solve this for me, I tried to do it in two ways 
but haven't really got it right.. :(


/********CODE Snippet

//Averages of three HHVs and LLVs
HHavg=(HHA+HHB+HHC/3);
LLavg=(LLA+LLB+LLC/3);


//Calculate 5% of HHV, both 5% more and 5% less 
HHmin=(HHV(H,30) * 0.95);
HHmax=(HHV(H,30) * 1.05);
LLmin=(LLV(L,30) * 0.95);
LLmax=(LLV(L,30) * 1.05);


//Now check to see if the averages of the three HHVs and
//LLVs are not deviating too much from the min and max values,
//I chose 5% as example of maximum deviation.

//HHAvg is between HHV - 5% and HHV + 5%
//LLAvg is between LLV - 5% and LLV + 5%
//I tried to make this like a nested if-statement
//HChannel is set as False to begin with...

HChannel=False;

if (HHavg > HHmin) {
if (HHavg < HHmax) {
if (LLavg > LLmin) {
if (LLavg < LLmax) {

 hChannel=True; }

} } }


//Finally the filter for the exploration
Filter=hChannel=True;





--- In amibroker@xxxxxxxxxxxxxxx, "wlandry01" <wlandry01@xxx> wrote:
>
> Hi,
> 
> I believe that you have included one too many arguments for "HHV". 
> Are you trying to use "Ref" with "HHV"?  You can use the following
> simple code to see if this helps:
> 
> HHB=Ref(HHV(C,10),-10);
> AddColumn(C,"Close",1.2);
> AddColumn(Htest,"Htest",1.2);
> Filter=1;
> 
> I don't know if this will get you where you are trying to go or not
> but the syntax does appear to be a problem.  Others who are much 
more
> familiar with AFL will, no doubt, be able to provide more insight.
> 
> I would also check the AFL library as I seem to recall seeing some
> examples that address channels.  TJ has some code there that deals
> with troughs and peaks, which is somewhat related to your subject.  
He
> has some excellent commentary included in the listing that you might
> find interesting and helpful:
> 
> http://www.amibroker.com/library/detail.php?id=19
> 
> 
> Wayne
> 
> 
> 
> --- In amibroker@xxxxxxxxxxxxxxx, "carlacash26" <carlacash26@> 
wrote:
> >
> > I want to plot a horizontal line from the Highest High Value and 
one 
> > from the Lowest Low Value for the past 30 days. In addition to 
this I 
> > want to have an exploration find stocks where the price has 
turned in 
> > the proximity of this line (support/resistance) over the past 30 
days 
> > (or any period that I define). In other words I want to search 
for a 
> > horizontal channel that has lasted for past 30* days.
> > 
> > I have thought about how to implement this and maybe this is a 
> > suitable way?..: 
> > 
> > To find the the HHV for the last 10 days, AND the HHV for the 
last 10 
> > to 20 days, AND the HHV for the last 20 to 30 days.
> > And then the same thing for the LLV. Do you understand what I 
mean?
> > 
> > Then if the HHV/LLV for these timeperiods don't deviate from each 
> > other that much, then I can assume that there is 
resistance/support
> > for past 30 days at this level. I could divide the range into 
> > more/less timeperiods also, I don't know the best number of 
periods, 
> > I chose 3 to begin with.
> > 
> > What do you think about this approach? Do you find anything that 
> > don't make sense about this? 
> > 
> > 
> > /***************************************************************/
> > //THE CODE I HAVE COME UP WITH, 
> > //it's not finished by any means but you get my point hopefully
> > //The syntax is probably not correct, this is some kind 
> > //of pseudo code I guess, I have just written this in notepad
> > /***************************************************************/
> > 
> > 
> > // First find the highest high values, And lowest low values for 
the 
> > 3 periods; 10 days ago, 10-20 days ago, and 20-30 days ago
> > 
> > HHA=HHV(H,10,-1);  	 //HHV of 10 days ago  (for example 33)
> > HHB=HHV(H,10,-10); 	 //HHV of 10 to 20 ago (for example 32)
> > HHC=HHV(H,10,-20); 	 //HHV of 20 to 30 days ago (for example 34)
> > 
> > LLA=LLV(L,10,-1);	 //LLV of 10 days ago  (for example 27)
> > LLB=LLV(L,10,-10);	 //LLV of 10 to 20 ago (for example 28)
> > LLC=LLV(L,10,-20); 	 //LLV of 20 to 30 days ago (for example 29)
> > 
> > 
> > 
> > //Then caluculate the average of these HHVs and LLVs
> > 
> > HHavg=(HHA+HHB+HHC/3);//(for example = 33)
> > LLavg=(LLA+LLB+LLC/3); //(for example =28)
> > 
> > 
> > 
> > //Then check to see if the averages of the three HHVs and 
> > //LLVs are not deviating too much, I chose 5% as example 
> > //of maximum deviation. 
> > 
> > 
> > //HHAvg is between HHV - 5% and HHV + 5%
> > if ((HHavg > (HHV(H,30) * 0.95)) AND (HHavg < (HHV(H,30) * 
1.05))) 
> > 
> > AND
> > 
> > //LLAvg is between LLV - 5% and LLV + 5%
> > if ((LLavg > (LLV(L,30) * 0.95)) AND (LLavg < (LLV(L,30) * 
1.05))) 
> > 
> > { hChannel=TRUE; } 
> > //if they don't differ more than 5% there is a horizontal channel
> > 
> > 
> > Filter=hChannel;  //filter for stocks where hchannel is true
> > 
> > //now plot the channel for stocks where hChannel=true
> > //i.e. plot lines from HHavg and LLavg, AND plot lines 
> > //from HHV(H,30,-1) and LLV(L,30,-1)
> > //then maybe explore stocks that break out of these 
> > //resistance levels. Haven't thought about this yet...
> > 
> > //Code ends here
> > 
> > 
> > Please could you give your opinion on this, I might have missed 
> > something or maybe I'm completely off track? Is there a better 
way 
> > to find horizontal support and resistance that I could use to 
find 
> > horizontal channels/ranges?
> > 
> > Thank you very much for any help or suggestions or comments you 
can 
> > give! It's highly appreciated!
> >
>



Content-Description: "AVG certification"
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.432 / Virus Database: 268.17.31/676 - Release Date: 2/8/2007 3:04 PM