Reputation: 164
Afternoon all,
I am currently using the below script to monitor the highest and lowest Initial Balances for 3 market openings. Currently I switch between the symbols to see if price action has gone above the highest or lowest IB.
My idea I would like to put into code is to have a screener that allows me to view 10-20 symbols. Which would show green, red or white. Green if that symbols price action has gone above the highest IB, red below lowest IB, white if in between.
Similar to: https://uk.tradingview.com/script/La1XGzDj-Supertrend-Screener-Panel/
Currently the code is repeated with the only difference being time input for the three markets.
As the same code/processes will be repeated for each symbol I believe it could be made into a function where:
Any guidance would be gratefully appreciated:
Code below is extracted from the IB script above:
time_int_01 = input("0000-0100:1234567", "Asia IB Range", 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)
//////////////////////////////////// Initial Balance Asia Finish
//////////////////////////////////// Asia Plot Start
//High
AsiaIBHighInput = input('0100-0101:1234567', title="Capture Asia IB High") //set the opening range you are interested in
AsiaIBHigh = time("1", AsiaIBHighInput)
var AsiaIBHighPA = 0.0
if AsiaIBHigh
if not AsiaIBHigh[1]
AsiaIBHighPA := highe_01
plotAsiaIBHigh = plot(DisplayAllIBs ? AsiaIBHighPA : na, title=" Asia IB High", color=color.purple, linewidth=1, style=plot.style_linebr)
plotshape(DisplayAllIBs ? AsiaIBHighPA : na, style=shape.labeldown, location=location.absolute, color=color.purple, textcolor=color.white, show_last=1, text="Asia IB High", offset = offset_val, transp=20, title="Asia IB High")
//Low
AsiaIBLowInput = input('0100-0101:1234567', title="Capture Asia IB Low") //set the opening range you are interested in
AsiaIBLow = time("1", AsiaIBLowInput)
var AsiaIBLowPA = 0.0
if AsiaIBLow
if not AsiaIBLow[1]
AsiaIBLowPA := lowe_01
plotAsiaIBLow = plot(DisplayAllIBs ? AsiaIBLowPA : na, title=" Asia IB Low", color=color.purple, linewidth=1, style=plot.style_linebr)
plotshape(DisplayAllIBs ? AsiaIBLowPA : na, style=shape.labeldown, location=location.absolute, color=color.purple, textcolor=color.white, show_last=1, text="Asia IB Low", offset = offset_val, transp=20, title="Asia IB Low")
//////////////////////////////////// Asia Plot Finish
// Asia FINISH //
// London START //
//////////////////////////////////// Initial Balance London Start
time_int_02 = input("0800-0900:1234567", "London IB Range", 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)
//////////////////////////////////// Initial Balance London Finsh
//////////////////////////////////// London Plot Start
//High
LonIBHighInput = input('0900-0901:1234567', title="Capture London IB High") //set the opening range you are interested in
LonIBHigh = time("1", LonIBHighInput)
var LonIBHighPA = 0.0
if LonIBHigh
if not LonIBHigh[1]
LonIBHighPA := highe_02
plotLonIBHigh = plot(DisplayAllIBs ? LonIBHighPA : na, title=" Lon IB High", color=color.yellow, linewidth=1, style=plot.style_linebr)
plotshape(DisplayAllIBs ? LonIBHighPA : na, style=shape.labeldown, location=location.absolute, color=color.yellow, textcolor=color.white, show_last=1, text="Lon IB High", offset = offset_val, transp=20, title="Lon IB High")
//Low
LonIBLowInput = input('0900-0901:1234567', title="Capture London IB Low") //set the opening range you are interested in
LonIBLow = time("1", LonIBLowInput)
var LonIBLowPA = 0.0
if LonIBLow
if not LonIBLow[1]
LonIBLowPA := lowe_02
plotLonIBLow = plot(DisplayAllIBs ? LonIBLowPA : na, title=" Lon IB Low", color=color.yellow, linewidth=1, style=plot.style_linebr)
plotshape(DisplayAllIBs ? LonIBLowPA : na, style=shape.labeldown, location=location.absolute, color=color.yellow, textcolor=color.white, show_last=1, text="Lon IB Low", offset = offset_val, transp=20, title="Lon IB Low")
//////////////////////////////////// London Plot Finish
// London FINISH //
// New York START //
//////////////////////////////////// Initial Balance New York Start
time_int_03 = input("1430-1530:1234567", "New York IB Range", 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)
//////////////////////////////////// Initial Balance New York Finish
//////////////////////////////////// New York Plot Start
//High
NYIBHighInput = input('1530-1531:1234567', title="Capture New York IB High") //set the opening range you are interested in
NYIBHigh = time("1", NYIBHighInput)
var NYIBHighPA = 0.0
if NYIBHigh
if not NYIBHigh[1]
NYIBHighPA := highe_03
plotNYIBHigh = plot(DisplayAllIBs ? NYIBHighPA : na, title=" New York IB High", color=color.blue, linewidth=1, style=plot.style_linebr)
plotshape(DisplayAllIBs ? NYIBHighPA : na, style=shape.labeldown, location=location.absolute, color=color.blue, textcolor=color.white, show_last=1, text="New York IB High", offset = offset_val, transp=20, title="New York IB High")
//Low
NYIBLowInput = input('1530-1531:1234567', title="Capture New York IB Low") //set the opening range you are interested in
NYIBLow = time("1", NYIBLowInput)
var NYIBLowPA = 0.0
if NYIBLow
if not NYIBLow[1]
NYIBLowPA := lowe_03
plotNYIBLow = plot(DisplayAllIBs ? NYIBLowPA : na, title=" New York IB Low", color=color.blue, linewidth=1, style=plot.style_linebr)
plotshape(DisplayAllIBs ? NYIBLowPA : na, style=shape.labeldown, location=location.absolute, color=color.blue, textcolor=color.white, show_last=1, text="New York IB Low", offset = offset_val, transp=20, title="New York IB Low")
//////////////////////////////////// New York Plot Finish
// New York FINISH //
// Background colors
AsiaAboveHigh = close>(AsiaIBHighPA)
LondonAboveHigh = close>(LonIBHighPA)
NewYorkAboveHigh = close>(NYIBHighPA)
// IB Highest and Lowest Settings
Buy = AsiaAboveHigh and LondonAboveHigh and NewYorkAboveHigh
bgcolor(Buy and backcolor ? color.green : na, transp=95, title='Check Chart Buy Signal above all IB Highs')
AsiaBelowLow = close<(AsiaIBLowPA)
LondonBelowLow = close<(LonIBLowPA)
NewYorkBelowLow = close<(NYIBLowPA)
Sell = AsiaBelowLow and LondonBelowLow and NewYorkBelowLow
bgcolor(Sell and backcolor ? color.red : na, transp=95, title='Check Chart Sell Signal below all IB Lows')
##################################################################### Update 08/03/2021 - 1700 for @AnyDozer
Below is script so far I have put a simple function in so it doesn't error, Any assistance will be gratefully appreciated. I have been trying to develop the function but have not been successful.
//@version=4
study(title="Panel Wave Trend & MF", shorttitle="Panel Wave Trend & MF")
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// USER Symbol Input
Symbol01 = input(title = "Symbol Selection", defval="COINBASE:BTCUSD")
Symbol02 = input(title = "Symbol Selection", defval="COINBASE:LTCUSD")
Symbol03 = input(title = "Symbol Selection", defval="COINBASE:BCHUSD")
Symbol04 = input(title = "Symbol Selection", defval="COINBASE:ETHUSD")
Symbol05 = input(title = "Symbol Selection", defval="COINBASE:CGLDUSD")
Symbol06 = input(title = "Symbol Selection", defval="COINBASE:ALGOUSD")
// User adjustment inputs
offset_val = input(title="Label Offset", type=input.integer, defval=20)
backcolor = input(true, title="Optional background colour Price Action (PA) above or below all IB highs/lows")
DisplayAllIBs = input(false, title="Optional to display all IB highs/lows")
MidLinebackcolor = input(false, title="Optional background colour Price Action (PA) above or below all Midline")
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//TRYING TO IMPLEMENT THE BELOW IB PROCESSES INTO A FUNCTION SO THAT IT CAN USED ACROSS SEVERAL SYMBOLS IN A SCREENER
//The below works out the Initial Balance for Asia, London and New York then plots from the time the IB has finshed its 60 mins.
//It then looks at the 3 IBs to see which IB is the highest and plots it.
//The aim is to plot green on the monitoring panel if the price has gone above the highest IB
//Plot red if price has gone below the lowest IB
//Plot white if it is inbetween the highest and lowest IB
// Asia START //
//////////////////////////////////// Initial Balance Asia Start
time_int_01 = input("0000-0100:1234567", "Asia IB Range", 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)
//////////////////////////////////// Initial Balance Asia Finish
//////////////////////////////////// Asia Plot Start
//High
AsiaIBHighInput = input('0100-0101:1234567', title="Capture Asia IB High") //set the opening range you are interested in
AsiaIBHigh = time("1", AsiaIBHighInput)
var AsiaIBHighPA = 0.0
if AsiaIBHigh
if not AsiaIBHigh[1]
AsiaIBHighPA := highe_01
plotAsiaIBHigh = plot(DisplayAllIBs ? AsiaIBHighPA : na, title=" Asia IB High", color=color.purple, linewidth=1, style=plot.style_linebr)
plotshape(DisplayAllIBs ? AsiaIBHighPA : na, style=shape.labeldown, location=location.absolute, color=color.purple, textcolor=color.white, show_last=1, text="Asia IB High", offset = offset_val, transp=20, title="Asia IB High")
//Low
AsiaIBLowInput = input('0100-0101:1234567', title="Capture Asia IB Low") //set the opening range you are interested in
AsiaIBLow = time("1", AsiaIBLowInput)
var AsiaIBLowPA = 0.0
if AsiaIBLow
if not AsiaIBLow[1]
AsiaIBLowPA := lowe_01
plotAsiaIBLow = plot(DisplayAllIBs ? AsiaIBLowPA : na, title=" Asia IB Low", color=color.purple, linewidth=1, style=plot.style_linebr)
plotshape(DisplayAllIBs ? AsiaIBLowPA : na, style=shape.labeldown, location=location.absolute, color=color.purple, textcolor=color.white, show_last=1, text="Asia IB Low", offset = offset_val, transp=20, title="Asia IB Low")
//////////////////////////////////// Asia Plot Finish
// Asia FINISH //
// London START //
//////////////////////////////////// Initial Balance London Start
time_int_02 = input("0800-0900:1234567", "London IB Range", 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)
//////////////////////////////////// Initial Balance London Finsh
//////////////////////////////////// London Plot Start
//High
LonIBHighInput = input('0900-0901:1234567', title="Capture London IB High") //set the opening range you are interested in
LonIBHigh = time("1", LonIBHighInput)
var LonIBHighPA = 0.0
if LonIBHigh
if not LonIBHigh[1]
LonIBHighPA := highe_02
plotLonIBHigh = plot(DisplayAllIBs ? LonIBHighPA : na, title=" Lon IB High", color=color.yellow, linewidth=1, style=plot.style_linebr)
plotshape(DisplayAllIBs ? LonIBHighPA : na, style=shape.labeldown, location=location.absolute, color=color.yellow, textcolor=color.white, show_last=1, text="Lon IB High", offset = offset_val, transp=20, title="Lon IB High")
//Low
LonIBLowInput = input('0900-0901:1234567', title="Capture London IB Low") //set the opening range you are interested in
LonIBLow = time("1", LonIBLowInput)
var LonIBLowPA = 0.0
if LonIBLow
if not LonIBLow[1]
LonIBLowPA := lowe_02
plotLonIBLow = plot(DisplayAllIBs ? LonIBLowPA : na, title=" Lon IB Low", color=color.yellow, linewidth=1, style=plot.style_linebr)
plotshape(DisplayAllIBs ? LonIBLowPA : na, style=shape.labeldown, location=location.absolute, color=color.yellow, textcolor=color.white, show_last=1, text="Lon IB Low", offset = offset_val, transp=20, title="Lon IB Low")
//////////////////////////////////// London Plot Finish
// London FINISH //
// New York START //
//////////////////////////////////// Initial Balance New York Start
time_int_03 = input("1430-1530:1234567", "New York IB Range", 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)
//////////////////////////////////// Initial Balance New York Finish
//////////////////////////////////// New York Plot Start
//High
NYIBHighInput = input('1530-1531:1234567', title="Capture New York IB High") //set the opening range you are interested in
NYIBHigh = time("1", NYIBHighInput)
var NYIBHighPA = 0.0
if NYIBHigh
if not NYIBHigh[1]
NYIBHighPA := highe_03
plotNYIBHigh = plot(DisplayAllIBs ? NYIBHighPA : na, title=" New York IB High", color=color.blue, linewidth=1, style=plot.style_linebr)
plotshape(DisplayAllIBs ? NYIBHighPA : na, style=shape.labeldown, location=location.absolute, color=color.blue, textcolor=color.white, show_last=1, text="New York IB High", offset = offset_val, transp=20, title="New York IB High")
//Low
NYIBLowInput = input('1530-1531:1234567', title="Capture New York IB Low") //set the opening range you are interested in
NYIBLow = time("1", NYIBLowInput)
var NYIBLowPA = 0.0
if NYIBLow
if not NYIBLow[1]
NYIBLowPA := lowe_03
plotNYIBLow = plot(DisplayAllIBs ? NYIBLowPA : na, title=" New York IB Low", color=color.blue, linewidth=1, style=plot.style_linebr)
plotshape(DisplayAllIBs ? NYIBLowPA : na, style=shape.labeldown, location=location.absolute, color=color.blue, textcolor=color.white, show_last=1, text="New York IB Low", offset = offset_val, transp=20, title="New York IB Low")
//////////////////////////////////// New York Plot Finish
// New York FINISH //
// Background colors
AsiaAboveHigh = close>(AsiaIBHighPA)
LondonAboveHigh = close>(LonIBHighPA)
NewYorkAboveHigh = close>(NYIBHighPA)
// IB Highest and Lowest Settings
Buy = AsiaAboveHigh and LondonAboveHigh and NewYorkAboveHigh
bgcolor(Buy and backcolor ? color.green : na, transp=95, title='Check Chart Buy Signal above all IB Highs')
AsiaBelowLow = close<(AsiaIBLowPA)
LondonBelowLow = close<(LonIBLowPA)
NewYorkBelowLow = close<(NYIBLowPA)
Sell = AsiaBelowLow and LondonBelowLow and NewYorkBelowLow
bgcolor(Sell and backcolor ? color.red : na, transp=95, title='Check Chart Sell Signal below all IB Lows')
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//TRYING TO IMPLEMENT THE ABOVE IB PROCESSES INTO A FUNCTION SO THAT IT CAN USED ACROSS SEVERAL SYMBOLS IN A SCREENER
//The below works out the Initial Balance for Asia, London and New York then plots from the time the IB has finshed its 60 mins.
//It then looks at the 3 IBs to see which IB is the highest and plots it.
//The aim is to plot green on the monitoring panel if the price has gone above the highest IB
//Plot red if price has gone below the lowest IB
//Plot white if it is inbetween the highest and lowest IB
IBCALC () =>
// AsiaIBTime = input('0000-0100:1234567')
// var highe_A = 0.0
// var lowe_A = 10e10
// if AsiaIBTime
// if not AsiaIBTime[1]
// highe_A := high
// lowe_A := low
// else
// highe_A := max(high, highe_A)
// lowe_A := min(low, lowe_A)
AboveAllIBs = color.green //#0CAB07 // Dark Green -> Long
BelowAllIBs = color.red //#DE071C // Dark Red -> Short
InBetween = color.white //#E1DE14 // Yellow #000000 #555555
C = close
O = open
IBcolor_ = C > O ? C > C[1] ? AboveAllIBs : AboveAllIBs : C < O ? C < C[1] ? BelowAllIBs : BelowAllIBs : InBetween
[IBcolor_]
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
[IBcolor_] = IBCALC ()
color_Sym01 = security(Symbol01, timeframe.period, IBcolor_)
color_Sym02 = security(Symbol02, timeframe.period, IBcolor_)
color_Sym03 = security(Symbol03, timeframe.period, IBcolor_)
color_Sym04 = security(Symbol04, timeframe.period, IBcolor_)
color_Sym05 = security(Symbol05, timeframe.period, IBcolor_)
color_Sym06 = security(Symbol06, timeframe.period, IBcolor_)
// === PLOT HISTOGRAM ===
// === Allocate Strategies to Lines ===
Sym01_bar = 6
Sym02_bar = 5
Sym03_bar = 4
Sym04_bar = 3
Sym05_bar = 2
Sym06_bar = 1
// === Plot Signals per Strategy ===
plot(Sym01_bar, title="BTCUSD", color = color_Sym01, transp = 0, style = plot.style_columns)
plot(Sym02_bar, title="LTCUSD", color = color_Sym02, transp = 0, style = plot.style_columns)
plot(Sym03_bar, title="BCHUSD", color = color_Sym03, transp = 0, style = plot.style_columns)
plot(Sym04_bar, title="ETHUSD", color = color_Sym04, transp = 0, style = plot.style_columns)
plot(Sym05_bar, title="CGLDUSD", color = color_Sym05, transp = 0, style = plot.style_columns)
plot(Sym06_bar, title="ALGOUSD", color = color_Sym06, transp = 0, style = plot.style_columns)
// === Plot Background lines ===
line0 = hline(0, title="Line 0", linestyle=hline.style_dotted, editable = false)
line1 = hline(1, title="Line 1", linestyle=hline.style_dotted, editable = false)
line2 = hline(2, title="Line 2", linestyle=hline.style_dotted, editable = false)
line3 = hline(3, title="Line 3", linestyle=hline.style_dotted, editable = false)
line4 = hline(4, title="Line 4", linestyle=hline.style_dotted, editable = false)
line5 = hline(5, title="Line 5", linestyle=hline.style_dotted, editable = false)
line6 = hline(6, title="Line 6", linestyle=hline.style_dotted, editable = false)
// === Plot Labels ===
chper = time - time[1]
chper := change(chper) > 0 ? chper[1] : chper
var label l_Sym01 = na, var label l_Sym02 = na, var label l_Sym03 = na, var label l_Sym04 = na, var label l_Sym05 = na, var label l_Sym06 = na
label.delete(l_Sym01), label.delete(l_Sym02), label.delete(l_Sym03), label.delete(l_Sym04), label.delete(l_Sym05), label.delete(l_Sym06)
l_Sym01 := label.new(x = time + chper * 20, y = Sym01_bar-1, text = "BTCUSD", textcolor=#FFFFFF, style=label.style_none, xloc = xloc.bar_time, yloc=yloc.price, size=size.small)
l_Sym02 := label.new(x = time + chper * 20, y = Sym02_bar-1, text = "LTCUSD", textcolor=#FFFFFF, style=label.style_none, xloc = xloc.bar_time, yloc=yloc.price, size=size.small)
l_Sym03 := label.new(x = time + chper * 20, y = Sym03_bar-1, text = "BCHUSD", textcolor=#FFFFFF, style=label.style_none, xloc = xloc.bar_time, yloc=yloc.price, size=size.small)
l_Sym04 := label.new(x = time + chper * 20, y = Sym04_bar-1, text = "ETHUSD", textcolor=#FFFFFF, style=label.style_none, xloc = xloc.bar_time, yloc=yloc.price, size=size.small)
l_Sym05 := label.new(x = time + chper * 20, y = Sym05_bar-1, text = "CGLDUSD", textcolor=#FFFFFF, style=label.style_none, xloc = xloc.bar_time, yloc=yloc.price, size=size.small)
l_Sym06 := label.new(x = time + chper * 20, y = Sym06_bar-1, text = "ALGOUSD", textcolor=#FFFFFF, style=label.style_none, xloc = xloc.bar_time, yloc=yloc.price, size=size.small)
Upvotes: 0
Views: 162
Reputation: 2568
//@version=4
study(title="Help (Panel Wave Trend & MF)", shorttitle="Panel Wave Trend & MF")
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// USER Symbol Input
Symbol01 = input(title = "Symbol Selection", defval="COINBASE:BTCUSD")
Symbol02 = input(title = "Symbol Selection", defval="COINBASE:LTCUSD")
Symbol03 = input(title = "Symbol Selection", defval="COINBASE:BCHUSD")
Symbol04 = input(title = "Symbol Selection", defval="COINBASE:ETHUSD")
Symbol05 = input(title = "Symbol Selection", defval="COINBASE:CGLDUSD")
Symbol06 = input(title = "Symbol Selection", defval="COINBASE:ALGOUSD")
// User adjustment inputs
offset_val = input(title="Label Offset", type=input.integer, defval=20)
backcolor = input(true, title="Optional background colour Price Action (PA) above or below all IB highs/lows")
DisplayAllIBs = input(false, title="Optional to display all IB highs/lows")
MidLinebackcolor = input(false, title="Optional background colour Price Action (PA) above or below all Midline")
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//TRYING TO IMPLEMENT THE BELOW IB PROCESSES INTO A FUNCTION SO THAT IT CAN USED ACROSS SEVERAL SYMBOLS IN A SCREENER
//The below works out the Initial Balance for Asia, London and New York then plots from the time the IB has finshed its 60 mins.
//It then looks at the 3 IBs to see which IB is the highest and plots it.
//The aim is to plot green on the monitoring panel if the price has gone above the highest IB
//Plot red if price has gone below the lowest IB
//Plot white if it is inbetween the highest and lowest IB
// Start of the function, must include all calculations
IBCALC () =>
// Asia START //
//////////////////////////////////// Initial Balance Asia Start
time_int_01 = input("0000-0100:1234567", "Asia IB Range", 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)
//////////////////////////////////// Initial Balance Asia Finish
//////////////////////////////////// Asia Plot Start
//High
AsiaIBHighInput = input('0100-0101:1234567', title="Capture Asia IB High") //set the opening range you are interested in
AsiaIBHigh = time("1", AsiaIBHighInput)
var AsiaIBHighPA = 0.0
if AsiaIBHigh
if not AsiaIBHigh[1]
AsiaIBHighPA := highe_01
// plotAsiaIBHigh = plot(DisplayAllIBs ? AsiaIBHighPA : na, title=" Asia IB High", color=color.purple, linewidth=1, style=plot.style_linebr)
// plotshape(DisplayAllIBs ? AsiaIBHighPA : na, style=shape.labeldown, location=location.absolute, color=color.purple, textcolor=color.white, show_last=1, text="Asia IB High", offset = offset_val, transp=20, title="Asia IB High")
//Low
AsiaIBLowInput = input('0100-0101:1234567', title="Capture Asia IB Low") //set the opening range you are interested in
AsiaIBLow = time("1", AsiaIBLowInput)
var AsiaIBLowPA = 0.0
if AsiaIBLow
if not AsiaIBLow[1]
AsiaIBLowPA := lowe_01
// plotAsiaIBLow = plot(DisplayAllIBs ? AsiaIBLowPA : na, title=" Asia IB Low", color=color.purple, linewidth=1, style=plot.style_linebr)
// plotshape(DisplayAllIBs ? AsiaIBLowPA : na, style=shape.labeldown, location=location.absolute, color=color.purple, textcolor=color.white, show_last=1, text="Asia IB Low", offset = offset_val, transp=20, title="Asia IB Low")
//////////////////////////////////// Asia Plot Finish
// Asia FINISH //
// London START //
//////////////////////////////////// Initial Balance London Start
time_int_02 = input("0800-0900:1234567", "London IB Range", 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)
//////////////////////////////////// Initial Balance London Finsh
//////////////////////////////////// London Plot Start
//High
LonIBHighInput = input('0900-0901:1234567', title="Capture London IB High") //set the opening range you are interested in
LonIBHigh = time("1", LonIBHighInput)
var LonIBHighPA = 0.0
if LonIBHigh
if not LonIBHigh[1]
LonIBHighPA := highe_02
// plotLonIBHigh = plot(DisplayAllIBs ? LonIBHighPA : na, title=" Lon IB High", color=color.yellow, linewidth=1, style=plot.style_linebr)
// plotshape(DisplayAllIBs ? LonIBHighPA : na, style=shape.labeldown, location=location.absolute, color=color.yellow, textcolor=color.white, show_last=1, text="Lon IB High", offset = offset_val, transp=20, title="Lon IB High")
//Low
LonIBLowInput = input('0900-0901:1234567', title="Capture London IB Low") //set the opening range you are interested in
LonIBLow = time("1", LonIBLowInput)
var LonIBLowPA = 0.0
if LonIBLow
if not LonIBLow[1]
LonIBLowPA := lowe_02
// plotLonIBLow = plot(DisplayAllIBs ? LonIBLowPA : na, title=" Lon IB Low", color=color.yellow, linewidth=1, style=plot.style_linebr)
// plotshape(DisplayAllIBs ? LonIBLowPA : na, style=shape.labeldown, location=location.absolute, color=color.yellow, textcolor=color.white, show_last=1, text="Lon IB Low", offset = offset_val, transp=20, title="Lon IB Low")
//////////////////////////////////// London Plot Finish
// London FINISH //
// New York START //
//////////////////////////////////// Initial Balance New York Start
time_int_03 = input("1430-1530:1234567", "New York IB Range", 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)
//////////////////////////////////// Initial Balance New York Finish
//////////////////////////////////// New York Plot Start
//High
NYIBHighInput = input('1530-1531:1234567', title="Capture New York IB High") //set the opening range you are interested in
NYIBHigh = time("1", NYIBHighInput)
var NYIBHighPA = 0.0
if NYIBHigh
if not NYIBHigh[1]
NYIBHighPA := highe_03
// plotNYIBHigh = plot(DisplayAllIBs ? NYIBHighPA : na, title=" New York IB High", color=color.blue, linewidth=1, style=plot.style_linebr)
// plotshape(DisplayAllIBs ? NYIBHighPA : na, style=shape.labeldown, location=location.absolute, color=color.blue, textcolor=color.white, show_last=1, text="New York IB High", offset = offset_val, transp=20, title="New York IB High")
//Low
NYIBLowInput = input('1530-1531:1234567', title="Capture New York IB Low") //set the opening range you are interested in
NYIBLow = time("1", NYIBLowInput)
var NYIBLowPA = 0.0
if NYIBLow
if not NYIBLow[1]
NYIBLowPA := lowe_03
// plotNYIBLow = plot(DisplayAllIBs ? NYIBLowPA : na, title=" New York IB Low", color=color.blue, linewidth=1, style=plot.style_linebr)
// plotshape(DisplayAllIBs ? NYIBLowPA : na, style=shape.labeldown, location=location.absolute, color=color.blue, textcolor=color.white, show_last=1, text="New York IB Low", offset = offset_val, transp=20, title="New York IB Low")
//////////////////////////////////// New York Plot Finish
// New York FINISH //
// Background colors
AsiaAboveHigh = close>(AsiaIBHighPA)
LondonAboveHigh = close>(LonIBHighPA)
NewYorkAboveHigh = close>(NYIBHighPA)
// IB Highest and Lowest Settings
Buy = AsiaAboveHigh and LondonAboveHigh and NewYorkAboveHigh
// bgcolor(Buy and backcolor ? color.green : na, transp=95, title='Check Chart Buy Signal above all IB Highs')
AsiaBelowLow = close<(AsiaIBLowPA)
LondonBelowLow = close<(LonIBLowPA)
NewYorkBelowLow = close<(NYIBLowPA)
Sell = AsiaBelowLow and LondonBelowLow and NewYorkBelowLow
// bgcolor(Sell and backcolor ? color.red : na, transp=95, title='Check Chart Sell Signal below all IB Lows')
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//TRYING TO IMPLEMENT THE ABOVE IB PROCESSES INTO A FUNCTION SO THAT IT CAN USED ACROSS SEVERAL SYMBOLS IN A SCREENER
//The below works out the Initial Balance for Asia, London and New York then plots from the time the IB has finshed its 60 mins.
//It then looks at the 3 IBs to see which IB is the highest and plots it.
//The aim is to plot green on the monitoring panel if the price has gone above the highest IB
//Plot red if price has gone below the lowest IB
//Plot white if it is inbetween the highest and lowest IB
// IBCALC () =>
// AsiaIBTime = input('0000-0100:1234567')
// var highe_A = 0.0
// var lowe_A = 10e10
// if AsiaIBTime
// if not AsiaIBTime[1]
// highe_A := high
// lowe_A := low
// else
// highe_A := max(high, highe_A)
// lowe_A := min(low, lowe_A)
AboveAllIBs = color.green //#0CAB07 // Dark Green -> Long
BelowAllIBs = color.red //#DE071C // Dark Red -> Short
InBetween = color.white //#E1DE14 // Yellow #000000 #555555
// C = close
// O = open
// IBcolor_ = C > O ? C > C[1] ? AboveAllIBs : AboveAllIBs : C < O ? C < C[1] ? BelowAllIBs : BelowAllIBs : InBetween
IBcolor_ = Buy ? AboveAllIBs : Sell ? BelowAllIBs : InBetween
[IBcolor_]
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
[IBcolor_] = IBCALC ()
color_Sym01 = security(Symbol01, timeframe.period, IBcolor_)
color_Sym02 = security(Symbol02, timeframe.period, IBcolor_)
color_Sym03 = security(Symbol03, timeframe.period, IBcolor_)
color_Sym04 = security(Symbol04, timeframe.period, IBcolor_)
color_Sym05 = security(Symbol05, timeframe.period, IBcolor_)
color_Sym06 = security(Symbol06, timeframe.period, IBcolor_)
// === PLOT HISTOGRAM ===
// === Allocate Strategies to Lines ===
Sym01_bar = 6
Sym02_bar = 5
Sym03_bar = 4
Sym04_bar = 3
Sym05_bar = 2
Sym06_bar = 1
// === Plot Signals per Strategy ===
plot(Sym01_bar, title="BTCUSD", color = color_Sym01, transp = 0, style = plot.style_columns)
plot(Sym02_bar, title="LTCUSD", color = color_Sym02, transp = 0, style = plot.style_columns)
plot(Sym03_bar, title="BCHUSD", color = color_Sym03, transp = 0, style = plot.style_columns)
plot(Sym04_bar, title="ETHUSD", color = color_Sym04, transp = 0, style = plot.style_columns)
plot(Sym05_bar, title="CGLDUSD", color = color_Sym05, transp = 0, style = plot.style_columns)
plot(Sym06_bar, title="ALGOUSD", color = color_Sym06, transp = 0, style = plot.style_columns)
// === Plot Background lines ===
line0 = hline(0, title="Line 0", linestyle=hline.style_dotted, editable = false)
line1 = hline(1, title="Line 1", linestyle=hline.style_dotted, editable = false)
line2 = hline(2, title="Line 2", linestyle=hline.style_dotted, editable = false)
line3 = hline(3, title="Line 3", linestyle=hline.style_dotted, editable = false)
line4 = hline(4, title="Line 4", linestyle=hline.style_dotted, editable = false)
line5 = hline(5, title="Line 5", linestyle=hline.style_dotted, editable = false)
line6 = hline(6, title="Line 6", linestyle=hline.style_dotted, editable = false)
// === Plot Labels ===
chper = time - time[1]
chper := change(chper) > 0 ? chper[1] : chper
var label l_Sym01 = na, var label l_Sym02 = na, var label l_Sym03 = na, var label l_Sym04 = na, var label l_Sym05 = na, var label l_Sym06 = na
label.delete(l_Sym01), label.delete(l_Sym02), label.delete(l_Sym03), label.delete(l_Sym04), label.delete(l_Sym05), label.delete(l_Sym06)
l_Sym01 := label.new(x = time + chper * 20, y = Sym01_bar-1, text = "BTCUSD", textcolor=#000000, style=label.style_none, xloc = xloc.bar_time, yloc=yloc.price, size=size.small)
l_Sym02 := label.new(x = time + chper * 20, y = Sym02_bar-1, text = "LTCUSD", textcolor=#000000, style=label.style_none, xloc = xloc.bar_time, yloc=yloc.price, size=size.small)
l_Sym03 := label.new(x = time + chper * 20, y = Sym03_bar-1, text = "BCHUSD", textcolor=#000000, style=label.style_none, xloc = xloc.bar_time, yloc=yloc.price, size=size.small)
l_Sym04 := label.new(x = time + chper * 20, y = Sym04_bar-1, text = "ETHUSD", textcolor=#000000, style=label.style_none, xloc = xloc.bar_time, yloc=yloc.price, size=size.small)
l_Sym05 := label.new(x = time + chper * 20, y = Sym05_bar-1, text = "CGLDUSD", textcolor=#000000, style=label.style_none, xloc = xloc.bar_time, yloc=yloc.price, size=size.small)
l_Sym06 := label.new(x = time + chper * 20, y = Sym06_bar-1, text = "ALGOUSD", textcolor=#000000, style=label.style_none, xloc = xloc.bar_time, yloc=yloc.price, size=size.small)
Upvotes: 1