//---------------------------------------------------------------------------
// Deinitialization procedure (could be omitted)
//---------------------------------------------------------------------------
procedure Done; stdcall;
begin
// see Deinitialization procedure
end;
//---------------------------------------------------------------------------
// On parameters change procedure (could be omitted)
//---------------------------------------------------------------------------
procedure OnParametersChange; stdcall;
begin
// called when parameters of indicator were changed
end;
// this function draws session line
procedure DrawLine(index: integer; color: integer); stdcall;
var formattedDateTime : string;
begin
DateTimeToString(formattedDateTime, 'c', Time(index));
ObjectCreate(formattedDateTime, obj_TrendLine, 0, Time(index), 20000, Time(index), 0);
ObjectSet(formattedDateTime, OBJPROP_WIDTH, 1);
ObjectSet(formattedDateTime, OBJPROP_STYLE, integer(psDot));
if color = 1 then
begin
ObjectSet(formattedDateTime, OBJPROP_COLOR, clGreen);
end
else
begin
ObjectSet(formattedDateTime, OBJPROP_COLOR, clRed);
end;
end;
//---------------------------------------------------------------------------
// Calculation of single bar
//---------------------------------------------------------------------------
procedure Calculate(index: integer); stdcall;
var iHour: integer;
var iMinute: integer;
begin
// Time(index) identifies current bar open time
iHour := HourOf(Time(index));
iMinute := MinuteOf(Time(index));
if (index < maxBars) then
begin
if (iHour = startHour) and (iMinute = startMinute) then
DrawLine(index, 1);
if (iHour = endHour) and (iMinute = endMinute) then
DrawLine(index, 2);
end;
end;
exports
// these procedures should be declared as external