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

Re: Trendline detector in trading system



PureBytes Links

Trading Reference Links

Marek,
You may look at
http://www.amibroker.com/library/detail.php?id=105
first comment, /*Pattern Recognition graph*/ 
and 
http://www.amibroker.com/library/detail.php?id=103
for stochastic trendlines.
Does it help ?
Dimitris Tsokakis
--- In amibroker@xxxx, "Marek Chlopek" <mchlopek@xxxx> wrote:
> Hi all,
> We have an unique function "STUDY" in Amibroker that gives us 
possibility to
> refer from AFL code to line (often plotted as a trendline or 
vertical for
> stop loss) that has been manually drawn by the user.
> 
> I was wondering if there is a ready-to-use formula that 
automatically
> detects trendlines? This could be useful for trading system with 
entry
> and/or exit strategy that involves barrier stops.
> Regards
> Marek Chlopek
> 
> NB:
> 
> Please find enclosed additional description from the article 
published in
> S&C.
> The C++ code is also available (excluding some header files with 
variables
> structure definitions).
> 
> ----------------
> Stocks & Commodities V16:7 (324-328): Barrier Stops And Trendlines 
by J.
> Katz, Ph.D., and D. McCormick
> Copyright (c) Technical Analysis Inc.
> 
> TRENDLINE DETECTOR
> The algorithm that detects the trendlines, and that is accessed via 
calls to
> the functions "UpTL" and "DownTL"
> (see sidebar "C++ code"), operates as follows. Let us consider 
trendlines
> generated by UpTL - trendlines sloping
> upward and that exist below the price. A search is made to 
determine all
> lines with the following properties: First,
> the line must connect two price points within the lookback period, 
and
> second, other than these two points, no other
> points must either touch or penetrate beyond the line, and third, 
the line
> must fall between yl and yh (y-axis) at bar cb
> (current bar, x-axis).
> 
> A count is made of all lines satisfying these three requirements. 
This count
> is the return value from the function. The function also returns 
the median
> of the lines if there is more than one, or the line itself, if 
there is only
> a single one, via a trendline class variable. If no lines are found 
that
> meet all the requirements, a count of zero is returned; in such 
cases, the
> trendline returned should be ignored, as it will contain garbage. 
The
> function "DownTL" works in exactly the same way, except that it 
finds lines
> that are above the price rather than below it.
> 
> The functions "FindUpslopeTrend" and "FindDownslope Trend" step 
through
> ranges moving away from the price until one of the previously 
mentioned
> functions returns a count greater than one, indicating the presence 
of at
> least one valid trendline lying within the specified range.
> 
> These functions also impose additional criteria; not just any 
trendline will
> do. We require that the two price points determining the line have a
> separation of greater than five bars and that the most recent of 
these two
> points exists at
> least one bar prior to the current bar. If all of these conditions 
are met,
> we have found a valid trendline. The way these
> functions are set up, they will attempt to find the closest 
trendlines that
> are not more than $4,000 away from the current price using the old 
S&P 500
> contract. We use the old S&P 500 contract, since most of our 
historical data
> consists of this contract.