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

2007-02-09 Thread carlacash26
OK, here is what I have come up with. It will perform an exploration, 
but it will just 
list all the stock, not filter out the ones that are not meeting my 
criteria.

Background; I search for the 3 highest high value for past 10 days, 
10-20 days and 20-30 days.
Then I want to find the smallest of these values and compare it to 
the highest high value of them all,
if they don't deviate by more than 2%, the stock has a resistance 
level at that point.
Same thing with the lowest low values, which will find me the support 
level.

The problem I am facing now is that there is something wrong with 
finding the smallest of
the Highest high values. The HHmin is just set as 1.00 and not as 
the value of the smallest of 
the 3 HHVs.

I hope someone can help me with this. I think I'm close now.





/*
Find stocks in a trading range
**/

// 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=Ref(HHV(H,10),-1); //HHV of 10 days ago (for example 33)
HHB=Ref(HHV(H,10),-10); //HHV of 10 to 20 ago (for example 32)
HHC=Ref(HHV(H,10),-20); //HHV of 20 to 30 days ago (for example 34)

LLA=Ref(LLV(L,10),-1); //LLV of 10 days ago (for example 33)
LLB=Ref(LLV(L,10),-10); //LLV of 10 to 20 ago (for example 32)
LLC=Ref(LLV(L,10),-20); //LLV of 20 to 30 days ago (for example 34)



//Then find the smallest value of the 3 HHVs, and the largest value 
of the LLVs

HHmin = IIf((HHA  HHB=True) AND (HHA  HHC=True), HHA, HHB);
HHmin = IIf((HHB  HHA=True) AND (HHB  HHC=True), HHB, HHB);
HHmin = IIf((HHC  HHB=True) AND (HHC  HHA=True), HHC, HHB);

LLmax = IIf((LLA  LLB=True) AND (LLA  LLC=True), LLA, LLA);
LLmax = IIf((LLB  LLA=True) AND (LLB  LLC=True), LLB, LLB);
LLmax = IIf((LLC  LLB=True) AND (LLC  LLA=True), LLC, LLB);



//Then caluculate the average of these HHVs and LLVs 
//NOTE: this is not needed for the time being

HHavg=((HHA+HHB+HHC)/3);//(for example = 33)
LLavg=((LLA+LLB+LLC)/3); //(for example =28)



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

HChannel=False;
minHHrange=(HHV(H,30) * 0.95);  //set the min and max values
maxHHrange=(HHV(H,30) * 1.05);
minLLrange=(LLV(L,30) * 0.95);
maxLLrange=(LLV(L,30) * 1.05);


hChannelHHmin = IIf (HHmin  minHHrange, True, False);
hChannelHHmax = IIf (HHmin  maxHHrange, True, False);
hChannelLLmin = IIf (LLmax  minLLrange, True, False);
hChannelLLmax = IIf (LLmax  maxLLrange, True, False);


//Then sum up all of the criteria
hChannel = IIf (hChannelHHmin=True AND hChannelHHmax=True AND 
hChannelLLmin=True AND hChannelLLmax=True, True, False);

//And finally filter out the ones that don't meet the criteria
Filter=hChannel=True;

COLA= Close;
COLB= Ref(HHV(H,10),-1); 
COLC=HHB=Ref(HHV(H,10),-10);
COLD=Ref(HHV(H,10),-20);
COLE= HHmin;

AddColumn(Cola,close);
AddColumn(Colb,HHV-10);
AddColumn(Colc,HHV-10-20);
AddColumn(Cold,HHV-20-30);
AddColumn(Cole,HHmin);

//END OF CODE



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

2007-02-09 Thread wlandry01
Hi,

A couple of things occur to me:

1.)  At one point the code defines HChannel as False.  Later the
terminology used is hChannel.  Should those be the same?

2.)  Also, the statement, Filter=hChannel=True; probably should read
Filter=hChannel==True;.  I believe the current wording sets Filter
to True but it appears that you want to set the Filter to True
only when hChannel is True.

