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

Re: Auto Channels/Triangles/Wedges Ver 1.2



PureBytes Links

Trading Reference Links

Well it is getting better. This code has a fancy trick that Thomazs
supplied.

Code starts here++++++++++
//Channel,Triangle,Wedge Formations//

perchg =10; // 10 percent swings, can be changed

maxgraph=3;
emptyval = -1e10; // do not chnage this line

//===================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;

graph2color=graph1color=7; 
pdaysback=lastvalue(peakbars(high,perchg,3));
graph1style=5;
graph1=IIF( pkx <= lastvalue( pkx ) - pdaysback, emptyval, 
toptrendline );

tdaysback=lastvalue(troughbars(low,perchg,3));
graph2style=5;
graph2=IIF( pkx <= lastvalue( pkx ) - tdaysback, emptyval, 
bottrendline );

//====end