PureBytes Links
Trading Reference Links
|
Hello:
I have tweaked TZ's auto trendline code to see
Channels/Triangles/Wedges. As I scrolled thru my tickers I saw
many lost opportunities. Well, no more!
The entire code is listed below. Paste it in the Indicator
Window, then Apply. Best viewed alone in one sheet
Some tickers show very textbook like formations and breakouts:
Examples:ABT, ADI on NYSE, AEP on NASDAQ, AEL on Toronto.
If you know how to limit the lines, say for the last 3 months, then
the charts will look even better. Thomasz might have a way to do it.
The code follows.
Nand
--------------------------------------------------------
//Channel,Triangle,Wedge Formations//
maxgraph=5;
perchg = 10; // 10 percent swings, can be changed
//===================get bottom trendline
btx = cum(1);
btstartvalue = lastvalue( trough( low, perchg, 1 ) );
btendvalue = lastvalue( trough( low, perchg, 2 ) );
btstartbar = lastvalue( valuewhen( low ==btstartvalue, btx, 1 ) );
btendbar = lastvalue( valuewhen( low == btendvalue, btx, 1 ) );
bta = (btendvalue-btstartvalue)/(btendbar-btstartbar);
btb =btstartvalue;
bottrendline = bta * ( btx - btstartbar ) + btb;
//==================get top trendline
pkx = cum(1);
pkstartvalue = lastvalue( peak( high, perchg, 1 ) );
pkendvalue = lastvalue( peak( high, perchg, 2 ) );
pkstartbar = lastvalue( valuewhen( high == pkstartvalue, pkx, 1 ) );
pkendbar = lastvalue( valuewhen( high == pkendvalue, pkx, 1 ) );
topa = (pkendvalue-pkstartvalue)/(pkendbar-pkstartbar);
topb = pkstartvalue;
toptrendline = topa * ( pkx - pkstartbar ) +topb;
//===========draw lines on a price chart
graph0 = close;
graph0style=64;
graph0color=2;
graph1style = 5;
graph1color = 8;
graph1=toptrendline;
graph2style=5;
graph2color = 5;
graph2=bottrendline;
//====end for now
|