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

Problems with "Update at every tick" in ts2000i



PureBytes Links

Trading Reference Links

I use the following code to draw "pivot". And it's set to update at 
every tick. The idea is to instantly delete all old TL at the first tick 
of todays session, draw the TL and then do nothing else with the TLs 
rest of the day. This code keeps updating it at every tick till the 
completion of the first bar, but that's okay.

Trouble is, if this indicator is applied on charts, it messes up all 
other drawing (other indicators draw messy, candles print kinda funny, 
with parts of them missing & being redrawn) _even after_ the first bar 
of the day is done. After the indicator has drawn the TLs, if I "format" 
the indicator and disable "update at every tick", everything works 
great. Then why don't I disable "update at every tick" by default? Well, 
then I won't get the TLs till the end of the first bar.

What's wrong with my code? After the first bar, this is essentially a 
no-op, right? But ts2ki must be trying to do some drawing no matter 
what. I have used it earlier with TS 7.x, and it was just fine. Is this 
just inefficient & buggy TL handling in 2ki?

Thanks,

Abhijit



{==========================================================}
input:
	{Pivot colors}
	PvColor(White), R1Color(Green), S1Color(Red), R2Color(Blue), 
S2Color(Magenta);


var:
	Pv(0), R1(0), S1(0), R2(0), S2(0);

array:
	TLArray[10, 5](0);

{This should execute only on the first bar of the day}
if(Date <> Date[1]) then
begin
	Pv = (HighD(1) + LowD(1) + OpenD(0)*2)/4;
	R1 = Pv*2 - LowD(1);
	S1 = Pv*2 - HighD(1);
	R2 = Pv + (R1 - S1);
	S2 = Pv - (R1 - S1);

	for value1 = 0 to 4
	begin
		if(TL_Exist(TLArray[0, value1])) then
			TL_Delete(TLArray[0, value1]);
	end;
	
	TLArray[0, 0] = TL_New(Date, Time, Pv, Date, 
MinutesToTime(TimeToMinutes(Time) + 5), Pv);
	TL_SetStyle(TLArray[0, 0], Tool_Dotted);
	TL_SetColor(TLArray[0, 0], PvColor);
	TL_SetExtRight(TLArray[0, 0], true);
	
	TLArray[0, 1] = TL_New(Date, Time, R1, Date, 
MinutesToTime(TimeToMinutes(Time) + 5), R1);
	TL_SetStyle(TLArray[0, 1], Tool_Dotted);
	TL_SetColor(TLArray[0, 1], R1Color);
	TL_SetExtRight(TLArray[0, 1], true);
	
	TLArray[0, 2] = TL_New(Date, Time, S1, Date, 
MinutesToTime(TimeToMinutes(Time) + 5), S1);
	TL_SetStyle(TLArray[0, 2], Tool_Dotted);
	TL_SetColor(TLArray[0, 2], S1Color);
	TL_SetExtRight(TLArray[0, 2], true);
	
	TLArray[0, 3] = TL_New(Date, Time, R2, Date, 
MinutesToTime(TimeToMinutes(Time) + 5), R2);
	TL_SetStyle(TLArray[0, 3], Tool_Dotted);
	TL_SetColor(TLArray[0, 3], R2Color);
	TL_SetExtRight(TLArray[0, 3], true);
	
	TLArray[0, 4] = TL_New(Date, Time, S2, Date, 
MinutesToTime(TimeToMinutes(Time) + 5), S2);
	TL_SetStyle(TLArray[0, 4], Tool_Dotted);
	TL_SetColor(TLArray[0, 4], S2Color);
	TL_SetExtRight(TLArray[0, 4], true);
end;