PureBytes Links
Trading Reference Links
|
Try surrounding your counter with "if LastBarOnChart then begin... end ;"
At 11:06 PM 7/14/2009, you wrote:
Date: Wed, 15 Jul 2009 14:06:16 +1000
From: "Rene Muench" <muenchr@xxxxxxxxxxxxxx>
Subject: Looking for some suggestions, to make this code run better??
Hi Everyone,
The code below runs OK, but is very slow.
I don't know how to determine the cause of its slow running and wonder if
anyone of you guys could shade some in sides on how to make it run faster?
I am attempting to remove TS charts background grid and relace it with
trendlines as outlined in the code.
Please don't ask why I assigned certain values to the arrays. I couldn't get
the code to work until I assign these values, whether that makes sense or
not is a different question.
Thanks in advance
Kind Regards,
Rene'
__________________________________________________________________
{Horizontal Trendlines by 7 points as of start of the chart and based on
close}
{sval = Starting amount, THVal = trendline Value}
{THDate Horizontal trendline date, THTime = Horizontal trendline time,
THTLRef = Horizontal trendline reference point}
Inputs:length(7),Min(308.00),Max(490.00);
vars: counter(0),sVal(0),THVal(0);
Arrays: THDate[10](0), THTime[10](0), THTLRef[32](100);
if currentbar = 1 then begin
THDate[0] = Date[0];
THTime[0] = Time[0];
end;
for counter = 1 to (Max - Min) + 1 begin
if counter = 1 then begin {start from the top }
sVal = Max; {Stet the first horizontal trendline}
THVal= sVal;
THTLRef[counter] = TL_New(THDate[0], THTime[0], THVal, LastCalcDate
, THTime[0], THVal);
THTLRef[counter] = TL_SetColor(THTLRef[counter], 15);
THTLRef[counter] = TL_SetStyle(THTLRef[counter], 2);
THTLRef[counter] = TL_SetExtRight(THTLRef[counter], true);
end
else begin if counter > 1 then begin
sVal = sval - length;
THVal= sVal;
THTLRef[counter] = TL_New(THDate[0], THTime[0], THVal, LastCalcDate
, THTime[0], THVal);
THTLRef[counter] = TL_SetColor(THTLRef[counter], 15);
THTLRef[counter] = TL_SetStyle(THTLRef[counter], 2);
THTLRef[counter] = TL_SetExtRight(THTLRef[counter], true);
end;
end;
end;
{end of code}
|