Программирование - это просто
Advertisement
arrow arrow , , arrow (TGauge, virtual, abstract, momentum).
07.02.2023 .
1:
C#
Delphi
Web-
Excel-
.
(TGauge, virtual, abstract, momentum). E-mail
megabax   
12.11.2009 .
New Page 1

(TGauge, virtual, abstract, momentum).

.

( ) :

, , . :

TPASSStatAnalizTemplate=class(TObject)
protected
     FIndicator:TPASSIndicator;
     FProfitChange:double;
     FDrawdownChange:double;
     FLastSignalPrice:double; //
     FAnalizCandleCount:LongInt; //
     FSignalType:TPASSSignalsTypes;
     FParameters:TPASSParameters;
     FStoreData:TPASSStatStoreDataTemplate;
     procedure SaveTestResult;
public
     Gauge:TGauge;
     constructor Create(AIndicator:TPASSIndicator; AAnalizCandleCount:LongInt; AStoreData:TPASSStatStoreDataTemplate);
     function FindSignal:boolean; virtual; abstract;
     function FindSignalRotate:boolean; virtual; abstract;// ,
     procedure GetChange;
     procedure Test;
     Destructor Destroy;
end;
 

, , , . . :

  • FIndicator - . TPASSIndicator, ( momentum), , , .
  • FProfitChange - , .
  • FDrawdownChange - , .
  • FLastSignalPrice - . , . , , .
  • FAnalizCandleCount - , ().
  • FSignalType - : . PASSBaseObj. .
  • FParameters - . - . . , . : .  " - " , .

  • FStoreData - , .

SaveTestResult. . :

procedure TPASSStatAnalizTemplate.SaveTestResult;
begin
      FStoreData.AddData(FParameters);
end;

Public:

  • Gauge - (TGauge). , :

    (TGauge, virtual, abstract, momentum)

TGauge Samples*:

    (TGauge, virtual, abstract, momentum)

, TGauge, uses , , Gauges:

uses PASSIndicators, PASSBaseObj, SysUtils, classes, Gauges;

TPASSStatAnalizTemplate:

  • Create - , . ; , , . :
constructor TPASSStatAnalizTemplate.Create(AIndicator:TPASSIndicator; AAnalizCandleCount:LongInt; AStoreData:TPASSStatStoreDataTemplate);
begin
inherited Create;
    FIndicator:=AIndicator;
    FAnalizCandleCount:=AAnalizCandleCount;
    FStoreData:=AStoreData;
    FParameters:=TPASSParameters.Create;
    FParameters.Add('ProfitChange',0, ptFloat);
    FParameters.Add('DrawdownChange',0, ptFloat);
    FParameters.Add('SignalResult',enBuy, ptSignal);
    FParameters.Add('SignalDate',0, ptData);
    FParameters.Add('ProfitChangeSign',enBuy, ptFloat);
end;

, . . TPASSParameters, .

  • FindSignal - . , , . .
  • FindSignalRotate - , . , , (), .  , .

  • GetChange - FAnalizCandleCount:

procedure TPASSStatAnalizTemplate.GetChange;
var  CurrentItemIndex, I:LongInt; BarData:TBarStructure;
       FMaxPrice, FMinPrice:double;
begin
      CurrentItemIndex:=FIndicator.PriceSource.CurrentItemIndex;
      FLastSignalPrice:=FIndicator.PriceSource.GetDataByFieldNameAndIndex('Open',CurrentItemIndex+1);
      if FLastSignalPrice=0 then raise exception.Create('TPASSStatAnalizTemplate.TPASSStatAnalizTemplate - . '+
             DateTimeToStr(FIndicator.PriceSource.GetBarData.DateTime));
      FMinPrice:=FLastSignalPrice;
      FMaxPrice:=FLastSignalPrice;
      for I:=1 to FAnalizCandleCount do
      begin
          if not(FIndicator.Next) then break;
          BarData:=FIndicator.PriceSource.GetBarData;
          if BarData.Hight>FMaxPrice then FMaxPrice:=BarData.Hight;
          if BarData.Low<FMinPrice then FMinPrice:=BarData.Low;
      end;
      if FSignalType=enBuy then
      begin
          FProfitChange:=(FMaxPrice-FLastSignalPrice)/FLastSignalPrice;
          FDrawdownChange:=(FLastSignalPrice-FMinPrice)/FLastSignalPrice;
      end else
      begin
         FProfitChange:=(FLastSignalPrice-FMinPrice)/FLastSignalPrice;
         FDrawdownChange:=(FMaxPrice-FLastSignalPrice)/FLastSignalPrice;
      end;
      FIndicator.PriceSource.CurrentItemIndex:=CurrentItemIndex;
end;

, . :

      for I:=1 to FAnalizCandleCount do
      begin
          if not(FIndicator.Next) then break;
          BarData:=FIndicator.PriceSource.GetBarData;
          if BarData.Hight>FMaxPrice then FMaxPrice:=BarData.Hight;
          if BarData.Low<FMinPrice then FMinPrice:=BarData.Low;
      end;

, , , , . , , - . .

  • Test - , , , ,   :

procedure TPASSStatAnalizTemplate.Test;
var CurrentItemIndex:integer; LastSignalPrice:double; SignalType: TPASSSignalsTypes;
       SignalPrice:double;
begin
    while FindSignal do
    begin
       if FAnalizCandleCount+FIndicator.PriceSource.CurrentItemIndex>FIndicator.PriceSource.CountLoadedBars then exit;
      GetChange; //
      Gauge.Progress:=FIndicator.PriceSource.CurrentItemIndex;
      FParameters.SetParameterByName('ProfitChange',FProfitChange);
      FParameters.SetParameterByName('DrawdownChange',FDrawdownChange);
      FParameters.SetParameterByName('SignalResult',FSignalType);
      FParameters.SetParameterByName('SignalDate',FIndicator.PriceSource.GetBarData.DateTime);
      SignalType:=FSignalType;
      CurrentItemIndex:=FIndicator.PriceSource.CurrentItemIndex;
      LastSignalPrice:=FLastSignalPrice;
      if not(FindSignalRotate) then exit;
      if FLastSignalPrice=0 then raise Exception.Create('TPASSStatAnalizTemplate.Test - ');
      FIndicator.PriceSource.NextItem;
      SignalPrice:=FIndicator.PriceSource.GetBarData.Open;
      if SignalType=enBuy then
           FParameters.SetParameterByName('ProfitChangeSign',(SignalPrice-FLastSignalPrice)/FLastSignalPrice)
      else
           FParameters.SetParameterByName('ProfitChangeSign',(FLastSignalPrice-SignalPrice)/FLastSignalPrice);
      FIndicator.PriceSource.CurrentItemIndex:=CurrentItemIndex+1;
      SaveTestResult();
   end;
end;

, FStoreData .

  • :
Destructor TPASSStatAnalizTemplate.Destroy;
begin
    FParameters.Free;
    inherited Destroy;
end;

FParameters - , . FStoreData - , .

TPASSStatStoreDataTemplate ( TPASSStatAnalizTemplate)- -:

TPASSStatStoreDataTemplate=class(TObject)
public
     procedure AddData(AParameters:TPASSParameters); virtual; abstract;
end;

, , .

. , ,


, * ,   . 1274 "Delphi", "Borland Software Corporation".

 

( 27.07.2013 . )
 
« .   . »
 
© 2023 Программирование - это просто
Joomla! - , GNU/GPL.
© 2005-2008 Joom.Ru - Joomla!
Design by Mamboteam.com | Powered by Mambobanner.de
  .