Speedometer
Speedometer
Speedometer
//@version=4
study("RSI Speedometer ", overlay=false)
// ---------------------------------------------------------------
// ---------------- Required inputs and variables ----------------
x_axis = array.new_int(radius * 2, 0)
for i = offset to offset + 2 * radius - 1
array.set(x_axis, i - offset, time[i])
one_bar = int(change(time))
right_side = array.get(x_axis, 0)
left_side = array.get(x_axis, 2 * radius - 1)
x_center = array.get(x_axis, radius - 1)
// ---------------------------------------------------------------
// ---------------------------------------------------------------
// -------------------- Speedometer functions --------------------
// ---------------------------------------------------------------
// ---------------------------------------------------------------
// ---------------------------------------------------------------
// --------------- End of Speedometer Functions ------------------
// ---------------------------------------------------------------
// ---------------------------------------------------------------
// Plot each sector and it's "glow"
f_draw_sector(1, 5, 20, radius, y_axis, y_scale, color.red, 5)
f_draw_sector(1, 5, 20, radius, y_axis, y_scale, color.white, 1)
// Minor ticks
f_draw_tick(1, 10, 6, x_center, radius, y_axis, y_scale, color.white, 1)
f_draw_tick(3, 10, 6, x_center, radius, y_axis, y_scale, color.white, 1)
f_draw_tick(5, 10, 6, x_center, radius, y_axis, y_scale, color.white, 1)
f_draw_tick(7, 10, 6, x_center, radius, y_axis, y_scale, color.white, 1)
f_draw_tick(9, 10, 6, x_center, radius, y_axis, y_scale, color.white, 1)
// ---------------------------------------------------------------
plot(metric)
hline(100), hline(0)
// Add some buffer around the RSI plot to give enough space for the labels to be
seeen
hline(y_scale * 1.2, color=#00000000)
hline(y_axis - y_scale * 0.2, color=#00000000)