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

[amibroker] Re: Coding Swing Highs and Lows



PureBytes Links

Trading Reference Links

Hi,

Here's my take on it.
 Problem with LineArray function is that it only takes numbers not 
arrays thus cannot be backtested (at least I don't thick it can). 
Input has to be LastValue or SelectedValue.

The code:
 
Plot(C,"",colorGreen,styleBar);

 pivotlow = Ref(L,-1)>L AND L<Ref(L,1);
 y0=SelectedValue(ValueWhen(pivotlow,L,2));
 y1=SelectedValue(ValueWhen(pivotlow,L,1));
 x0=SelectedValue(ValueWhen(pivotlow,Cum(1)-1,2));
 x1=SelectedValue(ValueWhen(pivotlow,Cum(1)-1,1));
 Cond=y1>y0;
 Line=LineArray(x0,y0,x1,y1,1);
 Plot(IIf(Cond,Line,Null),"",colorBlue,styleLine|
 styleThick|styleNoRescale|styleNoLabel);
 PlotShapes((Cum(1)-1==x0 OR Cum(1)-1==x1)
 *shapeSmallCircle,colorBlue,0,L); 
 PlotShapes((cond AND Cross(Cum(C<Line),0) AND Cum(1)-1>x1)
 *shapeDownArrow,colorRed,0,H);
 

Title="TD Demand Line";
GraphXSpace=4;

Johan




--- In amibroker@xxxxxxxxxxxxxxx, "Martin M" <marmal@xxxx> wrote:
> Hi, 
> 
> My first post, let's see if this works...
> 
> In his book The New Science of Technical Analysis Tom Demark 
describes objective and automatic ways to draw trendlines. For 
example: a TD demand line can be drawn connecting the two most 
recent troughs conforming to the following criteria:
> Yesterday's low is higher than today's low
> Tomorrow's low is higher than today's low
> 
> So a trough has higher lows on both sides. The two most recent 
troughs are then connected with a trendline and the trendline is 
extended into the future. If at anytime the trendline is broken a 
short position can be initiated at the point of the line break. If a 
new trough is created the trendline is re-drawn between the lows of 
the two most recent troughs. Additionally, the demand line must have 
a positive slope so the most recent trough's low must be higher than 
the previous one.
> 
> Similarly, a TD supply line kan be drawn connceting the two most 
recent tops (a bar with lower highs on both sides) and a break of a 
supply line can work as a trigger for a long position or to cover a 
short or both. Likewise, the supply line must have a negative slope.
> 
> I have seen succesful trading systems only based on TD Lines, but 
I am not good enough to program it into amibroker. So I was 
wondering if someone can help?
> It doesn't look too difficult, though. The troughs and tops 
must "only" be defined and connected with trendlines.
> 
> Any help would be very appreciated,
> Martin from Sweden



------------------------ Yahoo! Groups Sponsor ---------------------~-->
Buy Ink Cartridges or Refill Kits for your HP, Epson, Canon or Lexmark
Printer at MyInks.com. Free s/h on orders $50 or more to the US & Canada.
http://www.c1tracking.com/l.asp?cid=5511
http://us.click.yahoo.com/mOAaAA/3exGAA/qnsNAA/GHeqlB/TM
---------------------------------------------------------------------~->

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