Программирование - это просто
Advertisement
arrow arrow , , arrow (repeat, until).
08.02.2023 .
1:
C#
Delphi
Web-
Excel-
.
(repeat, until). E-mail
megabax   
19.11.2009 .
New Page 1

(repeat, until).

.

momentum,   . , . TPASSStatAnalizMomentum:

TPASSStatAnalizMomentum=class(TPASSStatAnalizTemplate)
     function FindSignal:boolean; override;
     function FindSignalRotate:boolean; override;
     procedure Test;
end;

, FindSignal FindSignalRotate :

function TPASSStatAnalizMomentum.FindSignal:boolean;
var LastCandleIndex:integer; s:string;
begin
     Result:=false;
     LastCandleIndex:=1;
     repeat
         if FIndicator.GetResultByFieldName('Value')=0 then LastCandleIndex:=2 else LastCandleIndex:=1;
         if (FIndicator.GetResultByFieldName('Value')>=0) and
            (FIndicator.GetResultByFieldNameAndIndex('Value',FIndicator.PriceSource.CurrentItemIndex-LastCandleIndex)<0) then
         begin
             FSignalType:=enBuy;
             Result:=true;
             exit;
         end;
         if (FIndicator.GetResultByFieldName('Value')<0) and
             (FIndicator.GetResultByFieldNameAndIndex('Value',FIndicator.PriceSource.CurrentItemIndex-LastCandleIndex)>=0) then
        begin
            FSignalType:=enSell;
            Result:=true;
            exit;
        end;
    until not FIndicator.Next;
end;

function TPASSStatAnalizMomentum.FindSignalRotate:boolean;
var LastSignalType:TPASSSignalsTypes; toNext:boolean;
begin
    LastSignalType:=FSignalType;
    toNext:=true;
    if not(FIndicator.PriceSource.NextItem) then
    begin
       Result:=false;
       exit;
    end;
    repeat
        if not FindSignal then
        begin
           Result:=false;
           exit;
        end;
        if (LastSignalType=enBuy) and (FSignalType=enSell) then
        begin
          Result:=true;
          exit;
        end;
        if (LastSignalType=enSell) and (FSignalType=enBuy) then
        begin
           Result:=true;
           exit;
        end;
   until toNext;
   Result:=false;
end;

:

1.

          if (FIndicator.GetResultByFieldName('Value')>=0) and
            (FIndicator.GetResultByFieldNameAndIndex('Value',FIndicator.PriceSource.CurrentItemIndex-LastCandleIndex)<0) then

, , :

             FSignalType:=enBuy;
             Result:=true;
             exit;

2.

         if (FIndicator.GetResultByFieldName('Value')<0) and
             (FIndicator.GetResultByFieldNameAndIndex('Value',FIndicator.PriceSource.CurrentItemIndex-LastCandleIndex)>=0) then

, , :

            FSignalType:=enSell;
            Result:=true;
            exit;

3. , , 1 ( , repeat ... until

? , :

    LastSignalType:=FSignalType;
    toNext:=true;
    if not(FIndicator.PriceSource.NextItem) then

, , :

    repeat
        if not FindSignal then
        begin
           Result:=false;
           exit;
        end;

, ( - , - ):

        if (LastSignalType=enBuy) and (FSignalType=enSell) then
        begin
          Result:=true;
          exit;
        end;
        if (LastSignalType=enSell) and (FSignalType=enBuy) then
        begin
           Result:=true;
           exit;
        end;

, , , ( ):

   until toNext;

, FindSignalRotate TPASSStatAnalizTemplate, , , . , , . , , .

TPASSStatStoreDataList=class(TPASSStatStoreDataTemplate)
protected
   FList:TStrings;
   FCounter:integer;
public
   constructor Create(AList:TStrings);
   procedure AddData(AParameters:TPASSParameters); override;
end;

, . , . , , TPASSStatAnalizMomentum:

constructor TPASSStatStoreDataList.Create(AList:TStrings);
begin
   inherited Create;
   FList:=AList;
   FCounter:=0;
end;

procedure TPASSStatStoreDataList.AddData(AParameters:TPASSParameters);
var s:string; i,cn:integer;
begin
   s:='';
   cn:=AParameters.Count-1;
   for i:=0 to cn do s:=s+AParameters[i].Name+'='+AParameters.AsStringByNum(i)+';';
   FList.Add(s);
   FCounter:=FCounter+1;
end;

AddData TPASSStatStoreDataList . , . . , :

procedure TPASSStatAnalizMomentum.Test;
begin
    FIndicator.PriceSource.CurrentItemIndex:=FIndicator.GetParameterByName('DT')+3;
    inherited Test;
end;
( 17.08.2011 . )
 
« .   . »
 
© 2023 Программирование - это просто
Joomla! - , GNU/GPL.
© 2005-2008 Joom.Ru - Joomla!
Design by Mamboteam.com | Powered by Mambobanner.de
  .