Symbol Exchange time Syncing to indicator
Posted: Fri Feb 19, 2021 11:25 am
Good afternoon all,
I have been working on the below script on crypto currencies to see how market opening times could affect price action.
I would like to take it a step further and enable its use on non crypto currencies. But the issue I have is that the alignment changes depending on the symbols timezone.
So for example the below aligns as to my idea for BTCUSD but GBPNZD (which is UTC-5) the alignment is off.
Has anyone coded this before?
I have been working on the below script on crypto currencies to see how market opening times could affect price action.
I would like to take it a step further and enable its use on non crypto currencies. But the issue I have is that the alignment changes depending on the symbols timezone.
So for example the below aligns as to my idea for BTCUSD but GBPNZD (which is UTC-5) the alignment is off.
Has anyone coded this before?
Code: Select all
//@version=4
study("Initial Balance Markets Time Zones", overlay=true)
// User adjustment inputs
offset_val = input(title="Label Offset", type=input.integer, defval=20)
backcolor = input(false, title="Optional background colour Price Action (PA) above or below all IB highs/lows")
// Asia Start
time_int_01 = input("0000-0100:1234567", "Asia", input.session)
in_time_int_01 = time(timeframe.period, time_int_01)
var highe_01 = 0.0
var lowe_01 = 10e10
if in_time_int_01
if not in_time_int_01[1]
highe_01 := high
lowe_01 := low
else
highe_01 := max(high, highe_01)
lowe_01 := min(low, lowe_01)
plot(not in_time_int_01 ? highe_01 : na, title="Asia High", color=color.purple, linewidth=2, style=plot.style_linebr)
plotshape(not in_time_int_01 ? highe_01 : na, style=shape.labelup, location=location.absolute, color=color.purple, textcolor=color.white, show_last=1, text="Asia/UTC High", offset = offset_val, transp=20, title="Asia/UTC High")
plot(not in_time_int_01 ? lowe_01 : na, title="Asia Low", color=color.purple, linewidth=2, style=plot.style_linebr)
plotshape(not in_time_int_01 ? lowe_01 : na, style=shape.labeldown, location=location.absolute, color=color.purple, textcolor=color.white, show_last=1, text="Asia/UTC Low", offset = offset_val, transp=20, title="Asia/UTC Low")
// Asia Finish
// London Start
time_int_02 = input("0800-0900:1234567", "London", input.session)
in_time_int_02 = time(timeframe.period, time_int_02)
var highe_02 = 0.0
var lowe_02 = 10e10
if in_time_int_02
if not in_time_int_02[1]
highe_02 := high
lowe_02 := low
else
highe_02 := max(high, highe_02)
lowe_02 := min(low, lowe_02)
plot(not in_time_int_02 ? highe_02 : na, title="London High", color=color.yellow, linewidth=2, style=plot.style_linebr)
plotshape(not in_time_int_02 ? highe_02 : na, style=shape.labelup, location=location.absolute, color=color.yellow, textcolor=color.white, show_last=1, text="London High", offset = offset_val, transp=20, title="London High")
plot(not in_time_int_02 ? lowe_02 : na, title="London Low", color=color.yellow, linewidth=2, style=plot.style_linebr)
plotshape(not in_time_int_02 ? lowe_02 : na, style=shape.labeldown, location=location.absolute, color=color.yellow, textcolor=color.white, show_last=1, text="London Low", offset = offset_val, transp=20, title="London Low")
// London Finsh
// New York Start
time_int_03 = input("1430-1530:1234567", "New York", input.session)
in_time_int_03 = time(timeframe.period, time_int_03)
var highe_03 = 0.0
var lowe_03 = 10e10
if in_time_int_03
if not in_time_int_03[1]
highe_03 := high
lowe_03 := low
else
highe_03 := max(high, highe_03)
lowe_03 := min(low, lowe_03)
plot(not in_time_int_03 ? highe_03 : na, title="New York High", color=color.blue, linewidth=2, style=plot.style_linebr)
plotshape(not in_time_int_03 ? highe_03 : na, style=shape.labelup, location=location.absolute, color=color.blue, textcolor=color.white, show_last=1, text="New York High", offset = offset_val, transp=20, title="New York High")
plot(not in_time_int_03 ? lowe_03 : na, title="New York Low", color=color.blue, linewidth=2, style=plot.style_linebr)
plotshape(not in_time_int_03 ? lowe_03 : na, style=shape.labeldown, location=location.absolute, color=color.blue, textcolor=color.white, show_last=1, text="New York Low", offset = offset_val, transp=20, title="New York Low")
// New York Finish
// Background colors
AsiaAboveHigh = close>(highe_01)
LondonAboveHigh = close>(highe_02)
NewYorkAboveHigh = close>(highe_03)
Buy = AsiaAboveHigh and LondonAboveHigh and NewYorkAboveHigh
bgcolor(Buy and backcolor ? color.green : na, transp=95, title='Check Chart Buy Signal above all IB High')
AsiaBelowLow = close<(lowe_01)
LondonBelowLow = close<(lowe_02)
NewYorkBelowLow = close<(lowe_03)
Sell = AsiaBelowLow and LondonBelowLow and NewYorkBelowLow
bgcolor(Sell and backcolor ? color.red : na, transp=95, title='Check Chart Sell Signal below all IB Low')
// Condition Alerts
alertcondition(Buy==1 ? Buy : na, title="Buy Alert", message="Check Chart Buy Signal above all IB High, {{close}}")
alertcondition(Sell==1 ? Sell :na, title="Sell Alert", message="Check Chart Sell Signal below all IB Low, {{close}}")