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

[amibroker] visualising rectangles



PureBytes Links

Trading Reference Links

/*

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]



------------------------ Yahoo! Groups Sponsor --------------------~--> 
Make a clean sweep of pop-up ads. Yahoo! Companion Toolbar.
Now with Pop-Up Blocker. Get it for free!
http://us.click.yahoo.com/L5YrjA/eSIIAA/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/