-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathkantu_pricepattern.pas
More file actions
158 lines (114 loc) · 4.93 KB
/
kantu_pricepattern.pas
File metadata and controls
158 lines (114 loc) · 4.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
unit kantu_pricepattern;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls, kantu_definitions, kantu_simulation;
type
{ TPricePatternForm }
TPricePatternForm = class(TForm)
Button1: TButton;
Memo1: TMemo;
procedure Button1Click(Sender: TObject);
private
{ private declarations }
public
{ public declarations }
procedure decomposeIndicatorPattern(indicatorPattern: TIndicatorPattern; patternType: integer);
end;
var
PricePatternForm: TPricePatternForm;
implementation
uses kantu_main;
{$R *.lfm}
{ TPricePatternForm }
procedure TPricePatternForm.decomposeIndicatorPattern(indicatorPattern: TIndicatorPattern; patternType: integer);
var
i,j : integer;
firstIndicator, secondIndicator, firstShift, secondShift: string;
logicType: integer;
firstIndicatorSell, secondIndicatorSell: integer;
typeString1, typeString2: string;
logicToken: string;
begin
if (patternType = ENTRY_PATTERN) then
begin
Memo1.Lines.Add('---- Entry Pattern Decomposition ----');
Memo1.Lines.Add('*************************************');
if (SimulationForm.useSLCheck.Checked) then
Memo1.Lines.Add('Price pattern SL = ' + FloatToStr(indicatorPattern.SL));
if (SimulationForm.useTPCheck.Checked) then
Memo1.Lines.Add('Price pattern TP = ' + FloatToStr(indicatorPattern.TP));
if (SimulationForm.UseHourFilter.Checked) then
Memo1.Lines.Add('Trade only on hour = ' + FloatToStr(indicatorPattern.hourFilter));
if (SimulationForm.UseDayFilter.Checked) then
Memo1.Lines.Add('Trade only on day = ' + FloatToStr(indicatorPattern.dayFilter));
end;
Memo1.Lines.Add('------------------------------------');
Case patternType of
EXIT_PATTERN : Memo1.Lines.Add('Short Exit rules');
ENTRY_PATTERN : Memo1.Lines.Add('Long entry rules');
end;
for i:= 0 to Length(indicatorPattern.tradingRules)-1 do
begin
firstIndicator := FloatToStr(indicatorPattern.tradingRules[i][IDX_FIRST_INDICATOR]);
secondIndicator := FloatToStr(indicatorPattern.tradingRules[i][IDX_SECOND_INDICATOR]);
firstShift := FloatToStr(indicatorPattern.tradingRules[i][IDX_FIRST_INDICATOR_SHIFT]+1);
secondShift := FloatToStr(indicatorPattern.tradingRules[i][IDX_SECOND_INDICATOR_SHIFT]+1);
Case indicatorPattern.tradingRules[i][IDX_FIRST_INDICATOR] of
0 : typeString1 := 'Open';
1 : typeString1 := 'High';
2 : typeString1 := 'Low';
3 : typeString1 := 'Close';
end;
Case indicatorPattern.tradingRules[i][IDX_SECOND_INDICATOR] of
0 : typeString2 := 'Open';
1 : typeString2 := 'High';
2 : typeString2 := 'Low';
3 : typeString2 := 'Close';
end;
logicToken := 'AND ' ;
Memo1.Lines.Add(logicToken + typeString1 +'[' + firstShift + ']' + ' > ' + typeString2 +'[' + secondShift + ']');
end;
Memo1.Lines.Add('------------------------------------');
Case patternType of
EXIT_PATTERN : Memo1.Lines.Add('Long Exit rules');
ENTRY_PATTERN : Memo1.Lines.Add('Short entry rules');
end;
for i:= 0 to Length(indicatorPattern.tradingRules)-1 do
begin
firstIndicator := FloatToStr(indicatorPattern.tradingRules[i][IDX_FIRST_INDICATOR]);
secondIndicator := FloatToStr(indicatorPattern.tradingRules[i][IDX_SECOND_INDICATOR]);
firstShift := FloatToStr(indicatorPattern.tradingRules[i][IDX_FIRST_INDICATOR_SHIFT]+1);
secondShift := FloatToStr(indicatorPattern.tradingRules[i][IDX_SECOND_INDICATOR_SHIFT]+1);
Case indicatorPattern.tradingRules[i][IDX_FIRST_INDICATOR] of
0 : typeString1 := 'Open';
1 : typeString1 := 'Low';
2 : typeString1 := 'High';
3 : typeString1 := 'Close';
4 : typeString1 := 'Body';
5 : typeString1 := 'Range';
else typeString1 := 'Input'+ IntToStr(StrToInt(firstIndicator)-2);
end;
Case indicatorPattern.tradingRules[i][IDX_SECOND_INDICATOR] of
0 : typeString2 := 'Open';
1 : typeString2 := 'Low';
2 : typeString2 := 'High';
3 : typeString2 := 'Close';
4 : typeString2 := 'Body';
5 : typeString2 := 'Range';
else typeString2 := 'Input'+ IntToStr(StrToInt(secondIndicator)-2);
end;
logicToken := 'AND ' ;
if (indicatorPattern.tradingRules[i][IDX_FIRST_INDICATOR] <> 4) and (indicatorPattern.tradingRules[i][IDX_FIRST_INDICATOR] <> 5) then
Memo1.Lines.Add(logicToken + typeString1 +'[' + firstShift + ']' + ' < ' + typeString2 +'[' + secondShift + ']') else
Memo1.Lines.Add(logicToken + typeString1 +'[' + firstShift + ']' + ' > ' + typeString2 +'[' + secondShift + ']')
end;
Memo1.Lines.Add('------------------------------------');
Memo1.Lines.Add('************************************');
Memo1.Lines.Add(' ');
end;
procedure TPricePatternForm.Button1Click(Sender: TObject);
begin
PricePatternForm.Visible := false;
end;
end.