Hope this helps.


Wayne


--- In amibroker@yahoogroups.com, carlacash26 [EMAIL PROTECTED] wrote:

 OK, here is what I have come up with. It will perform an exploration, 
 but it will just 
 list all the stock, not filter out the ones that are not meeting my 
 criteria.
 
 Background; I search for the 3 highest high value for past 10 days, 
 10-20 days and 20-30 days.
 Then I want to find the smallest of these values and compare it to 
 the highest high value of them all,
 if they don't deviate by more than 2%, the stock has a resistance 
 level at that point.
 Same thing with the lowest low values, which will find me the support 
 level.
 
 The problem I am facing now is that there is something wrong with 
 finding the smallest of
 the Highest high values. The HHmin is just set as 1.00 and not as 
 the value of the smallest of 
 the 3 HHVs.
 
 I hope someone can help me with this. I think I'm close now.
 
 
 
 
 
 /*
 Find stocks in a trading range
 **/
 
 // 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=Ref(HHV(H,10),-1); //HHV of 10 days ago (for example 33)
 HHB=Ref(HHV(H,10),-10); //HHV of 10 to 20 ago (for example 32)
 HHC=Ref(HHV(H,10),-20); //HHV of 20 to 30 days ago (for example 34)
 
 LLA=Ref(LLV(L,10),-1); //LLV of 10 days ago (for example 33)
 LLB=Ref(LLV(L,10),-10); //LLV of 10 to 20 ago (for example 32)
 LLC=Ref(LLV(L,10),-20); //LLV of 20 to 30 days ago (for example 34)
 
 
 
 //Then find the smallest value of the 3 HHVs, and the largest value 
 of the LLVs
 
 HHmin = IIf((HHA  HHB=True) AND (HHA  HHC=True), HHA, HHB);
 HHmin = IIf((HHB  HHA=True) AND (HHB  HHC=True), HHB, HHB);
 HHmin = IIf((HHC  HHB=True) AND (HHC  HHA=True), HHC, HHB);
 
 LLmax = IIf((LLA  LLB=True) AND (LLA  LLC=True), LLA, LLA);
 LLmax = IIf((LLB  LLA=True) AND (LLB  LLC=True), LLB, LLB);
 LLmax = IIf((LLC  LLB=True) AND (LLC  LLA=True), LLC, LLB);
 
 
 
 //Then caluculate the average of these HHVs and LLVs 
 //NOTE: this is not needed for the time being
 
 HHavg=((HHA+HHB+HHC)/3);//(for example = 33)
 LLavg=((LLA+LLB+LLC)/3); //(for example =28)
 
 
 
 //Then check to see if the min and max of the three HHVs and
 //LLVs are not deviating too much, I chose 5% as example
 //of maximum deviation.
 
 HChannel=False;
 minHHrange=(HHV(H,30) * 0.95);  //set the min and max values
 maxHHrange=(HHV(H,30) * 1.05);
 minLLrange=(LLV(L,30) * 0.95);
 maxLLrange=(LLV(L,30) * 1.05);
 
 
 hChannelHHmin = IIf (HHmin  minHHrange, True, False);
 hChannelHHmax = IIf (HHmin  maxHHrange, True, False);
 hChannelLLmin = IIf (LLmax  minLLrange, True, False);
 hChannelLLmax = IIf (LLmax  maxLLrange, True, False);
 
 
 //Then sum up all of the criteria
 hChannel = IIf (hChannelHHmin=True AND hChannelHHmax=True AND 
 hChannelLLmin=True AND hChannelLLmax=True, True, False);
 
 //And finally filter out the ones that don't meet the criteria
 Filter=hChannel=True;
 
 COLA= Close;
 COLB= Ref(HHV(H,10),-1); 
 COLC=HHB=Ref(HHV(H,10),-10);
 COLD=Ref(HHV(H,10),-20);
 COLE= HHmin;
 
 AddColumn(Cola,close);
 AddColumn(Colb,HHV-10);
 AddColumn(Colc,HHV-10-20);
 AddColumn(Cold,HHV-20-30);
 AddColumn(Cole,HHmin);
 
 //END OF CODE





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

