Skip to content

Commit 070ae23

Browse files
update
1 parent 392e548 commit 070ae23

File tree

2 files changed

+39
-31
lines changed

2 files changed

+39
-31
lines changed

[RS]Bar Pattern Statistics Tool.pinescript

+16-14
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,20 @@ string op_type_03 = 'up bar'
1212
string op_type_04 = 'down bar'
1313
string op_type_05 = 'up pin bar'
1414
string op_type_06 = 'down pin bar'
15-
16-
string bar01_type = input(defval=op_type_01, title='#1 in pattern:', type=input.string, options=[op_type_01, op_type_02, op_type_03, op_type_04, op_type_05, op_type_06])
17-
string bar02_type = input(defval=op_type_01, title='#2 in pattern:', type=input.string, options=[op_type_01, op_type_02, op_type_03, op_type_04, op_type_05, op_type_06])
18-
string bar03_type = input(defval=op_type_01, title='#3 in pattern:', type=input.string, options=[op_type_01, op_type_02, op_type_03, op_type_04, op_type_05, op_type_06])
19-
string bar04_type = input(defval=op_type_01, title='#4 in pattern:', type=input.string, options=[op_type_01, op_type_02, op_type_03, op_type_04, op_type_05, op_type_06])
20-
string bar05_type = input(defval=op_type_01, title='#5 in pattern:', type=input.string, options=[op_type_01, op_type_02, op_type_03, op_type_04, op_type_05, op_type_06])
21-
string bar06_type = input(defval=op_type_01, title='#6 in pattern:', type=input.string, options=[op_type_01, op_type_02, op_type_03, op_type_04, op_type_05, op_type_06])
22-
string bar07_type = input(defval=op_type_01, title='#7 in pattern:', type=input.string, options=[op_type_01, op_type_02, op_type_03, op_type_04, op_type_05, op_type_06])
23-
string bar08_type = input(defval=op_type_01, title='#8 in pattern:', type=input.string, options=[op_type_01, op_type_02, op_type_03, op_type_04, op_type_05, op_type_06])
24-
string bar09_type = input(defval=op_type_01, title='#9 in pattern:', type=input.string, options=[op_type_01, op_type_02, op_type_03, op_type_04, op_type_05, op_type_06])
25-
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])
26-
27-
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:na))))))
15+
string op_type_07 = 'any type of bar'
16+
17+
string bar01_type = input(defval=op_type_01, title='#1 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])
18+
string bar02_type = input(defval=op_type_01, title='#2 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])
19+
string bar03_type = input(defval=op_type_01, title='#3 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])
20+
string bar04_type = input(defval=op_type_01, title='#4 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])
21+
string bar05_type = input(defval=op_type_01, title='#5 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])
22+
string bar06_type = input(defval=op_type_01, title='#6 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])
23+
string bar07_type = input(defval=op_type_01, title='#7 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])
24+
string bar08_type = input(defval=op_type_01, title='#8 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])
25+
string bar09_type = input(defval=op_type_01, title='#9 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])
26+
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])
27+
28+
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)))))))
2829
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))))))))))
2930

3031
f_get_pattern_as_text()=>
@@ -55,8 +56,9 @@ f_isUpBar(_pos) => f_isHighUp(_pos) and f_isLowUp(_pos)
5556
f_isDownBar(_pos) => f_isHighDown(_pos) and f_isLowDown(_pos)
5657
f_isPinUp(_pos) => risinghigh[_pos] and body_range[_pos] < (hl_range[_pos] * 0.33) and (upperwick[_pos] * 0.66) > lowerwick[_pos]
5758
f_isPinDown(_pos) => fallinglow[_pos] and body_range[_pos] < (hl_range[_pos] * 0.33) and (lowerwick[_pos] * 0.66) > upperwick[_pos]
59+
f_isAny(_pos) => true
5860

59-
f_enum_BarPattern(_i, _pos)=>(_i==1?f_isInsideBar(_pos):(_i==2?f_isOutsideBar(_pos):(_i==3?f_isUpBar(_pos):(_i==4?f_isDownBar(_pos):(_i==5?f_isPinUp(_pos):(_i==6?f_isPinDown(_pos):na))))))
61+
f_enum_BarPattern(_i, _pos)=>(_i==1?f_isInsideBar(_pos):(_i==2?f_isOutsideBar(_pos):(_i==3?f_isUpBar(_pos):(_i==4?f_isDownBar(_pos):(_i==5?f_isPinUp(_pos):(_i==6?f_isPinDown(_pos):(_i==7?f_isAny(_pos):na)))))))
6062

6163
f_check_nbar(_i, _pos)=>f_enum_BarPattern(f_enum_type(f_get_nbar_type(_i)), _pos)
6264

[RS]MTF Candlesticks.pinescript

+23-17
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ f_tfResInMinutes(_resolution) =>
2020
// _resolution: resolution of any TF (in "timeframe.period" string format).
2121
security(syminfo.tickerid, _resolution, f_resInMinutes())
2222

23+
// Returns a time formated text string of the elapsed time remaining until
24+
// specified timeframe closes:
2325
f_countdown_to_close_text(_tf)=>
2426
int _open_date = valuewhen(change(time(_tf)) != 0, time, 0)
2527
int _close_date = _open_date + round(f_tfResInMinutes(_tf)) * 60000
@@ -33,7 +35,10 @@ f_countdown_to_close_text(_tf)=>
3335
string _countdown = (_month >= 1 ? tostring(_month, " #M ") : "") + (_weeks >= 1 ? tostring(_weeks, " #W ") : "") + (_days >= 1 ? tostring(_days, " #D ") : "") + (_hours >= 0 ? (_hours < 10 ? "0" : "") + tostring(_hours, "#") : "00") + (_minutes >= 0 ? (_minutes < 10 ? "0" : "") + tostring(_minutes, ":# ") : ":00")
3436
_countdown
3537

