New Page 1
TPASSMomentum (Delphi
7: , create, private, protected, breakpoint,
)
.
. .
mmMenu : ""-->""
(itLoad). : odOpenDialog, lbDateTime
lbResult, "" (btnCalk),
SpinEdit (seCandle seDT),
Samples. *:

( *.txt)
FPriceSource
FIndicator ( ):
TfrmMomentum = class(TForm)
odOpenDialog: TOpenDialog;
mmMenu: TMainMenu;
itFile: TMenuItem;
itLoad: TMenuItem;
lbResult: TLabel;
btnCalk: TButton;
seDT: TSpinEdit;
lbDateTime: TLabel;
seCandle: TSpinEdit;
procedure itLoadClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure btnCalkClick(Sender: TObject);
procedure seCandleChange(Sender: TObject);
private
{ Private declarations }
FPriceSource:TPASSPriceSource;
FIndicator:TPASSMomentum;
public
{ Public declarations }
end;
|
OnCreate
FPriceSource
FIndicator nil:
procedure TfrmMomentum.FormCreate(Sender: TObject);
begin
FPriceSource:=nil;
FIndicator:=nil;
end;
|
OnClick "":
procedure TfrmMomentum.itLoadClick(Sender: TObject);
begin
if odOpenDialog.Execute then
begin
if FPriceSource<>nil then FreeAndNil(FPriceSource);
FPriceSource:=TPASSPriceSource.Create('',false);
FPriceSource.LoadDataFromTextFile(odOpenDialog.FileName);
end;
end;
|
, ,
, FPriceSource, ,
.
, , OnChange
seCandle:
procedure TfrmMomentum.seCandleChange(Sender: TObject);
begin
FPriceSource.CurrentItemIndex:=seCandle.Value;
lbDateTime.Caption:= DateTimeToStr(FPriceSource.GetDataByFieldName('DateTime'));
end;
|
, ,
""
procedure TfrmMomentum.btnCalkClick(Sender: TObject);
begin
if FIndicator<>nil then FreeAndNil(FIndicator);
FIndicator:=TPASSMomentum.Create(seDT.Value,'Close');
FIndicator.PriceSource:=FPriceSource;
lbResult.Caption:= intToStr(FIndicator.GetParameterByName('Value'));
end; |
,
. FPriceSource,
.
, .
"".
! *.

FParameters.Add('PriceFieldType',APriceFieldType)*;

,
FParameters . , ,
*:

( ),
F5,
( ) "Debu"
--> "Toggle breakpoint"*.

. ""
.
, "Watches" "View"
--> "Debug Windows" --> "Watches"*:

FParameters,
Insert.
*:

FParameters
nil*:

, ,
:
,
inherited Create;
, ,
F7 .
TPASSIndicator, :
inherited Create
FParameters:=TPASSParameters.Create
, FParameters . ,
TPASSMomentum nil.
,
Delphi. , ,
, . ,
. TPASSIndicator FParameters
private, TPASSMomentum
protected.
. !
PASSIndicators (, ),
FParameters . ,
,
private,
protected. , :
-
,
,
private
protected,
,
. PASSIndicators:
TPASSIndicator=Class(TPASSAbstractDataSource)
private
FParameters:TPASSParameters; // .
FPriceSource:TPASSPriceSource; // .
procedure SetPriceSource(APriceSource:TPassPriceSource);
procedure UpdateParameters; virtual; abstract;
public
constructor Create;
property PriceSource:TPASSPriceSource read FPriceSource write SetPriceSource;
procedure SetParameterByName(AParameterName:string; AParameterValue:Variant); virtual;
function GetParameterByName(AParameterName:string):Variant; virtual;
function GetResultByFieldName(AFieldName:string):double; virtual; abstract;
function GetResultByFieldNameAndIndex(FieldName:string; Index:LongInt):double; virtual; abstract;
function GetResultByFieldNum(AFieldName:integer):double; virtual; abstract;
function GetResultByFieldNumAndIndex(FieldName:Integer; Index:LongInt):double; virtual; abstract;
procedure First; virtual; abstract;
procedure Last; virtual; abstract;
function Next:boolean; virtual; abstract;
function Prev:boolean; virtual; abstract;
function GetIndicatorName:string; virtual; abstract;
Destructor Destroy; virtual;
end;
|
,
TPASSIndicator
protected. .
PASSIndicators,
.
, * ,
. 1274
"Delphi",
"Borland Software Corporation".
|