4
4
//@version=4
5
5
study(title='[RS]Bar Pattern Statistics Tool', shorttitle='bst', overlay=false)
6
6
7
- // bar type placeholder names:
8
7
string op_type_01 = 'inside bar'
9
8
string op_type_02 = 'outside bar'
10
9
string op_type_03 = 'up bar'
11
10
string op_type_04 = 'down bar'
12
11
string op_type_05 = 'up pin bar'
13
12
string op_type_06 = 'down pin bar'
14
13
string op_type_07 = 'any type of bar'
15
- // bar type enumeration functions:
16
14
f_enum_type(_str)=>(_str==op_type_01?1:(_str==op_type_02?2:(_str==op_type_03?3:(_str==op_type_04?4:(_str==op_type_05?5:(_str==op_type_06?6:(_str==op_type_07?7:na)))))))
17
15
f_enum_type_by_idx(_i)=>(_i==1?op_type_01:(_i==2?op_type_02:(_i==3?op_type_03:(_i==4?op_type_04:(_i==5?op_type_05:(_i==6?op_type_06:(_i==7?op_type_07:op_type_07)))))))
18
- //
19
- // current bar information:
20
16
float body_range = abs(close - open)
21
17
float hl_range = high - low
22
18
float upperwick = high - max(close, open)
@@ -25,8 +21,7 @@ bool risinghigh = high > high[1]
25
21
bool fallinghigh = high < high[1]
26
22
bool risinglow = low > low[1]
27
23
bool fallinglow = low < low[1]
28
- //
29
- // bar type information at position:
24
+
30
25
f_isHighUp(_pos) => risinghigh[_pos]
31
26
f_isHighDown(_pos) => fallinghigh[_pos]
32
27
f_isLowUp(_pos) => risinglow[_pos]
@@ -58,16 +53,16 @@ string bar09_type = input(defval=op_type_01, title='#9 in pattern:', type=input.
58
53
string bar10_type = input(defval=op_type_01, title='#10 in pattern:', type=input.string, options=[op_type_01, op_type_02, op_type_03, op_type_04, op_type_05, op_type_06, op_type_07])
59
54
60
55
if automatic_last_n_bars
61
- bar01_type := f_enum_type_by_idx(f_ident_bar(max(0, n_bars_in_pattern-0 )))
62
- bar02_type := f_enum_type_by_idx(f_ident_bar(max(0, n_bars_in_pattern-1 )))
63
- bar03_type := f_enum_type_by_idx(f_ident_bar(max(0, n_bars_in_pattern-2 )))
64
- bar04_type := f_enum_type_by_idx(f_ident_bar(max(0, n_bars_in_pattern-3 )))
65
- bar05_type := f_enum_type_by_idx(f_ident_bar(max(0, n_bars_in_pattern-4 )))
66
- bar06_type := f_enum_type_by_idx(f_ident_bar(max(0, n_bars_in_pattern-5 )))
67
- bar07_type := f_enum_type_by_idx(f_ident_bar(max(0, n_bars_in_pattern-6 )))
68
- bar08_type := f_enum_type_by_idx(f_ident_bar(max(0, n_bars_in_pattern-7 )))
69
- bar09_type := f_enum_type_by_idx(f_ident_bar(max(0, n_bars_in_pattern-8 )))
70
- bar10_type := f_enum_type_by_idx(f_ident_bar(max(0, n_bars_in_pattern-9 )))
56
+ bar01_type := f_enum_type_by_idx(f_ident_bar(max(0, n_bars_in_pattern-1 )))
57
+ bar02_type := f_enum_type_by_idx(f_ident_bar(max(0, n_bars_in_pattern-2 )))
58
+ bar03_type := f_enum_type_by_idx(f_ident_bar(max(0, n_bars_in_pattern-3 )))
59
+ bar04_type := f_enum_type_by_idx(f_ident_bar(max(0, n_bars_in_pattern-4 )))
60
+ bar05_type := f_enum_type_by_idx(f_ident_bar(max(0, n_bars_in_pattern-5 )))
61
+ bar06_type := f_enum_type_by_idx(f_ident_bar(max(0, n_bars_in_pattern-6 )))
62
+ bar07_type := f_enum_type_by_idx(f_ident_bar(max(0, n_bars_in_pattern-7 )))
63
+ bar08_type := f_enum_type_by_idx(f_ident_bar(max(0, n_bars_in_pattern-8 )))
64
+ bar09_type := f_enum_type_by_idx(f_ident_bar(max(0, n_bars_in_pattern-9 )))
65
+ bar10_type := f_enum_type_by_idx(f_ident_bar(max(0, n_bars_in_pattern-10 )))
71
66
72
67
f_get_nbar_type(_i)=>(_i==1?bar01_type:(_i==2?bar02_type:(_i==3?bar03_type:(_i==4?bar04_type:(_i==5?bar05_type:(_i==6?bar06_type:(_i==7?bar07_type:(_i==8?bar08_type:(_i==9?bar09_type:(_i==10?bar10_type:na))))))))))
73
68
f_check_nbar(_i, _pos)=>f_enum_BarPattern(f_enum_type(f_get_nbar_type(_i)), _pos)
0 commit comments