38+
//------------------------------------------------------------------------------
39+
// inputs:
3640
int n_of_candlesticks = input(defval=5, minval=0, maxval=5)
41+
int n_of_candlesticks_per_tf = input(defval=5, minval=0, maxval=5)
3742
string tf1 = input(defval="60")
3843
string tf2 = input(defval="240")
3944
string tf3 = input(defval="D")
@@ -43,25 +48,26 @@ string tf5 = input(defval="M")
4348
bool show_labels = input(false)
4449
bool show_sr = input(false)
4550

46-
int spacing = input(5)
47-
int tdispl = round((time[0] - time[10]) / 10) * spacing
51+
int spacing = input(4)
52+
int tdispl = round(f_resInMinutes()) * 60000 * spacing
4853

4954
bool bm = barmerge.lookahead_on
5055
bool gp = barmerge.gaps_off
5156

52-
f_security(_tf, _display)=>
57+
f_security(_tf, _pos, _display)=>
5358
bool _bm = barmerge.lookahead_on
5459
bool _gp = barmerge.gaps_off
55-
float _open = not _display ? 0.0 : security(syminfo.tickerid, _tf, open, _gp, _bm)
56-
float _high = not _display ? 0.0 : security(syminfo.tickerid, _tf, high, _gp, _bm)
57-
float _low = not _display ? 0.0 : security(syminfo.tickerid, _tf, low, _gp, _bm)
58-
[_open, _high, _low]
60+
float _open = not _display ? 0.0 : security(syminfo.tickerid, _tf, open[_pos], _gp, _bm)
61+
float _high = not _display ? 0.0 : security(syminfo.tickerid, _tf, high[_pos], _gp, _bm)
62+
float _low = not _display ? 0.0 : security(syminfo.tickerid, _tf, low[_pos], _gp, _bm)
63+
float _close = not _display ? 0.0 : security(syminfo.tickerid, _tf, close[_pos], _gp, _bm)
64+
[_open, _high, _low, _close]
5965

60-
[tf1_open, tf1_high, tf1_low] = f_security(tf1, n_of_candlesticks >= 1)
61-
[tf2_open, tf2_high, tf2_low] = f_security(tf2, n_of_candlesticks >= 2)
62-
[tf3_open, tf3_high, tf3_low] = f_security(tf3, n_of_candlesticks >= 3)
63-
[tf4_open, tf4_high, tf4_low] = f_security(tf4, n_of_candlesticks >= 4)
64-
[tf5_open, tf5_high, tf5_low] = f_security(tf5, n_of_candlesticks >= 5)
66+
[tf1_open, tf1_high, tf1_low, tf1_close] = f_security(tf1, 0, n_of_candlesticks >= 1)
67+
[tf2_open, tf2_high, tf2_low, tf2_close] = f_security(tf2, 0, n_of_candlesticks >= 2)
68+
[tf3_open, tf3_high, tf3_low, tf3_close] = f_security(tf3, 0, n_of_candlesticks >= 3)
69+
[tf4_open, tf4_high, tf4_low, tf4_close] = f_security(tf4, 0, n_of_candlesticks >= 4)
70+
[tf5_open, tf5_high, tf5_low, tf5_close] = f_security(tf5, 0, n_of_candlesticks >= 5)
6571

6672
labelpos = max(tf1_high, max(tf2_high, max(tf3_high, max(tf4_high, tf5_high))))
6773

@@ -116,13 +122,13 @@ f_draw_candle(_o, _h, _l, _c, _x, _label, _label_pos)=>
116122
)
117123

118124
if n_of_candlesticks >= 1
119-
f_draw_candle(tf1_open, tf1_high, tf1_low, close, time + tdispl * 1, tf1, labelpos)
125+
f_draw_candle(tf1_open, tf1_high, tf1_low, tf1_close, time + tdispl * 1, tf1, labelpos)
120126
if n_of_candlesticks >= 2
121-
f_draw_candle(tf2_open, tf2_high, tf2_low, close, time + tdispl * 2, tf2, labelpos)
127+
f_draw_candle(tf2_open, tf2_high, tf2_low, tf2_close, time + tdispl * 2, tf2, labelpos)
122128
if n_of_candlesticks >= 3
123-
f_draw_candle(tf3_open, tf3_high, tf3_low, close, time + tdispl * 3, tf3, labelpos)
129+
f_draw_candle(tf3_open, tf3_high, tf3_low, tf3_close, time + tdispl * 3, tf3, labelpos)
124130
if n_of_candlesticks >= 4
125-
f_draw_candle(tf4_open, tf4_high, tf4_low, close, time + tdispl * 4, tf4, labelpos)
131+
f_draw_candle(tf4_open, tf4_high, tf4_low, tf4_close, time + tdispl * 4, tf4, labelpos)
126132
if n_of_candlesticks >= 5
127-
f_draw_candle(tf5_open, tf5_high, tf5_low, close, time + tdispl * 5, tf5, labelpos)
133+
f_draw_candle(tf5_open, tf5_high, tf5_low, tf5_close, time + tdispl * 5, tf5, labelpos)
128134

0 commit comments

Comments
 (0)