2007-02-09 Thread wlandry01
Another follow up.  You might want to check your code for the use of
= (assignment) versus == (equal).  It looks like you should be
using == instead of = in several places.

There's some explanatory text in the User's Guide regarding the
difference in usage, as follows:

= (assignment)  vs  == (equality check)

There are two similar looking but completely different operators in AFL.

= is a variable assignment operator
== is an equality check operator

EXAMPLE

Incorrect code:
result = IIf( Variable = 10 , High, Low ); // WRONG
If you want to check if variable is equal to 10, you MUST use == 

Correct code:
result = IIf( Variable == 10 , High, Low ); // CORRECT


Wayne



--- In amibroker@yahoogroups.com, carlacash26 [EMAIL PROTECTED] wrote:



 OK, here is what I have come up with. It will perform an exploration, 
 but it will just 
 list all the stock, not filter out the ones that are not meeting my 
 criteria.
 
 Background; I search for the 3 highest high value for past 10 days, 
 10-20 days and 20-30 days.
 Then I want to find the smallest of these values and compare it to 
 the highest high value of them all,
 if they don't deviate by more than 2%, the stock has a resistance 
 level at that point.
 Same thing with the lowest low values, which will find me the support 
 level.
 
 The problem I am facing now is that there is something wrong with 
 finding the smallest of
 the Highest high values. The HHmin is just set as 1.00 and not as 
 the value of the smallest of 
 the 3 HHVs.
 
 I hope someone can help me with this. I think I'm close now.
 
 
 
 
 
 /*
 Find stocks in a trading range
 **/
 
 // 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=Ref(HHV(H,10),-1); //HHV of 10 days ago (for example 33)
 HHB=Ref(HHV(H,10),-10); //HHV of 10 to 20 ago (for example 32)
 HHC=Ref(HHV(H,10),-20); //HHV of 20 to 30 days ago (for example 34)
 
 LLA=Ref(LLV(L,10),-1); //LLV of 10 days ago (for example 33)
 LLB=Ref(LLV(L,10),-10); //LLV of 10 to 20 ago (for example 32)
 LLC=Ref(LLV(L,10),-20); //LLV of 20 to 30 days ago (for example 34)
 
 
 
 //Then find the smallest value of the 3 HHVs, and the largest value 
 of the LLVs
 
 HHmin = IIf((HHA  HHB=True) AND (HHA  HHC=True), HHA, HHB);
 HHmin = IIf((HHB  HHA=True) AND (HHB  HHC=True), HHB, HHB);
 HHmin = IIf((HHC  HHB=True) AND (HHC  HHA=True), HHC, HHB);
 
 LLmax = IIf((LLA  LLB=True) AND (LLA  LLC=True), LLA, LLA);
 LLmax = IIf((LLB  LLA=True) AND (LLB  LLC=True), LLB, LLB);
 LLmax = IIf((LLC  LLB=True) AND (LLC  LLA=True), LLC, LLB);
 
 
 
 //Then caluculate the average of these HHVs and LLVs 
 //NOTE: this is not needed for the time being
 
 HHavg=((HHA+HHB+HHC)/3);//(for example = 33)
 LLavg=((LLA+LLB+LLC)/3); //(for example =28)
 
 
 
 //Then check to see if the min and max of the three HHVs and
 //LLVs are not deviating too much, I chose 5% as example
 //of maximum deviation.
 
 HChannel=False;
 minHHrange=(HHV(H,30) * 0.95);  //set the min and max values
 maxHHrange=(HHV(H,30) * 1.05);
 minLLrange=(LLV(L,30) * 0.95);
 maxLLrange=(LLV(L,30) * 1.05);
 
 
 hChannelHHmin = IIf (HHmin  minHHrange, True, False);
 hChannelHHmax = IIf (HHmin  maxHHrange, True, False);
 hChannelLLmin = IIf (LLmax  minLLrange, True, False);
 hChannelLLmax = IIf (LLmax  maxLLrange, True, False);
 
 
 //Then sum up all of the criteria
 hChannel = IIf (hChannelHHmin=True AND hChannelHHmax=True AND 
 hChannelLLmin=True AND hChannelLLmax=True, True, False);
 
 //And finally filter out the ones that don't meet the criteria
 Filter=hChannel=True;
 
 COLA= Close;
 COLB= Ref(HHV(H,10),-1); 
 COLC=HHB=Ref(HHV(H,10),-10);
 COLD=Ref(HHV(H,10),-20);
 COLE= HHmin;
 
 AddColumn(Cola,close);
 AddColumn(Colb,HHV-10);
 AddColumn(Colc,HHV-10-20);
 AddColumn(Cold,HHV-20-30);
 AddColumn(Cole,HHmin);
 
 //END OF CODE





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

