-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIntrabarOpenCloseGap.pine
More file actions
24 lines (21 loc) · 1.04 KB
/
Copy pathIntrabarOpenCloseGap.pine
File metadata and controls
24 lines (21 loc) · 1.04 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
// MIT License
// © Yuri Lopukhov
// Just checking one idea: look at gaps between close and open bars on lower timeframe
// to try to estimate how much slippage exists there that may be a result of buying or selling pressure.
// Perhaps it only useful in real time to see if situation of the current bar is changing.
// Open to ideas and suggestions
// v. 0.1 - initial version
//@version=6
indicator("Intra-bar Close/Open Gap [YuL]", overlay = false)
tf = input.timeframe("1", "Intra-bar timeframe, should be lower than current")
close_prices = request.security_lower_tf(syminfo.tickerid, tf, close)
open_prices = request.security_lower_tf(syminfo.tickerid, tf, open)
gaps = array.new_float()
if close_prices.size() > 0
for i = 0 to close_prices.size() - 2
gaps.push(open_prices.get(i+1) - close_prices.get(i))
avg_gap = gaps.avg()
plot_color = avg_gap > 0 ? color.green : color.red
avg_gap_plot = plot(avg_gap, color=plot_color)
zero_line_plot = plot(0, color=plot_color, display = display.pane)
fill(avg_gap_plot, zero_line_plot, color=plot_color)