New Test-Startegy
This commit is contained in:
+57
-41
@@ -52,7 +52,8 @@ uses
|
||||
DynamicFMXControl,
|
||||
Myc.FMX.Chart,
|
||||
Myc.Trade.Indicators,
|
||||
Myc.DataRecord;
|
||||
Myc.DataRecord,
|
||||
StrategyTest;
|
||||
|
||||
type
|
||||
TForm1 = class(TForm)
|
||||
@@ -117,16 +118,6 @@ type
|
||||
property OnEvent: TNotifyEvent read FOnEvent write FOnEvent;
|
||||
end;
|
||||
|
||||
TEquitySum = class(TMycConverter<Double, Double>)
|
||||
private
|
||||
FEquity: Double;
|
||||
FInit: Boolean;
|
||||
protected
|
||||
function ProcessData(const Value: Double): TState; override;
|
||||
public
|
||||
constructor Create(AEquity: Double);
|
||||
end;
|
||||
|
||||
var
|
||||
Form1: TForm1;
|
||||
|
||||
@@ -426,7 +417,28 @@ begin
|
||||
|
||||
var pnl := Signal.Field<Double>('pnl');
|
||||
|
||||
var equity: TConverter<Double, Double> := TEquitySum.Create(10000);
|
||||
var FEquity: Double;
|
||||
var FInit: Boolean;
|
||||
|
||||
var equity :=
|
||||
TConverter<Double, Double>.CreateAggregation(
|
||||
function(const Value: Double; const Broadcast: TConverter<Double, Double>.TBroadcastProc): TState
|
||||
begin
|
||||
if not FInit then
|
||||
begin
|
||||
FInit := true;
|
||||
Broadcast(FEquity);
|
||||
end;
|
||||
|
||||
if not IsNan(Value) then
|
||||
begin
|
||||
FEquity := FEquity + Value;
|
||||
Result := Broadcast(FEquity);
|
||||
end;
|
||||
end
|
||||
);
|
||||
|
||||
// var equity: TConverter<Double, Double> := TEquitySum.Create(10000);
|
||||
pnl.Sender.Link(equity);
|
||||
|
||||
var Layout := CurrLayout<TVertScrollBox>;
|
||||
@@ -635,7 +647,27 @@ begin
|
||||
|
||||
var pnl := Signal.Field<Double>('pnl');
|
||||
|
||||
var equity: TConverter<Double, Double> := TEquitySum.Create(10000);
|
||||
var FEquity: Double := 10000;
|
||||
var FInit: Boolean := false;
|
||||
|
||||
var equity :=
|
||||
TConverter<Double, Double>.CreateAggregation(
|
||||
function(const Value: Double; const Broadcast: TConverter<Double, Double>.TBroadcastProc): TState
|
||||
begin
|
||||
if not FInit then
|
||||
begin
|
||||
FInit := true;
|
||||
Broadcast(FEquity);
|
||||
end;
|
||||
|
||||
if not IsNan(Value) then
|
||||
begin
|
||||
FEquity := FEquity + Value;
|
||||
Result := Broadcast(FEquity);
|
||||
end;
|
||||
end
|
||||
);
|
||||
|
||||
pnl.Sender.Link(equity);
|
||||
|
||||
var Layout := CurrLayout<TVertScrollBox>;
|
||||
@@ -867,38 +899,22 @@ begin
|
||||
var timeframe := TTimeframe.M15;
|
||||
ExecuteStrategy(Symbol, timeframe, CreateStrategy2(timeframe));
|
||||
|
||||
// timeframe := M5;
|
||||
// ExecuteStrategy(Symbol, timeframe, CreateStrategy2(timeframe));
|
||||
// timeframe := H4;
|
||||
// ExecuteStrategy(Symbol, timeframe, CreateStrategy2(timeframe));
|
||||
// timeframe := D;
|
||||
// ExecuteStrategy(Symbol, timeframe, CreateStrategy2(timeframe));
|
||||
// timeframe := M;
|
||||
// ExecuteStrategy(Symbol, timeframe, CreateStrategy2(timeframe));
|
||||
end;
|
||||
var tstStrat := StrategyTest.CreateStrategy1(timeframe);
|
||||
ExecuteStrategy(Symbol, timeframe, tstStrat);
|
||||
|
||||
{ TEquitySum<S, T> }
|
||||
var Layout := CurrLayout<TVertScrollBox>;
|
||||
if Layout = nil then
|
||||
exit;
|
||||
|
||||
constructor TEquitySum.Create(AEquity: Double);
|
||||
begin
|
||||
inherited Create;
|
||||
FEquity := AEquity;
|
||||
FInit := false;
|
||||
end;
|
||||
var pnlChart := TMycChart.Create(Self);
|
||||
AlignControl(pnlChart);
|
||||
pnlChart.Height := Layout.ChildrenRect.Width * 9 / 24;
|
||||
pnlChart.Lookback.Value := 50000;
|
||||
|
||||
function TEquitySum.ProcessData(const Value: Double): TState;
|
||||
begin
|
||||
if not FInit then
|
||||
begin
|
||||
FInit := true;
|
||||
Broadcast(FEquity);
|
||||
end;
|
||||
pnlChart.SetXAxisCounter<Double>(tstStrat.Sender);
|
||||
|
||||
if not IsNan(Value) then
|
||||
begin
|
||||
FEquity := FEquity + Value;
|
||||
Result := Broadcast(FEquity);
|
||||
end;
|
||||
var panel := pnlChart.AddPanel;
|
||||
panel.AddDoubleSeries(tstStrat.Sender, TAlphaColors.Blue, 3);
|
||||
end;
|
||||
|
||||
end.
|
||||
|
||||
Reference in New Issue
Block a user