{**********************************************}
{   TSARFunction                               }
{   Financial indicator Stop and Reversal      }
{   Copyright (c) 2006-2020 by Steema Software }
{**********************************************}
unit TeeSAR;
{$I TeeDefs.inc}

interface

uses
  {$IFNDEF LINUX}
  Windows, Messages,
  {$ENDIF}
  SysUtils, Classes,

  Graphics, Controls, Forms, Dialogs, StdCtrls, ComCtrls,

  TeeProcs, TeEngine, OHLChart, Chart, TeeBaseFuncEdit, ExtCtrls;

type
  TSARFuncEditor = class(TBaseFunctionEditor)
    Label1: TLabel;
    Label2: TLabel;
    EAccel: TEdit;
    EMaxStep: TEdit;
    procedure EAccelChange(Sender: TObject);
    procedure EMaxStepChange(Sender: TObject);
  private
    { Private declarations }
  protected
    procedure ApplyFormChanges; override;
    Procedure SetFunction; override;
  public
    { Public declarations }
  end;

implementation

{$IFNDEF LCL}
{$R *.DFM}
{$ELSE}
{$R *.lfm}
{$ENDIF}

uses
  TeeProCo;

{ TSARFuncEditor }
procedure TSARFuncEditor.ApplyFormChanges;
begin
  inherited;

  with TSARFunction(IFunction) do
  begin
    BeginUpdate;
    try
      AccelerationFactor:=StrToFloatDef(EAccel.Text,AccelerationFactor);
      MaxStep:=StrToFloatDef(EMaxStep.Text,MaxStep);
    finally
      EndUpdate;
    end;
  end;
end;

procedure TSARFuncEditor.SetFunction;
begin
  inherited;

  with TSARFunction(IFunction) do
  begin
    EAccel.Text:=FloatToStr(AccelerationFactor);
    EMaxStep.Text:=FloatToStr(MaxStep);
  end;
end;

procedure TSARFuncEditor.EAccelChange(Sender: TObject);
begin
  EnableApply;
end;

procedure TSARFuncEditor.EMaxStepChange(Sender: TObject);
begin
  EnableApply;
end;

initialization
  RegisterClass(TSARFuncEditor);
end.