2007-02-09 Thread carlacash26
Thanks again Wayne! I appreciate your input!

I have solved the problems I had. 
Filter=hChannel; worked, I guess if the variable is 1 or true then you
don't need the = at all.



--- In amibroker@yahoogroups.com, wlandry01 [EMAIL PROTECTED] wrote:

 Hi,
 
 A couple of things occur to me:
 
 1.)  At one point the code defines HChannel as False.  Later the
 terminology used is hChannel.  Should those be the same?
 
 2.)  Also, the statement, Filter=hChannel=True; probably should read
 Filter=hChannel==True;.  I believe the current wording sets Filter
 to True but it appears that you want to set the Filter to True
 only when hChannel is True.
 
 Hope this helps.
 
 
 Wayne
 
 
 --- In amibroker@yahoogroups.com, carlacash26 carlacash26@ wrote:
 
  OK, here is what I have come up with. It will perform an exploration, 
  but it will just 
  list all the stock, not filter out the ones that are not meeting my 
  criteria.
  
  Background; I search for the 3 highest high value for past 10 days, 
  10-20 days and 20-30 days.
  Then I want to find the smallest of these values and compare it to 
  the highest high value of them all,
  if they don't deviate by more than 2%, the stock has a resistance 
  level at that point.
  Same thing with the lowest low values, which will find me the support 
  level.
  
  The problem I am facing now is that there is something wrong with 
  finding the smallest of
  the Highest high values. The HHmin is just set as 1.00 and not as 
  the value of the smallest of 
  the 3 HHVs.
  
  I hope someone can help me with this. I think I'm close now.
  
  
  
  
  
  /*
  Find stocks in a trading range
  **/
  
  // 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=Ref(HHV(H,10),-1); //HHV of 10 days ago (for example 33)
  HHB=Ref(HHV(H,10),-10); //HHV of 10 to 20 ago (for example 32)
  HHC=Ref(HHV(H,10),-20); //HHV of 20 to 30 days ago (for example 34)
  
  LLA=Ref(LLV(L,10),-1); //LLV of 10 days ago (for example 33)
  LLB=Ref(LLV(L,10),-10); //LLV of 10 to 20 ago (for example 32)
  LLC=Ref(LLV(L,10),-20); //LLV of 20 to 30 days ago (for example 34)
  
  
  
  //Then find the smallest value of the 3 HHVs, and the largest value 
  of the LLVs
  
  HHmin = IIf((HHA  HHB=True) AND (HHA  HHC=True), HHA, HHB);
  HHmin = IIf((HHB  HHA=True) AND (HHB  HHC=True), HHB, HHB);
  HHmin = IIf((HHC  HHB=True) AND (HHC  HHA=True), HHC, HHB);
  
  LLmax = IIf((LLA  LLB=True) AND (LLA  LLC=True), LLA, LLA);
  LLmax = IIf((LLB  LLA=True) AND (LLB  LLC=True), LLB, LLB);
  LLmax = IIf((LLC  LLB=True) AND (LLC  LLA=True), LLC, LLB);
  
  
  
  //Then caluculate the average of these HHVs and LLVs 
  //NOTE: this is not needed for the time being
  
  HHavg=((HHA+HHB+HHC)/3);//(for example = 33)
  LLavg=((LLA+LLB+LLC)/3); //(for example =28)
  
  
  
  //Then check to see if the min and max of the three HHVs and
  //LLVs are not deviating too much, I chose 5% as example
  //of maximum deviation.
  
  HChannel=False;
  minHHrange=(HHV(H,30) * 0.95);  //set the min and max values
  maxHHrange=(HHV(H,30) * 1.05);
  minLLrange=(LLV(L,30) * 0.95);
  maxLLrange=(LLV(L,30) * 1.05);
  
  
  hChannelHHmin = IIf (HHmin  minHHrange, True, False);
  hChannelHHmax = IIf (HHmin  maxHHrange, True, False);
  hChannelLLmin = IIf (LLmax  minLLrange, True, False);
  hChannelLLmax = IIf (LLmax  maxLLrange, True, False);
  
  
  //Then sum up all of the criteria
  hChannel = IIf (hChannelHHmin=True AND hChannelHHmax=True AND 
  hChannelLLmin=True AND hChannelLLmax=True, True, False);
  
  //And finally filter out the ones that don't meet the criteria
  Filter=hChannel=True;
  
  COLA= Close;
  COLB= Ref(HHV(H,10),-1); 
  COLC=HHB=Ref(HHV(H,10),-10);
  COLD=Ref(HHV(H,10),-20);
  COLE= HHmin;
  
  AddColumn(Cola,close);
  AddColumn(Colb,HHV-10);
  AddColumn(Colc,HHV-10-20);
  AddColumn(Cold,HHV-20-30);
  AddColumn(Cole,HHmin);
  
  //END OF CODE
 





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

