PureBytes Links
Trading Reference Links
|
Try the code below for semi-automatically (input: dys) extending a
TL_New(....) line drawn on a daily chart.
The difficulty here is the mixing of dates (used in drawing TL_New(…))
and barnumbers (in TLValue (which finds the price at the end of the
extension)). What is the date of, say 8 bars ahead (the bar you want to
extend to)?
And to do this in a minute chart is more complex due to the mixing of
days and minutes on the time scale.
This extension of a TL_New(…) is done in Linear Regression Lines (see
the PE code for LinearRegValue (TargetB)). There, only bars are used for
the extension.
////////////////////////
input: start(1021001), ends(1021010),p1(l-1), p2(h+1),dys(8);
var:TL(0),bn1(0),bn2(0), TLValuee(0), Tbar(dys),cnt(-1);
array:bbn[1000](0);
array:dday[1000](0);
if d>=ends then begin
cnt=cnt+1;
bbn[cnt]=barnumber;
dday[cnt]=d;
end;
if d= start then
BN1=barnumber;
if d=ends then begin
BN2=barnumber;
If bn2 - bn1 <> 0 Then
TLValuee = (P1 - P2) / (bn2 - bn1) * (bn1 -(bn2+ TBar)) + P1 ;
TL = TL_New(start,1600,p1, ends,1600,p2 );
TL_SetStyle(TL, 1);
TL_SetColor(TL, blue);
end;
if currentbar=bbn[dys] then TL_SetEnd(TL,dday[dys] ,1600 , TLValuee);
Ian wrote:
> I can now use TL_New to draw a
> trendline between two stipulated points, in this case between two highs.
>
> What I'd like to do is to extend the line to the right by so-many bars.
> The only way I can see to do this is with TL_SetEnd but that requires
> that you have a specific date, time and price. I don't suppose there is
> a TL_ExtendLineBy-X-bars function, is there...? (:-)
>
> Given that I already have two dates, two times and two prices of the
> highs to draw the line in the first place, is there a formula that would
> let me calculate new end values for so-many bar in the future?
>
|