## Comment on Pi - Overview and Feedback

commented on 15 Oct 2014, 10:25 AM

hi

can we make our own indicators

Const
IndicatorName = ‘Psychological ‘;
Layout = Separated;

var
Psyho: TLineGraph;
period, i: Integer;
psy1: real;
instr, time_int: string;
LinesColor: TColor;

procedure CreateSettings;
begin
end;

procedure ApplySettings;
begin
Period := StrToInt(GetSetting(‘candle_period’));
Psyho.Color := StrToColor(GetSetting(‘color’));
LinesColor := StrToColor(GetSetting(‘linescolor’));
SetTitle(‘Psychological Line: period = ‘ + GetSetting(‘candle_period’));
Instr:=GetSetting(‘instrmnt’);
time_int:=GetSetting(‘time_interval’);
end;

procedure Init;
begin

Psyho := TLineGraph.Create();
SetYScale(0,100);
end;

procedure Recalculate;
var
i: Integer;
begin
Psyho.Clear;
for i := 0 to SourceGraph.Count – 1 do
begin
end;
end; // Recalculate

function Psy(ValueIndex:Integer):double;
var i:integer;
Ind:integer;
begin
Ind:=0;
for i:=1 to (period) do
if ValueIndex-i-1>0 then
begin
if SourceGraph.CloseValue(ValueIndex-i)>SourceGraph.CloseValue(ValueIndex-i-1) then Ind:=Ind+1;
result:=(Ind/period)*100;
end;

end;

var LastTime: TDateTime;
begin

if ValueIndex > SourceGraph.Count-2 then
begin
if (Psy(ValueIndex)>=75) and (Psy(ValueIndex-1)<75) and (SourceGraph.DateTime(ValueIndex)LastTime) then
begin
ShowMessage(‘Maybe it is time to sell ‘ + instr + ‘. See ‘ + time_int + ‘ chart’);
LastTime := SourceGraph.DateTime(ValueIndex);
end;

if (Psy(ValueIndex)25) and (SourceGraph.DateTime(ValueIndex)LastTime) then
begin
ShowMessage(‘Maybe it is time to buy ‘ + instr + ‘. See ‘ + time_int + ‘ chart’);
LastTime := SourceGraph.DateTime(ValueIndex);
end;
end;

end;

procedure Draw;
var
Height, Y: Integer;
begin
Height := Bottom – Top;
Canvas.Pen.Color := LinesColor;
Y := Bottom – Round(0.25 * Height);
Canvas.Line(Left, Y, Right, Y);
Y := Bottom – Round(0.75 * Height);
Canvas.Line(Left, Y, Right, Y);
end