2007-02-09 Thread carlacash26
Yes, it all makes sense! The same thing is in other programming
languages... Why didn't I think about that... :(

Thanks!

--- In amibroker@yahoogroups.com, wlandry01 [EMAIL PROTECTED] wrote:

 Another follow up.  You might want to check your code for the use of
 = (assignment) versus == (equal).  It looks like you should be
 using == instead of = in several places.
 
 There's some explanatory text in the User's Guide regarding the
 difference in usage, as follows:
 
 = (assignment)  vs  == (equality check)
 
 There are two similar looking but completely different operators in AFL.
 
 = is a variable assignment operator
 == is an equality check operator
 
 EXAMPLE
 
 Incorrect code:
 result = IIf( Variable = 10 , High, Low ); // WRONG
 If you want to check if variable is equal to 10, you MUST use == 
 
 Correct code:
 result = IIf( Variable == 10 , High, Low ); // CORRECT
 
 
 Wayne
 
 
 
 --- In amibroker@yahoogroups.com, carlacash26 carlacash26@ wrote:
 
 
 
  OK, here is what I have come up with. It will perform an exploration, 
  but it will just 
  list all the stock, not filter out the ones that are not meeting my 
  criteria.
  
  Background; I search for the 3 highest high value for past 10 days, 
  10-20 days and 20-30 days.
  Then I want to find the smallest of these values and compare it to 
  the highest high value of them all,
  if they don't deviate by more than 2%, the stock has a resistance 
  level at that point.
  Same thing with the lowest low values, which will find me the support 
  level.
  
  The problem I am facing now is that there is something wrong with 
  finding the smallest of
  the Highest high values. The HHmin is just set as 1.00 and not as 
  the value of the smallest of 
  the 3 HHVs.
  
  I hope someone can help me with this. I think I'm close now.
  
  
  
  
  
  /*
  Find stocks in a trading range
  **/
  
  // 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=Ref(HHV(H,10),-1); //HHV of 10 days ago (for example 33)
  HHB=Ref(HHV(H,10),-10); //HHV of 10 to 20 ago (for example 32)
  HHC=Ref(HHV(H,10),-20); //HHV of 20 to 30 days ago (for example 34)
  
  LLA=Ref(LLV(L,10),-1); //LLV of 10 days ago (for example 33)
  LLB=Ref(LLV(L,10),-10); //LLV of 10 to 20 ago (for example 32)
  LLC=Ref(LLV(L,10),-20); //LLV of 20 to 30 days ago (for example 34)
  
  
  
  //Then find the smallest value of the 3 HHVs, and the largest value 
  of the LLVs
  
  HHmin = IIf((HHA  HHB=True) AND (HHA  HHC=True), HHA, HHB);
  HHmin = IIf((HHB  HHA=True) AND (HHB  HHC=True), HHB, HHB);
  HHmin = IIf((HHC  HHB=True) AND (HHC  HHA=True), HHC, HHB);
  
  LLmax = IIf((LLA  LLB=True) AND (LLA  LLC=True), LLA, LLA);
  LLmax = IIf((LLB  LLA=True) AND (LLB  LLC=True), LLB, LLB);
  LLmax = IIf((LLC  LLB=True) AND (LLC  LLA=True), LLC, LLB);
  
  
  
  //Then caluculate the average of these HHVs and LLVs 
  //NOTE: this is not needed for the time being
  
  HHavg=((HHA+HHB+HHC)/3);//(for example = 33)
  LLavg=((LLA+LLB+LLC)/3); //(for example =28)
  
  
  
  //Then check to see if the min and max of the three HHVs and
  //LLVs are not deviating too much, I chose 5% as example
  //of maximum deviation.
  
  HChannel=False;
  minHHrange=(HHV(H,30) * 0.95);  //set the min and max values
  maxHHrange=(HHV(H,30) * 1.05);
  minLLrange=(LLV(L,30) * 0.95);
  maxLLrange=(LLV(L,30) * 1.05);
  
  
  hChannelHHmin = IIf (HHmin  minHHrange, True, False);
  hChannelHHmax = IIf (HHmin  maxHHrange, True, False);
  hChannelLLmin = IIf (LLmax  minLLrange, True, False);
  hChannelLLmax = IIf (LLmax  maxLLrange, True, False);
  
  
  //Then sum up all of the criteria
  hChannel = IIf (hChannelHHmin=True AND hChannelHHmax=True AND 
  hChannelLLmin=True AND hChannelLLmax=True, True, False);
  
  //And finally filter out the ones that don't meet the criteria
  Filter=hChannel=True;
  
  COLA= Close;
  COLB= Ref(HHV(H,10),-1); 
  COLC=HHB=Ref(HHV(H,10),-10);
  COLD=Ref(HHV(H,10),-20);
  COLE= HHmin;
  
  AddColumn(Cola,close);
  AddColumn(Colb,HHV-10);
  AddColumn(Colc,HHV-10-20);
  AddColumn(Cold,HHV-20-30);
  AddColumn(Cole,HHmin);
  
  //END OF CODE
 





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

2007-02-08 Thread carlacash26
OK first problem I encounter when trying to write this in amibroker, 
is that this doesn't work...:

HHA=HHV(H,10); //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)

Any idea how to get the highest high value from, 10 days ago (not 
counting today), 10 to 20 days ago and 20-30 days ago?

Is it possible in an easy fashion?

Thanks!


--- In amibroker@yahoogroups.com, carlacash26 [EMAIL PROTECTED] 
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!





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

2007-02-08 Thread wlandry01
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@yahoogroups.com, carlacash26 [EMAIL PROTECTED] 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!





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

2007-02-08 Thread wlandry01
Hi, again.

Note that the following line should be changed to read:

AddColumn(HHB,HHB,1.2);

I switched in mid-thought in order to use your terminology.  It's too
early for me to be thinking, in any case.


Wayne



--- In amibroker@yahoogroups.com, wlandry01 [EMAIL PROTECTED] 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@yahoogroups.com, 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!
 





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

2007-02-08 Thread carlacash26
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@yahoogroups.com, wlandry01 [EMAIL PROTECTED] 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@yahoogroups.com, 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