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

Re: [amibroker] Re: visualising rectangles



PureBytes Links

Trading Reference Links

oeps, the code

/*

Rectangle System Development

after: "Professional Stock Trading", M. Conway / A. Behle, 2003, pages 106, 107, 108

Edward Pottasch, nov 2004

*/

RectangleLength = 4;
RangeLength = RectangleLength * 3;
RangeFactor = 1.1;
RangeRatioLimit = 0.3;
AtrPeriod = RangeLength;

// rectangle
hg = HHV(H,RectangleLength);
lw = LLV(L,RectangleLength);
HeightRectangle = hg - lw;

// preceding range
hgp = Ref(HHV(H,RangeLength),RectangleLength * -1);
lwp = Ref(LLV(L,RangeLength),RectangleLength * -1);
HeightRangeLength = hgp - lwp;

// aspect ratio
ar = HeightRectangle / HeightRangeLength;

// ATR
at = ATR(AtrPeriod);

// decide if it is a rectangle
yon = IIF(ar < RangeRatioLimit AND HeightRectangle < at * RangeFactor, 1, 0);

// breakout level
long_breakout_level = IIF(yon,yon * hg,null);
short_breakout_level = IIF(yon,yon * lw,null);

// decide about direction
Buy = IIF(H > Ref(long_breakout_level,-1),1,0);
BuyPrice = IIF(O > Ref(long_breakout_level,-1), O, Ref(long_breakout_level,-1));
Short = IIF(L < Ref(short_breakout_level,-1),1,0);
ShortPrice = IIF(O < Ref(short_breakout_level,-1), O, Ref(short_breakout_level,-1));

Plot(C,"",colorwhite,64);
PlotShapes(IIf(yon,shapeCircle,0),colorWhite, layer = 0, yposition = O, offset = 0 );

