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

Re: Trendline breakout problem



PureBytes Links

Trading Reference Links

Your code is being executed on every bar so the statement:

    Value7=TL_New(Value1,Value2,Value3,Value4,Value5,Value6);

is drawing a new trendline on every bar, which probably accounts for
the ID number going to #1740.

The statements:

    Value1=TL_GetBeginDate(0);
    ...

will return the same value on every bar (since the TL#0 has not
moved) so you only need to execute them once on CurrentBar = 1.

Then, I think you should be using the TL_GetVal statement to find the
value of the trendline on any bar. This can only be done on bars
where the trendline is present so it needs to be inside the test for
a valid trendline. So I suspect you need something like the following
code:

    if CurrentBar = 1 then begin
       Value1=TL_GetBeginDate(0);
       Value2=TL_GetBeginTime(0);
       Value3=TL_GetBeginVal(0);
       Value4=TL_GetEnddate(0);
       Value5=TL_GetEndTime(0);
       Value6=TL_GetEndVal(0);
    end;

    if Date >= Value1 and Date <= Value4 then begin
       Value7 = TL_GetValue(0, Date, Time);
       if close crosses over  Value7 then buy  on close;
       if close crosses under Value7 then sell on close;
    end;


Bob Fulks


At 1:38 AM +0200 8/4/01, Yarroll wrote:

>Hello List,
>
>I've been experimenting with a very simple trendline breakout system, just
>to make sure it works as I hoped to. I first deleted all drawing objects
>from the chart, then added a new trendline (its ID was understandably #0).
>This is a downward sloping trendline and I made sure that the close crosses
>above it at one point. The code is as follows:
>
>Value1=TL_GetBeginDate(0);
>Value2=TL_GetBeginTime(0);
>Value3=TL_GetBeginVal(0);
>Value4=TL_GetEnddate(0);
>Value5=TL_GetEndTime(0);
>Value6=TL_GetEndVal(0);
>Value7=TL_New(Value1,Value2,Value3,Value4,Value5,Value6);
>
>If Date>Value1 and Date<value4 then begin
>if close crosses above Value7 then buy this bar 1 contract on close;
>end;
>
>{values 1 and 4 are 2 different dates on the chart, covering trendline's
>period}
>
>
>I applied this strategy to the chart... There are NO trades in Strategy
>Performance Report (although the close DOES cross above the trendline), and
>funniest of all - TradeStation changed the TL ID from #0 to #1740!!!
>LOL. I changed the code above replacing 0s with 1740s and sure enough, the
>TL ID on the chart was 0 back again, LOL.
>
>Am I missing something? Any other way to do this?
>
>Thanks, and all the best
>
>Yarroll