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

Re: [amibroker] Convexity, Concavity and their use



PureBytes Links

Trading Reference Links




Thanks Dimitris for sharing  
;)
 Can I use <FONT 
face="Times New Roman" color=#000000>The 4 phases of a stock graph in trading 
system or looks in future data?
I think this is good for detecting good entries and 
exits...
Have you designed any afl code to detect congestion 
(for a trading system)?
Thank a lot
 
juan
<BLOCKQUOTE 
>
  ----- Original Message ----- 
  <DIV 
  >From: 
  Dimitris 
  Tsokakis 
  To: <A title=amibroker@xxxxxxxxxxxxxxx 
  href="">amibroker@xxxxxxxxxxxxxxx 
  Sent: Friday, September 26, 2003 5:03 
  AM
  Subject: [amibroker] Convexity, Concavity 
  and their use
  
  An ideal sinusoidal has 4 phases:
   
  Convex AND Ascending;// <FONT 
  face=Verdana size=2><FONT 
  face="Times New Roman">colorDarkGreen
  Concave AND Ascending;// <FONT 
  face=Verdana size=2><FONT 
  face="Times New Roman">colorTurquoise
  Concave AND Descending;// <FONT 
  face=Verdana size=2><FONT 
  face="Times New Roman">colorDarkRed
  Convex AND Descending;// <FONT 
  size=2>colorPink
  The IB code illustrates the example 
  
   
  // The 4 phases of an ideal 
  sinusoidal<FONT 
  face=Verdana size=2>
  freq = 1<FONT 
  face="Times New Roman">;
  y=sin( <FONT 
  size=2>Cum( freq/10<FONT 
  face=Verdana size=2> ) );<FONT 
  face="Times New Roman">
  t=1<FONT 
  face="Times New Roman">;
  Convex=(y-Ref<FONT 
  size=2>(y,-t))/t>=(y-Ref<FONT 
  size=2>(y,-(t+1)))/(t+<FONT 
  size=2>1<FONT 
  face="Times New Roman">);
  Concave=NOT(Convex);<FONT 
  face="Times New Roman">
  Ascending=y>=Ref<FONT 
  size=2>(y,-1<FONT 
  face="Times New Roman">);
  Descending=NOT(ascending);
  Bullstart=Convex AND Ascending;
  Bullend=Concave AND ascending;
  Bearstart=Concave AND 
  Descending;
  Bearend=Convex AND 
  Descending;
  Color=IIf<FONT 
  size=2>(Bullstart,colorDarkGreen,IIf<FONT 
  size=2>(Bullend,colorTurquoise,IIf<FONT 
  face=Verdana size=2><FONT 
  face="Times New Roman">(Bearstart,colorDarkRed,colorPink)));<FONT 
  face=Verdana size=2>
  Plot(y,""<FONT 
  size=2>,Color,8<FONT face=Verdana 
  size=2>);
   
  [see sin.gif]
  We shall use a smoothing procedure 
  [IIR2 filter] as close to the sinusoidal as possible. [see 
  IIR2.gif]
  Of course the trend characteristics 
  do not give the [-1, +1] oscillation, but the convexity/concavity are still 
  detectable.
  The superimpose of actual price 
  candles gives a more descriptive picture of the 4 phases.
  [see 4phases.gif]
  The full code is
  <FONT face=Batang color=#0000ff 
  size=2> 
  // The 4 
  phases of a stock graph
  // A. 
  Smothing procedure
  function<FONT 
  face="Times New Roman"> IIR2( input, f0, f1, f2 )
  {
  result[ 0 ] = input[ <FONT 
  size=2>0 ];result[ 1<FONT 
  size=2> ] = input[ 1<FONT face=Verdana 
  size=2> ]; 
  for( 
  i = 2<FONT 
  face="Times New Roman">; i < BarCount; i++ )
  {
  result[ i ] = f0 * input[ i ] + f1 * result[ i - <FONT 
  size=2>1 ] + f2 * result[ i - <FONT 
  size=2>2 
  ]; 
  }
  <FONT 
  size=2>return<FONT 
  face="Times New Roman"> result;
  }
  C1=C;<FONT 
  face="Times New Roman">
  k=0.3<FONT 
  face="Times New Roman">;
  RD=IIR2( C1, 0.3, <FONT 
  size=2>1.2+K, -0.5<FONT 
  face=Verdana size=2>-K);
  // B. Convexity 
  definition
  y=RD;<FONT face=Verdana 
  size=2>
  t=1<FONT 
  face="Times New Roman">;
  Convex=(y-Ref<FONT 
  face="Times New Roman">(y,-t))/t>=(y-<FONT 
  size=2>Ref<FONT 
  size=2>(y,-(t+1)))/(t+<FONT 
  size=2>1<FONT 
  face="Times New Roman">);
  Concave=NOT(Convex);<FONT 
  face="Times New Roman">
  Ascending=y>=Ref<FONT 
  face="Times New Roman">(y,-<FONT 
  size=2>1<FONT 
  face="Times New Roman">);
  Descending=NOT(ascending);
  // C. Trend 
  phases
  Bullstart=Convex AND Ascending;// from A to 
  B
  Bullend=Concave AND ascending;// from B to 
  C
  Bearstart=Concave AND Descending;// from C 
  to D
  Bearend=Convex AND Descending;// from D to 
  E
  // D. Application
  Color=IIf<FONT 
  face="Times New Roman">(Bullstart,colorDarkGreen,<FONT 
  size=2>IIf<FONT 
  size=2>(Bullend,colorTurquoise,IIf<FONT 
  face=Verdana size=2><FONT 
  face="Times New Roman">(Bearstart,colorDarkRed,colorPink)));<FONT 
  face=Verdana size=2>
  Plot(y,""<FONT 
  size=2>,Color,8<FONT face=Verdana 
  size=2>+styleThick);<FONT 
  face=Verdana size=2>
  Plot(C,""<FONT 
  size=2>,47,<FONT 
  size=2>64);GraphXSpace=5<FONT 
  face=Verdana size=2>;
  <FONT face=Batang 
  color=#0000ff> <FONT 
  size=2>Send 
  BUG REPORTS to bugs@xxxxxxxxxxxxxSend SUGGESTIONS to 
  suggest@xxxxxxxxxxxxx-----------------------------------------Post 
  AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx (Web page: <A 
  href="">http://groups.yahoo.com/group/amiquote/messages/)--------------------------------------------Check 
  group FAQ at: <A 
  href="">http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
  Your use of Yahoo! Groups is subject to the <A 
  href="">Yahoo! Terms of Service. 







Yahoo! Groups Sponsor


  ADVERTISEMENT 









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 the Yahoo! Terms of Service.