I wanted to modify the pivot indicator supplied with Forex Tester 2. I found the source code to the new pivot indicator on the forum and modified it. I then complied it using lazarus (following the same steps in the video instructions) and the indicator installed and worked fine but it is 6MB in size while all the supplied indicator .dll files are around 100KB.
Is there a way to compile the indicator so that it is smaller? Having a smaller file size would make it much easier to share with other people.
I've included the code below in case that helps at all.
Thanks!
Adrian
Code: Select all
//---------------------------------------------------------------------------
// Pivot Points
//---------------------------------------------------------------------------
library AJPivotPoints;
uses
SysUtils,
classes,
graphics,
math, DateUtils,
IndicatorInterfaceUnit,
TechnicalFunctions in 'TechnicalFunctions.pas';
var
Continuous: boolean = false;
PivotType: integer = 0;
// index buffers
PP, R3, S3: TIndexBuffer;
//---------------------------------------------------------------------------
// Initialization
//---------------------------------------------------------------------------
procedure Init; stdcall;
begin
// define parameters
IndicatorShortName('Pivot Points 2');
SetOutputWindow(ow_ChartWindow);
RegOption('Pivot Type', ot_EnumType, PivotType);
AddOptionValue('Pivot Type', 'Daily');
AddOptionValue('Pivot Type', 'Weekly');
AddOptionValue('Pivot Type', 'Monthly');
AddOptionValue('Pivot Type', 'Yearly');
PivotType := 0;
RegOption('Continuous', ot_Boolean, Continuous);
// create index buffers
PP := CreateIndexBuffer;
R3 := CreateIndexBuffer;
S3 := CreateIndexBuffer;
IndicatorBuffers(3);
SetIndexBuffer(0, R3);
SetIndexStyle(0, ds_Line, psDot, 1, clRed);
SetIndexLabel(0, 'R3');
SetIndexBuffer(1, PP);
SetIndexStyle(1, ds_Line, psDot, 1, clYellow);
SetIndexLabel(1, 'PP');
SetIndexBuffer(2, S3);
SetIndexStyle(2, ds_Line, psDot, 1, clRed);
SetIndexLabel(2, 'S3');
end;
//---------------------------------------------------------------------------
// Deinitialization
//---------------------------------------------------------------------------
procedure Done; stdcall;
begin
//
end;
//---------------------------------------------------------------------------
// Calculate bar
//---------------------------------------------------------------------------
procedure Calculate(index: integer); stdcall;
var
tm, tm1: TDateTime;
day, week, day1, week1, month, month1, year, year1, i: integer;
h, l, c, _pp: double;
NewPeriod: boolean;
procedure SetValues(index: integer; value: double);
begin
PP[index] := value;
R3[index] := value;
S3[index] := value;
end;
function WeekDay(tm: TDateTime): boolean;
var
day: integer;
begin
day := DayOfWeek(tm);
result := (day <> 1) and (day <> 7);
end;
begin
if index = Bars - 1 then
begin
SetValues(index, 0);
exit;
end;
tm := Time(index);
tm1 := Time(index + 1);
day := trunc(tm);
day1 := trunc(tm1);
week := WeekOf(day);
week1 := WeekOf(day1);
month := MonthOf(day);
month1 := MonthOf(day1);
year := YearOf(day);
year1 := YearOf(day1);
case PivotType of
0: NewPeriod := day <> day1;
1: NewPeriod := week <> week1;
2: NewPeriod := month <> month1;
else NewPeriod := year <> year1;
end;
if not(NewPeriod) then
begin
// the same period
PP[index] := PP[index + 1];
R3[index] := R3[index + 1];
S3[index] := S3[index + 1];
exit;
end;
// calculate pivots
i := index + 1;
_pp := PP[i];
if not(Continuous) then
SetValues(index + 1, 0);
h := High(i);
l := Low(i);
c := Close(i);
inc(i);
while (PP[i] = _pp) and (i < Bars) do
begin
h := Max(High(i), h);
l := Min(Low(i), l);
inc(i);
end;
_pp := (h + l + c)/3;
PP[index] := _pp;
R3[index] := h + 2*(_pp - l);
S3[index] := l - 2*(h - _pp);
end;
exports
Init, Done, Calculate;
begin
end.