@@ -20,6 +20,8 @@ f_tfResInMinutes(_resolution) =>
20
20
// _resolution: resolution of any TF (in "timeframe.period" string format).
21
21
security(syminfo.tickerid, _resolution, f_resInMinutes())
22
22
23
+ // Returns a time formated text string of the elapsed time remaining until
24
+ // specified timeframe closes:
23
25
f_countdown_to_close_text(_tf)=>
24
26
int _open_date = valuewhen(change(time(_tf)) != 0, time, 0)
25
27
int _close_date = _open_date + round(f_tfResInMinutes(_tf)) * 60000
@@ -33,7 +35,10 @@ f_countdown_to_close_text(_tf)=>
33
35
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")
34
36
_countdown
35
37
38
+ //------------------------------------------------------------------------------
39
+ // inputs:
36
40
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)
37
42
string tf1 = input(defval="60")
38
43
string tf2 = input(defval="240")
39
44
string tf3 = input(defval="D")
@@ -43,25 +48,26 @@ string tf5 = input(defval="M")
43
48
bool show_labels = input(false)
44
49
bool show_sr = input(false)
45
50
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
48
53
49
54
bool bm = barmerge.lookahead_on
50
55
bool gp = barmerge.gaps_off
51
56
52
- f_security(_tf, _display)=>
57
+ f_security(_tf, _pos, _display)=>
53
58
bool _bm = barmerge.lookahead_on
54
59
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]
59
65
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)
65
71
66
72
labelpos = max(tf1_high, max(tf2_high, max(tf3_high, max(tf4_high, tf5_high))))
67
73
@@ -116,13 +122,13 @@ f_draw_candle(_o, _h, _l, _c, _x, _label, _label_pos)=>
116
122
)
117
123
118
124
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)
120
126
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)
122
128
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)
124
130
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)
126
132
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)
128
134
0 commit comments