PlotShapes(IIf(Buy,shapeUpArrow,0),colorWhite, layer = 0, yposition = BuyPrice, offset = 0 );
PlotShapes(IIf(Short,shapeHollowDownArrow,0),colorLightBlue, layer = 0, yposition = ShortPrice, offset = 0 );


  ----- Original Message ----- 
  From: ed nl 
  To: amibroker@xxxxxxxxxxxxxxx 
  Sent: Sunday, November 14, 2004 4:44 PM
  Subject: Re: [amibroker] Re: visualising rectangles


  yeah that's right. The two white lines are the "reference range" and the red lines define the range which is of importance. The red lines become green lines once it finds a "rectangle pattern" according to the conditions describes in Conways book.  I'm sorry I did not provide too much details. It is just a gadget and I assume the reader can figure out by them selves what it does. The rectangles could be used inside a system.

  Code belowe I show white circles at points where it identifies a rectangle. You can put this code inside a chart below the other one (use the same settings, e.g. RectangleLength = 4, RangeFactor = 1.1). Then you see what I mean. The red range becomes green at the point where the white circle is drawn. Here it identifies a rectangle.

  Once you identified a rectangle you can start looking for a breakout at the next bar (see long + short signals),

  rgds, Ed




    ----- Original Message ----- 
    From: suree namsiripongpan 
    To: amibroker@xxxxxxxxxxxxxxx 
    Sent: Sunday, November 14, 2004 3:43 PM
    Subject: Re: [amibroker] Re: visualising rectangles


    Dear Ed, 

    I have already tried your code in my country index,
    i.e. ^SETI, I can see only the 2 white lines and 2 red
    lines.

    I tried to imagin to see the triangles, but i cannot
    spot.  Can you explain a bit more details....

    thanks. 


    --- ed nl <ed2000nl@xxxxxxx> wrote:

    > iascool,
    > 
    > in the Conway book they explain how to use
    > rectangles in a trading system. Rectangles precede a
    > breakout either on the long or on the short side.
    > Their system goes either long or short at the bar
    > following a rectangle if the price goes above /
    > below a certain value.
    > 
    > This code is only to play around and see what
    > happens in the chart. If you want to use the concept
    > in a system you'll have to do some additional
    > programming,
    > 
    > rgds, Ed
    > 
    >   ----- Original Message ----- 
    >   From: iascool 
    >   To: amibroker@xxxxxxxxxxxxxxx 
    >   Sent: Sunday, November 14, 2004 12:53 PM
    >   Subject: [amibroker] Re: visualising rectangles
    > 
    > 
    > 
    >   If you dont mind can u also share its significance
    > and application
    > 
    >   Regards
    >   --- In amibroker@xxxxxxxxxxxxxxx, "ed nl"
    > <ed2000nl@xxxx> wrote:
    >   > /*
    >   > 
    >   > Rectangle Development
    >   > 
    >   > after: "Professional Stock Trading", M. Conway /
    > A. Behle, 2003, 
    >   pages 106, 107, 108
    >   > 
    >   > Edward Pottasch, nov 2004
    >   > 
    >   > */
    >   > 
    >   > RectangleLength = 8;
    >   > RangeLength = RectangleLength * 3;
    >   > RangeFactor = 1.5;
    >   > RangeRatioLimit = 0.3;
    >   > AtrPeriod = RangeLength;
    >   > 
    >   > // rectangle
    >   > hg = SelectedValue(HHV(H,RectangleLength));
    >   > lw = SelectedValue(LLV(L,RectangleLength));
    >   > HeightRectangle = hg - lw;
    >   > 
    >   > // preceding range
    >   > hgp =
    > SelectedValue(Ref(HHV(H,RangeLength),RectangleLength
    > * -1));
    >   > lwp =
    > SelectedValue(Ref(LLV(L,RangeLength),RectangleLength
    > * -1));
    >   > HeightRangeLength = hgp - lwp;
    >   > 
    >   > // aspect ratio
    >   > ar = HeightRectangle / HeightRangeLength;
    >   > 
    >   > // ATR
    >   > at = SelectedValue(ATR(AtrPeriod));
    >   > 
    >   > // decide if it is a rectangle
    >   > yon = IIF(ar < RangeRatioLimit AND
    > HeightRectangle < at * 
    >   RangeFactor, 1, 0);
    >   > 
    >   > // visualize the rectangle
    >   > x = Cum(1);
    >   > lastx = LastValue(x); 
    >   > selv = SelectedValue(x);
    >   > 
    >   > // the rectangle
    >   > xx = IIF(x > selv - RectangleLength AND x <=
    > selv, x - (selv - 
    >   RectangleLength),null);
    >   > yy_l = lw + 0.0 * xx;
    >   > yy_h = hg + 0.0 * xx;
    >   > Plot(yy_l, "",
    > IIF(yon,colorBrightGreen,colorRed), IIF(yon,4,1));
    >   > Plot(yy_h, "",
    > IIF(yon,colorBrightGreen,colorRed), IIF(yon,4,1));
    >   > 
    >   > // preceding range
    >   > xx = IIF(x > selv - RectangleLength -
    > RangeLength AND x <= selv - 
    >   RectangleLength, x - (selv - RectangleLength -
    > RangeLength),null);
    >   > yy_l = lwp + 0.0 * xx;
    >   > yy_h = hgp + 0.0 * xx;
    >   > Plot(yy_l, "", colorWhite, 1);
    >   > Plot(yy_h, "", colorWhite, 1);
    >   > 
    >   > Plot(C,"",colorwhite,64);
    >   > 
    >   > "Aspect Ratio: " + writeval(ar);
    >   > "Height rectangle: " +
    > writeval(HeightRectangle);
    >   > "ATR * Rangefactor: " + writeval(at *
    > RangeFactor);
    >   > "Rectangle detected: " + writeif(yon," TRUE","
    > FALSE");
    >   > 
    >   > [Non-text portions of this message have been
    > removed]
    > 
    > 
    > 
    > 
    > 
    >   Check AmiBroker web page at:
    >   http://www.amibroker.com/
    > 
    >   Check group FAQ at:
    >
    http://groups.yahoo.com/group/amibroker/files/groupfaq.html
    > 
    > 
    > 
    >         Yahoo! Groups Sponsor 
    >               ADVERTISEMENT
    >              
    >        
    >        
    > 
    > 
    >
    ------------------------------------------------------------------------------
    >   Yahoo! Groups Links
    > 
    >     a.. To visit your group on the web, go to:
    >     http://groups.yahoo.com/group/amibroker/
    >       
    >     b.. To unsubscribe from this group, send an
    > email to:
    >     amibroker-unsubscribe@xxxxxxxxxxxxxxx
    >       
    >     c.. Your use of Yahoo! Groups is subject to the
    > Yahoo! Terms of Service. 
    > 
    > 
    > 
    > [Non-text portions of this message have been
    > removed]
    > 
    > 



                
    __________________________________ 
    Do you Yahoo!? 
    Check out the new Yahoo! Front Page. 
    www.yahoo.com 




    Check AmiBroker web page at:
    http://www.amibroker.com/

    Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html 


          Yahoo! Groups Sponsor 
                ADVERTISEMENT
               
         
         


  ------------------------------------------------------------------------------
    Yahoo! Groups Links

      a.. To visit your group on the web, go to:
      http://groups.yahoo.com/group/amibroker/
        
      b.. To unsubscribe from this group, send an email to:
      amibroker-unsubscribe@xxxxxxxxxxxxxxx
        
      c.. Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service. 



  [Non-text portions of this message have been removed]



  Check AmiBroker web page at:
  http://www.amibroker.com/

  Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html 


        Yahoo! Groups Sponsor 
         
        Get unlimited calls to

        U.S./Canada
       
       


------------------------------------------------------------------------------
  Yahoo! Groups Links

    a.. To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/
      
    b.. To unsubscribe from this group, send an email to:
    amibroker-unsubscribe@xxxxxxxxxxxxxxx
      
    c.. Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service. 



[Non-text portions of this message have been removed]



------------------------ Yahoo! Groups Sponsor --------------------~--> 
$9.95 domain names from Yahoo!. Register anything.
http://us.click.yahoo.com/J8kdrA/y20IAA/yQLSAA/GHeqlB/TM
--------------------------------------------------------------------~-> 

Check AmiBroker web page at:
http://www.amibroker.com/

Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

<*> To unsubscribe from this group, send an email to:
    amibroker-unsubscribe@xxxxxxxxxxxxxxx

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