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

Re: [amibroker] Re: The Reverse Engine Bollinger Bands Problem, IV



PureBytes Links

Trading Reference Links




Well, Pal, there's not much more to report. I think I may have coded it 
once in AB a year or so ago, but I don't remember much about the results. When 
you place your orders, you use OCO orders so you don't get filled on both long 
and short on the same day. You get filled at the first breach of a band (upper 
or lower), and then the other order automatically gets canceled. Or, you could 
use it as a reversal system, too, if you wanted. I know nothing about Gann 
support and resistance points, so I can't comment on that. Thanks for the reply. 

 
AV
<BLOCKQUOTE 
>
  ----- Original Message ----- 
  <DIV 
  >From: 
  palsanand 
  
  To: <A title=amibroker@xxxxxxxxxxxxxxx 
  href="">amibroker@xxxxxxxxxxxxxxx 
  Sent: Wednesday, September 24, 2003 9:07 
  PM
  Subject: [amibroker] Re: The Reverse 
  Engine Bollinger Bands Problem, IV
  Hi,I can envision some problems with this Bollinger 
  Breakout system.  1)  It is extremely diffcult for one to 
  make a determination of the direction of the market based on volatility 
  (HVR, BandWidth etc.,)alone without a good Entry/Exit Trading signal 
  Detection System.  Hence you may have to straddle the 
  market.2)  Suppose you go long above the upper band and you place 
  a sell stop below the lower band (straddle) and vice-versa and you get 
  filled on both sides....You may get away with this system by 
  placing your stop not just above/below the bands but at for e.g., at 
  Gann's support and resistance points, because these points once they are 
  breached reverse their function (support becomes resistance and resistance 
  becomes support).I would be interested in knowing more about this 
  system....Thanks.Regards,Pal--- 
  In amibroker@xxxxxxxxxxxxxxx, "Al Venosa" <advenosa@xxxx> wrote:> 
  Pal,> > There is a trading system used by some traders called 
  the Bollinger Breakout System. It is similar to what DT has proposed. You 
  buy when the upper band is exceeded plus a small additional amount 
  (opposite for shorting). However, the standard deviation bands are much 
  smaller than the usual +/- 2. Usually, they are around +/- 0.4 or so. So, 
  the bands are quite a bit narrower and are used as breakout bands rather 
  than the usual rebound bands or support/resistance levels where one 
  sells at the top of the upper band and buys at the bottom of the lower 
  band. Just a different way of looking at things. It's a volatility 
  breakout system of sorts. By the way, the exit is the opposite of the 
  entry: sell at the breakout from the lower band (if long originally). 
  > > AV>   ----- Original Message ----- 
  >   From: palsanand >   To: 
  amibroker@xxxxxxxxxxxxxxx >   Sent: Wednesday, September 24, 
  2003 1:03 PM>   Subject: [amibroker] Re: The Reverse Engine 
  Bollinger Bands Problem, IV> > >   
  Hi,> >   I would characterize your definition of upper 
  or lower breakout as a >   continuation signal not a 
  breakout.  > >   In my opinion an upper breakout 
  always starts from the lower Bband >   and a lower 
  breakout always starts from the upper Bband.  The trick 
  >   there is to find that particular value of the Z-Score 
  (+/-2)that will >   detect the breakout or counter-trend 
  pullback.  It is made much >   easier by calculating a 
  range of Z-Scores with different moving >   averages (2-21) 
  & performing a check on it using StochZ(50) & 
  StochZ>   (200).> >   The 
  Bollinger Bands are Standard Deviation Bands.  It's superiority 
  >   is in showing your investments volatility along with the 
  likely >   support and resistance areas (Z=0).  The 
  extremes of the band (+/-2)>   are considered 
  "unusual".  Every time you see an investment reach the 
  >   extremes, it is said to be at the "Bollinger Band".  
  However, it is >   also a key turning point.  The 
  price can be expected to be anywhere >   within the 95% 
  confidence band at any time.  The moment the >   
  investment hits the extremes, it is now statistically significant and 
  >   something has caused this new valuation and it is time to 
  search for >   a signal using your favorite Entry/Exit 
  Trading Signal Detection >   system.> 
  >   But, sometimes a breakout becomes a counter-trend 
  pullback & vice->   versa.  The trick there is to 
  detect the volatility.  You may find >   that the 
  volatility characteristics are quite different for these two 
  >   types of market conditions.> >   
  Regards,> >   Pal>   --- In 
  amibroker@xxxxxxxxxxxxxxx, "Dimitris Tsokakis" <TSOKAKIS@xxxx> 
  >   wrote:>   > Here is an application of 
  the method.>   > Suppose we trade BBands and suppose we 
  buy at the upper breakout >   and sell some, say 8, days 
  later.>   > The usual code would be, from 1/1/2003 till 
  now>   > >   > // Without the 
  method>   > t=8;>   > 
  Buy=Cross(C,bt);Buy=ExRemSpan(Buy,t);Sell=Ref(Buy,-t);>   
  > SetTradeDelays( 1, 1, 1, 1 ) ;>   > 
  e2=Equity(1,3,1030101,1030924);>   > >   
  > where bt is the BBandTop(C,n,f) upper Bollinger Band>   
  > Buy/Sell at Open with delay +1.>   > 
  >   > Now we know in advance the critical level X1 to have 
  a BB breakout >   tomorrow. >   > We 
  may use it as a BuyPrice and set Buy delay to 0.>   > The 
  new system would be>   > >   > // With 
  the method>   > t=8;>   > 
  Buy=Cross(C,bt);Buy=ExRemSpan(Buy,t);Sell=Ref(Buy,-t);BuyPrice=Ref>   
  (x1,-1);>   > SetTradeDelays( 0, 1, 1, 1 ) 
  ;e1=Equity(1,3,1030101,1030924);>   > >   
  > The att. gif gives an outline of the improvement.>   
  > Of course, nothing is free in this world, we have to decide, when 
  >   the price reach the critical level X1, that it will close 
  higher !!>   > Explore the database for the n=1 last 
  quotations with>   > >   >  n=10; 
  f=2;>   > 
  Qn=Sum(C^2,n);Qn_1=Sum(C^2,n-1);>   > 
  Sn=Sum(C,n);Sn_1=Sum(C,n-1);>   > 
  Mn=Sn/n;Mn_1=Sn_1/(n-1);>   > 
  Kn=(1/n)*sqrt(n*Qn-Sn^2);Kn_1=(1/(n-1))*sqrt((n-1)*Qn_1-Sn_1^2);>   
  > bb=Mn-f*Kn;bt=Mn+f*Kn;>   > 
  S=Sn_1;Q=Qn_1;>   > 
  A2=(n-1)*(f^2-n+1);>   > 
  A1=-2*(f^2+1-n)*S;>   > 
  A0=f^2*n*Q-f^2*S^2-S^2;>   > 
  x1=(-A1-sqrt(A1^2-4*A2*A0))/(2*A2);>   > 
  x2=(-A1+sqrt(A1^2-4*A2*A0))/(2*A2);>   > 
  Plot(C,"C",1,8);>   > 
  Plot(X1,"",colorBlue,1);>   > 
  Plot(X2,"",colorBlue,1);Plot(bb,"BBandBot",7,1);Plot>   
  (bt,"BBandTop",7,1);>   > 
  PlotShapes(shapeDownTriangle*Cross(x2,Ref(C,1)),colorPink);>   
  > PlotShapes(shapeDownArrow*(Cross(bb,C)),colorRed);>   
  > 
  PlotShapes(shapeUpTriangle*Cross(Ref(C,1),x1),colorAqua);>   
  > 
  PlotShapes(shapeUpArrow*(Cross(C,bt)),colorBrightGreen);>   
  > Title="The next "+Name()+" Close should be "+"\n 
  *below"+WriteVal>   (x2)+" [ "+WriteVal(100*(-1+x2/C))+"% 
  ] for a BBandBot Cross"+>   > "\n *above"+WriteVal(x1)+" 
  ["+WriteVal(100*(-1+x1/C))+"% ] for a >   BBandTop 
  Cross"+>   > "\n  Actual Next Close = 
  "+WriteIf(Cum(1)!=LastValue(Cum>   
  (1)),WriteVal(Ref(C,1)),"?");>   > 
  t=8;>   > // With the method>   > 
  Buy=Cross(C,bt);Buy=ExRemSpan(Buy,t);Sell=Ref(Buy,-t);>   
  > BuyPrice=Ref(x1,-1);>   > SetTradeDelays( 0, 1, 1, 1 
  ) ;>   > 
  e1=Equity(1,3,1030101,1030924);>   > // Without the 
  method>   > 
  Buy=Cross(C,bt);Buy=ExRemSpan(Buy,t);Sell=Ref(Buy,-t);>   
  > SetTradeDelays( 1, 1, 1, 1 ) ;>   > 
  e2=Equity(1,3,1030101,1030924);>   > 
  Filter=e1>e2;>   > AddColumn(e2,"e 
  Without");>   > AddColumn(e1,"e 
  With");>   > AddColumn(100*(-1+e1/e2),"Profits % 
  Increment");>   > >   > to get an idea 
  of probable applications.>   > Dimitris 
  Tsokakis>   > >   > 
  >   > >   > >   > 
  >   > ----- Original Message ----- >   
  > From: Dimitris Tsokakis >   > To: 
  amibroker@xxxxxxxxxxxxxxx >   > Sent: Tuesday, September 
  23, 2003 1:15 PM>   > Subject: Fw: The Reverse Engine 
  Bollinger Bands Problem, III>   > >   
  > >   > If you expect a BBandBot(C,10,3) to cross CSCO 
  Close, perhaps you >   should wait for long. 
  >   > This type of cross never occurred the last 45 months 
  !!>   > There are some resctrictions in BBandbot(C,n,f) 
  parameters. >   > A. f upper limit>   
  > For a given n, the values of f are limited.>   > This 
  limit is not universal, it varies from stock to stock.>   
  > In AA window, explore the current stock for the last n=1 bars 
  with>   > >   > // f upper limit 
  for a given n>   > // Explore ONLY current stock, n=1 last 
  quotations>   > SetOption ("NoDefaultColumns" 
  ,True);>   > 
  AddTextColumn(Name(),"Name");>   > 
  n=10;>   > for(f=1.5;f<=3;f=f+0.1)>   
  > {>   > b=BBandBot(C,n,f);>   > 
  x=Cross(b,C);y=LastValue(Cum(x));>   > 
  if(y>0)>   > 
  {AddColumn(y,"f="+WriteVal(f,1.1),1.0);}>   > 
  }>   > Filter=1;>   >  
  >   > You may see the # of Cross(b,C) per f value. the 
  last column gives >   the upper limit of f for a given 
  n.>   > For the database it is better to use the 
  code>   >  >   > // f upper limit 
  for a given n>   > // Explore the database for the n=1 
  last quotations>   > SetOption ("NoDefaultColumns" 
  ,True);>   > 
  AddTextColumn(Name(),"Name");>   > 
  n=10;>   > for(f=1.5;f<=3;f=f+0.1)>   
  > {>   > b=BBandBot(C,n,f);>   > 
  x=Cross(b,C);y=LastValue(Cum(x));>   > 
  AddColumn(y,"f="+WriteVal(f,1.1),1.0);>   > 
  }>   > Filter=1;>   >  
  >   > For the N100 database no stock exceeded f=3 since 
  Jan2000.>   > >   > B. n lower 
  limit>   > For a given f there is a lower limit for n, 
  also variable from >   stock to stock.>   
  > >   > // n lower limit for a given 
  f>   > // Explore the database for the n=1 last 
  quotations>   >  SetOption ("NoDefaultColumns" 
  ,True);>   > 
  AddTextColumn(Name(),"Name");>   > 
  f=2.5;>   > for(n=3;n<20;n=n+1)>   
  > {>   > b=BBandBot(C,n,f);>   > 
  x=Cross(b,C);y=LastValue(Cum(x));>   > 
  AddColumn(y,"n="+WriteVal(n,1.0),1.0);>   > 
  }>   > Filter=1;>   > 
  >   > You will see that n should be greater than n=8 for a 
  probable Cross>   (b,C)>   > 
  >   > C. fmax for various n>   > For 
  your BBandBot parameters selection you should know the fmax for 
  >   various n.>   > // fmax for various 
  n>   > SetOption ("NoDefaultColumns" 
  ,True);>   > 
  AddTextColumn(Name(),"Name");>   > 
  for(n=10;n<210;n=n+10)>   > {>   > 
  for(f=1.5;f<=5;f=f+0.1)>   > {>   > 
  b=BBandBot(C,n,f);>   > 
  x=Cross(b,C);y=LastValue(Cum(x));>   > 
  if(y>0)>   > {fmax=f;}>   > 
  }>   > Filter=1;// explore for the n=1 last 
  quotations.>   > 
  AddColumn(fmax,"n="+WriteVal(n,1.0),1.1);>   > 
  }>   > >   > In the attached gif you 
  may see the fmax distribution for a group >   of stocks 
  [test period Jan2000 till now]>   > It is better to know 
  the mutual f,n limitations before using the >   Reverse 
  Engine BBands mechanism.>   > Dimitris 
  Tsokakis>   > >   >  
  >   > ----- Original Message ----- >   
  > From: Dimitris Tsokakis >   > To: 
  amibroker@xxxxxxxxxxxxxxx >   > Sent: Monday, September 
  22, 2003 1:53 PM>   > Subject: The Reverse Engine 
  Bollinger Bands Problem, II>   > >   > 
  >   > Here is the complete IB formula for BBandTop, 
  BBandbot.>   > >   > // Anticipating 
  the next bar BBandBot or BBandTop cross, by D. >   Tsokakis, 
  Sept 2003>   > n=20; f=2;>   > 
  Qn=Sum(C^2,n);Qn_1=Sum(C^2,n-1);>   > 
  Sn=Sum(C,n);Sn_1=Sum(C,n-1);>   > 
  Mn=Sn/n;Mn_1=Sn_1/(n-1);>   > 
  Kn=(1/n)*sqrt(n*Qn-Sn^2);Kn_1=(1/(n-1))*sqrt((n-1)*Qn_1-Sn_1^2);>   
  > bb=Mn-f*Kn;bt=Mn+f*Kn;>   > 
  S=Sn_1;Q=Qn_1;>   > 
  A2=(n-1)*(f^2-n+1);>   > 
  A1=-2*(f^2+1-n)*S;>   > 
  A0=f^2*n*Q-f^2*S^2-S^2;>   > 
  x1=(-A1-sqrt(A1^2-4*A2*A0))/(2*A2);>   > 
  x2=(-A1+sqrt(A1^2-4*A2*A0))/(2*A2);>   > 
  Plot(C,"C",1,8);>   > 
  Plot(X1,"",colorBlue,1);>   > 
  Plot(X2,"",colorBlue,1);Plot(bb,"BBandBot",7,1);Plot>   
  (bt,"BBandTop",7,1);>   > 
  PlotShapes(shapeDownTriangle*Cross(x2,Ref(C,1)),colorPink);>   
  > PlotShapes(shapeDownArrow*(Cross(bb,C)),colorRed);>   
  > 
  PlotShapes(shapeUpTriangle*Cross(Ref(C,1),x1),colorAqua);>   
  > 
  PlotShapes(shapeUpArrow*(Cross(C,bt)),colorBrightGreen);>   
  > Title="The next "+Name()+" Close should be "+"\n 
  *below"+WriteVal>   (x2)+" for a BBandBot 
  Cross"+>   > "\n *above"+WriteVal(x1)+" for a BBandTop 
  Cross"+>   > "\n  Actual Next Close = 
  "+WriteIf(Cum(1)!=LastValue(Cum>   
  (1)),WriteVal(Ref(C,1)),"?");>   > >   
  > The formula gives quite accurate results. Sometimes it is 
  useful.>   > At point Z1, the price should be below 
  13.845 and the next bar >   close was 
  13.840.>   > At point Z2, the price should be above 20.840 
  and the next bar >   close was 20.850.  
  >   > From the mathematical point of view, both crosses 
  come from the >   same 2nd degree equation 
  A2*X^2+A1*X+A0=0>   > Dimitris 
  Tsokakis>   > [to be continued]>   > 
  >   > ----- Original Message ----- >   
  > From: Dimitris Tsokakis >   > To: 
  amibroker@xxxxxxxxxxxxxxx >   > Sent: Monday, September 
  22, 2003 11:26 AM>   > Subject: The Reverse Engine 
  Bollinger Bands Problem>   > >   > 
  >   > What is the necessary next bar Close to see prices 
  below the next >   bar BBandbot ?>   
  > Steve Karnish is responsible for the question [and >   
  the ...headache], some time ago.>   > The following code 
  is dedicated to him.>   > Paste in IB 
  the>   > >   > // Anticipating the 
  next bar BBandbot cross, by D. Tsokakis, Sept >   
  2003>   > n=10; >   > 
  f=2;>   > 
  Qn=Sum(C^2,n);Qn_1=Sum(C^2,n-1);>   > 
  Sn=Sum(C,n);Sn_1=Sum(C,n-1);>   > 
  Mn=Sn/n;Mn_1=Sn_1/(n-1);>   > 
  Kn=(1/n)*sqrt(n*Qn-Sn^2);Kn_1=(1/(n-1))*sqrt((n-1)*Qn_1-Sn_1^2);>   
  > b=Mn-f*Kn;>   > S=Sn_1;Q=Qn_1;>   
  > A2=(n-1)*(f^2-n+1);>   > 
  A1=-2*(f^2+1-n)*S;>   > 
  A0=f^2*n*Q-f^2*S^2-S^2;>   > 
  x2=(-A1+sqrt(A1^2-4*A2*A0))/(2*A2);>   > 
  Plot(X2,"",colorBlue,1);Plot(C,"C",1,8);Plot(b,"BBandBot",7,1);>   
  > 
  PlotShapes(shapeUpArrow*Cross(x2,Ref(C,1)),colorWhite);>   
  > PlotShapes(shapeDownArrow*(Cross(b,C)),colorRed);>   
  > Title="The next "+Name()+" Close should be 
  <="+WriteVal(x2)+>   > "\nActual Next Close = 
  "+WriteIf(Cum(1)!=LastValue(Cum(1)),WriteVal>   
  (Ref(C,1)),"?");>   > >   > The 
  solution is the X2 array.>   > For visual verification, a 
  white arrow is plotted when the X2 >   crosses the next bar 
  close and a red arrow points the actual cross.>   > 
  >   > Dimitris Tsokakis>   > [to be 
  continued]> > 
  >         Yahoo! Groups Sponsor 
  >               
  ADVERTISEMENT>              
  >        
  >        > > 
  >   Send BUG REPORTS to bugs@xxxx>   Send 
  SUGGESTIONS to suggest@xxxx>   
  ----------------------------------------->   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 
  Yahoo! Terms of Service. > > >   
  --->   Outgoing mail is certified Virus 
  Free.>   Checked by AVG anti-virus system (<A 
  href="">http://www.grisoft.com).>   
  Version: 6.0.520 / Virus Database: 318 - Release Date: 
  9/18/2003
  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. 
  
<BLOCKQUOTE 
><FONT 
  face="Courier New">---Outgoing mail is certified Virus 
  Free.Checked by AVG anti-virus system (<A 
  href="">http://www.grisoft.com).Version: 6.0.520 
  / Virus Database: 318 - Release Date: 
9/18/2003






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.