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

[amibroker] Finding highest and lowest turning points



PureBytes Links

Trading Reference Links

I have a AFL for finding turning points and want to refine this to check and
remove surplus turning points. eg two tops with no bottom in between and
keep the higher of the 2 tops (or 3 or 4 consecutive tops etc). 
I can remove them in AFL after the loop is completed, but for other purposes
I need to identify these tops and bottoms to make topper tops and bottomer
bottoms.  
I tried to have a second set of variables using [J] as the identifier, but
this just gave me every bar. 
What I want to do within the loop is find the highest top and lowest bot for
major turning points. 

Help appreciated. 

Here is my loop code with the topper and botter added in 

Top = Null;
Bot = Null;
LastTop = 0;
HiPiv = Null;
LoPiv = Null;
j=0;
Topper = Null;
Botter = Null;
//Assign H & L for zero volatility Bars as = Last Bar with H not= L
H = IIf( V==0, ValueWhen(V>0,H), H );
L = IIf( V==0, ValueWhen(V>0,L), L );
//Loop to find Tops and Bottoms, plus price values of Tops & Bottoms
for( i=Start+1; i<End-1; i++ )
{
 if( H[i]>=H[i-2] && H[i]>=H[i-1] && H[i]>H[i+1] && H[i]>H[i+2] &&
LastTop==0)
 {
  Top[i] = 1;
  HiPiv[i] = H[i];
  LastTop = 1;
  Topper[j] =1;
  j = j+1;
 }
 else
 {
  if( H[i]>=H[i-2] && H[i]>=H[i-1] && H[i]>H[i+1] && H[i]>H[i+2] &&
LastTop==1 && H[i]>HiPiv[i-1] )
  {
   Top[i] = 1;
   HiPiv[i] = H[i];
   LastTop = 1;
   Topper[j] =1;
   j = j+1;
  }
  else
  {
   if( L[i]<=L[i-2] && L[i]<=L[i-1] && L[i]<L[i+1] && L[i]<L[i+2] &&
LastTop==1)
   {
    Bot[i] = 1;
    LoPiv[i] = L[i];
    LastTop = 0;
    Botter[j] = 1;
    j=j+1;
   }
   else
   {
    if( L[i]<=L[i-2] && L[i]<=L[i-1] && L[i]<L[i+1] && L[i]<L[i+2] &&
LastTop==0 && L[i]<LoPiv[i-1])
    {
     Bot[i] = 1;
     LoPiv[i] = L[i];
     LastTop = 0;
     Botter[j] = 1;
     j=j+1;
    }
    else
    {
     LoPiv[i] = LoPiv[i-1];
     HiPiv[i] = HiPiv[i-1];
    }
   }
  }
 }
}

MaxiTop = ValueWhen(Topper,1);
MaxiBot = ValueWhen(Botter,1);
PlotShapes( MaxiTop * shapeStar, colorLavender, 0, Avg, 0 ); //rising high
PlotShapes( MaxiBot * shapeStar, colorLavender, 0, Avg, 0 ); //rising low



Cheers,
Graham
http://groups.msn.com/ASXShareTrading
http://groups.msn.com/FMSAustralia 


------------------------ Yahoo! Groups Sponsor ---------------------~-->
Buy Ink Cartridges or Refill Kits for your HP, Epson, Canon or Lexmark
Printer at MyInks.com. Free s/h on orders $50 or more to the US & Canada.
http://www.c1tracking.com/l.asp?cid=5511
http://us.click.yahoo.com/mOAaAA/3exGAA/qnsNAA/GHeqlB/TM
---------------------------------------------------------------------~->

Send BUG REPORTS to bugs@xxxxxxxxxxxxx
Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
-----------------------------------------
Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx 
(Web page: http://groups.yahoo.com/group/amiquote/messages/)
--------------------------------------------
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/