Sample SMA strategy
This commit is contained in:
@@ -35,6 +35,9 @@ type
|
||||
function VisitAssignment(const Node: IAssignmentNode): TAstValue;
|
||||
function VisitIndexer(const Node: IIndexerNode): TAstValue;
|
||||
function VisitMemberAccess(const Node: IMemberAccessNode): TAstValue;
|
||||
function VisitCreateSeries(const Node: ICreateSeriesNode): TAstValue;
|
||||
function VisitAddSeriesItem(const Node: IAddSeriesItemNode): TAstValue;
|
||||
function VisitSeriesLength(const Node: ISeriesLengthNode): TAstValue;
|
||||
end;
|
||||
|
||||
implementation
|
||||
@@ -123,10 +126,13 @@ begin
|
||||
Indent;
|
||||
Node.ThenBranch.Accept(Self);
|
||||
Unindent;
|
||||
AppendLine('Else:');
|
||||
Indent;
|
||||
Node.ElseBranch.Accept(Self);
|
||||
Unindent;
|
||||
if Node.ElseBranch <> nil then
|
||||
begin
|
||||
AppendLine('Else:');
|
||||
Indent;
|
||||
Node.ElseBranch.Accept(Self);
|
||||
Unindent;
|
||||
end;
|
||||
Unindent;
|
||||
Result := TAstValue.Void;
|
||||
end;
|
||||
@@ -255,4 +261,45 @@ begin
|
||||
Result := TAstValue.Void;
|
||||
end;
|
||||
|
||||
function TPrettyPrintVisitor.VisitCreateSeries(const Node: ICreateSeriesNode): TAstValue;
|
||||
begin
|
||||
AppendLine('CreateSeries');
|
||||
Indent;
|
||||
AppendLine('Definition: ' + Node.Definition);
|
||||
Unindent;
|
||||
Result := TAstValue.Void;
|
||||
end;
|
||||
|
||||
function TPrettyPrintVisitor.VisitAddSeriesItem(const Node: IAddSeriesItemNode): TAstValue;
|
||||
begin
|
||||
AppendLine('AddSeriesItem');
|
||||
Indent;
|
||||
AppendLine('Series:');
|
||||
Indent;
|
||||
Node.Series.Accept(Self);
|
||||
Unindent;
|
||||
AppendLine('Value:');
|
||||
Indent;
|
||||
Node.Value.Accept(Self);
|
||||
Unindent;
|
||||
if Assigned(Node.Lookback) then
|
||||
begin
|
||||
AppendLine('Lookback:');
|
||||
Indent;
|
||||
Node.Lookback.Accept(Self);
|
||||
Unindent;
|
||||
end;
|
||||
Unindent;
|
||||
Result := TAstValue.Void;
|
||||
end;
|
||||
|
||||
function TPrettyPrintVisitor.VisitSeriesLength(const Node: ISeriesLengthNode): TAstValue;
|
||||
var
|
||||
seriesStr: string;
|
||||
begin
|
||||
// Get the string representation of the series identifier by visiting the node.
|
||||
seriesStr := Node.Series.Accept(Self).ToString;
|
||||
Result := TAstValue.FromText(Format('length(%s)', [seriesStr]));
|
||||
end;
|
||||
|
||||
end.
|
||||
|
||||
Reference in New Issue
Block a user