forked from zonquan/TradeStation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsfgf.projectedwave.txt
128 lines (120 loc) · 3.91 KB
/
sfgf.projectedwave.txt
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
[LegacyColorValue = true];
{
Function : sfgf.projectedwave
Description : Find the Projected Wave Pattern
Copyright 2016 Scottfree Gains LLC
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
}
Inputs:
Pivots(NumericSimple),
PM[MaxSize1, MaxSize2](NumericArrayRef),
Strength(NumericSimple),
Pattern[MaxSize3, MaxSize4](NumericArrayRef),
ATRFactor(NumericSimple);
Variables:
PatternPivots(4),
p1(0),
p2(0),
p3(0),
p4(0),
v1(0.0),
v2(0.0),
v3(0.0),
v4(0.0),
p(0.0),
ATR(0.0);
sfgf.projectedwave = 0;
If Pivots >= PatternPivots and Strength >= 1 Then Begin
{Bullish ProWave}
p2 = sfgf.pivothigh(Pivots, PM, 0, Pivots-1, Strength);
p3 = sfgf.pivotlow(Pivots, PM, 0, Pivots-1, Strength);
If p2 >= 0 and p3 >= 0 and
p2 > p3 Then Begin
v2 = High[PM[p2, 0]];
v3 = Low[PM[p3, 0]];
p4 = sfgf.pivothigh(Pivots, PM, 0, p3, 1);
If p4 >= 0 and v3 < v2 Then Begin
v4 = High[PM[p4, 0]];
p1 = sfgf.pivotlow(Pivots, PM, p2+1, Pivots-1, Strength);
If p1 >= 0 and v2 > v4 and v4 > v3 Then Begin
v1 = Low[PM[p1, 0]];
If v1 < v4 and v1 > v3 Then Begin
p = TLValueEasy(Low, PM[p3, 0], PM[p1, 0], -PM[p3, 0]);
ATR = Volatility(PM[p3, 0]);
Condition1 = AbsValue(p - Low) <= ATRFactor * ATR;
Condition2 = Low < Lowest(Low, PM[p1, 0]-1)[1];
Condition3 = Low <= p;
If Condition1 and Condition2 and Condition3 Then Begin
Pattern[1, 0] = PM[p1, 0];
Pattern[1, 1] = PM[p1, 1];
Pattern[1, 2] = PM[p1, 2];
Pattern[1, 3] = PM[p1, 3];
Pattern[2, 0] = PM[p2, 0];
Pattern[2, 1] = PM[p2, 1];
Pattern[2, 2] = PM[p2, 2];
Pattern[2, 3] = PM[p2, 3];
Pattern[3, 0] = PM[p3, 0];
Pattern[3, 1] = PM[p3, 1];
Pattern[3, 2] = PM[p3, 2];
Pattern[3, 3] = PM[p3, 3];
Pattern[4, 0] = PM[p4, 0];
Pattern[4, 1] = PM[p4, 1];
Pattern[4, 2] = PM[p4, 2];
Pattern[4, 3] = PM[p4, 3];
sfgf.projectedwave = PatternPivots;
End;
End;
End;
End;
End;
{Bearish ProWave}
p3 = sfgf.pivothigh(Pivots, PM, 0, Pivots-1, Strength);
p2 = sfgf.pivotlow(Pivots, PM, 0, Pivots-1, Strength);
If p2 >= 0 and p3 >= 0 and
p2 > p3 Then Begin
v3 = High[PM[p3, 0]];
v2 = Low[PM[p2, 0]];
p4 = sfgf.pivotlow(Pivots, PM, 0, p3, 1);
If p4 >= 0 and v3 > v2 Then Begin
v4 = Low[PM[p4, 0]];
p1 = sfgf.pivothigh(Pivots, PM, p2+1, Pivots-1, Strength);
If p1 >= 0 and v2 < v4 and v4 < v3 Then Begin
v1 = High[PM[p1, 0]];
If v1 > v4 and v1 < v3 Then Begin
p = TLValueEasy(High, PM[p3, 0], PM[p1, 0], -PM[p3, 0]);
ATR = Volatility(PM[p3, 0]);
Condition1 = AbsValue(p - High) <= ATRFactor * ATR;
Condition2 = High > Highest(High, PM[p1, 0]-1)[1];
Condition3 = High >= p;
If Condition1 and Condition2 and Condition3 Then Begin
Pattern[1, 0] = PM[p1, 0];
Pattern[1, 1] = PM[p1, 1];
Pattern[1, 2] = PM[p1, 2];
Pattern[1, 3] = PM[p1, 3];
Pattern[2, 0] = PM[p2, 0];
Pattern[2, 1] = PM[p2, 1];
Pattern[2, 2] = PM[p2, 2];
Pattern[2, 3] = PM[p2, 3];
Pattern[3, 0] = PM[p3, 0];
Pattern[3, 1] = PM[p3, 1];
Pattern[3, 2] = PM[p3, 2];
Pattern[3, 3] = PM[p3, 3];
Pattern[4, 0] = PM[p4, 0];
Pattern[4, 1] = PM[p4, 1];
Pattern[4, 2] = PM[p4, 2];
Pattern[4, 3] = PM[p4, 3];
sfgf.projectedwave = -PatternPivots;
End;
End;
End;
End;
End;
End;