本页源码来自 TradingView 公开发布的开源脚本,版权归原作者所有, 请遵循其原始许可(Pine 脚本常见 CC BY-NC-SA / MPL-2.0 / MIT)。 本项目仅用于研究检索与许可范围内的移植。
//@version=5
indicator(shorttitle="Simple ICT OB & FVG by GK", title="Simple ICT Order Blocks and Fair Value Gaps by Gowtham Kannakaje", overlay=true, max_labels_count = 500, max_lines_count = 500, max_boxes_count = 500, max_bars_back = 5000)
// Toggle boxes
Aaaaa = input(true, title='Show OB Boxes', group = "Order Blocks")
Dd = input.color(color.green,title = "Bullish OB border color", group = "Order Blocks", inline = "BuOB Color")
Ddd = input.color(color.rgb(76, 175, 79, 95),title = "Bullish OB box color", group = "Order Blocks", inline = "BuOB Color")
Ff = input.color(color.red,title = "Bearish OB border color", group = "Order Blocks", inline = "BeOB Color")
Fff = input.color(color.rgb(255, 82, 82, 95),title = "Bearish OB box color", group = "Order Blocks", inline = "BeOB Color")
Aaaaaa = input(true, title='Colour OB Candles', group = "Order Blocks")
E = input.color(color.green,title = "Bullish OB Bar color", group = "Order Blocks", inline = "OB Bar Color")
EE = input.color(color.red,title = " Bearish OB Bar color", group = "Order Blocks", inline = "OB Bar Color")
A = input(false, title='Show FVG Boxes', group = "Fair Value Gap")
Aa = input.color(color.teal,title = "FVG border color", group = "Fair Value Gap", inline = "FVG Color")
Aaa = input.color(color.rgb(255, 235, 59, 90),title = "FVG box color", group = "Fair Value Gap", inline = "FVG Color")
Aaaa = input(false, title='Colour FVG Candles', group = "Fair Value Gap")
C = input.color(color.green,title = "Bullish FVG Bar color", group = "Fair Value Gap", inline = "FVG Bar Color")
Cc = input.color(color.red,title = "Bearish FVG Bar color", group = "Fair Value Gap", inline = "FVG Bar Color")
//Defining Fair value gaps
AA = low - high[2] > 0 and open[1]<close[1]
AAA = low[2] - high > 0 and open[1]>close[1]
var line BBBB = na
var line BBBBB = na
var box BBBBBB = na
var line bBBBB = na
var line bBBBBB = na
var box bBBBBBB = na
if (AA and A)
BBBBBB:=box.new(bar_index-2,high[2],bar_index,low,border_color = Aa, bgcolor = Aaa,text = "", text_color = color.rgb(255, 255, 255, 80), text_size = size.small)
if (AAA and A)
bBBBBBB:=box.new(bar_index-2,low[2],bar_index,high,border_color = Aa, bgcolor = Aaa,text = "", text_color = color.rgb(255, 255, 255, 80), text_size = size.small)
AAAA = 0
AAAAA = AA and open[2]>close[2] and close[1]>high[2]
AAAAAA = AA and open[2]<=close[2] and open[3]>close[3] and close[1]>high[3] and not(open[2]>close[2])
AAAAAAA = AA and open[2]<=close[2] and open[3]<=close[3] and open[4]>close[4] and close[1]>high[4] and not(open[2]>close[2] or open[3]>close[3])
AAAAAAAA = not(((low[1]-high[3])>0) and open[3]>close[3])
AAAAAAAAA = not(((low[1]-high[3])>0) and open[3]>close[3]) and not(((low[2]-high[4])>0) and open[4]>close[4]) and not(((low[1]-high[3])>0) and open[4]>close[4])
AAAAAAAAAA = AAA and open[2]<close[2] and close[1]<low[2]
AAAAAAAAAAA = AAA and open[2]>=close[2] and open[3]<close[3] and close[1]<low[3] and not(open[2]<close[2])
AAAAAAAAAAAA = AAA and open[2]>=close[2] and open[3]>=close[3] and open[4]<close[4] and close[1]<low[4] and not(open[2]<close[2] or open[3]<close[3])
AAAAAAAAAAAAA = not(((low[3]-high[1])>0) and open[3]<close[3])
AAAAAAAAAAAAAA = not(((low[3]-high[1])>0) and open[3]<close[3]) and not(((low[4]-high[2])>0) and open[4]<close[4]) and not(((low[3]-high[1])>0) and open[4]<close[4])
/// Bullish OB boxes
if Aaaaa and AAAAA
AAAA:= 2
// BBBB:=line.new(bar_index-AAAA,low[AAAA],bar_index,low[AAAA],color = color.green)
// BBBBB:=line.new(bar_index-AAAA,high[AAAA],bar_index,high[AAAA],color = color.green)
BBBBBB:=box.new(bar_index-AAAA,high[AAAA],bar_index,low[AAAA],border_color = Dd, bgcolor = Ddd,text = "Naked OB", text_color = color.rgb(255, 255, 255, 80), text_size = size.small)
if Aaaaa and AAAAAA and AAAAAAAA
AAAA:= 3
// BBBB:=line.new(bar_index-AAAA,low[AAAA],bar_index,low[AAAA],color = color.green)
// BBBBB:=line.new(bar_index-AAAA,high[AAAA],bar_index,high[AAAA],color = color.green)
BBBBBB:=box.new(bar_index-AAAA,high[AAAA],bar_index,low[AAAA],border_color = Dd, bgcolor = Ddd,text = "Covered OB", text_color = color.rgb(255, 255, 255, 80), text_size = size.small)
if Aaaaa and AAAAAAA and AAAAAAAAA
AAAA:= 4
// BBBB:=line.new(bar_index-AAAA,low[AAAA],bar_index,low[AAAA],color = color.green)
// BBBBB:=line.new(bar_index-AAAA,high[AAAA],bar_index,high[AAAA],color = color.green)
BBBBBB:=box.new(bar_index-AAAA,high[AAAA],bar_index,low[AAAA],border_color = Dd, bgcolor = Ddd,text = "Covered OB", text_color = color.rgb(255, 255, 255, 80), text_size = size.small)
/// Bearish OB boxes
if Aaaaa and AAAAAAAAAA
AAAA:= 2
// BBBB:=line.new(bar_index-AAAA,low[AAAA],bar_index,low[AAAA],color = color.red)
// BBBBB:=line.new(bar_index-AAAA,high[AAAA],bar_index,high[AAAA],color = color.red)
BBBBBB:=box.new(bar_index-AAAA,high[AAAA],bar_index,low[AAAA],border_color = Ff, bgcolor = Fff,text = "Naked OB", text_color = color.rgb(255, 255, 255, 80), text_size = size.small)
if Aaaaa and AAAAAAAAAAA and AAAAAAAAAAAAA
AAAA:= 3
// BBBB:=line.new(bar_index-AAAA,low[AAAA],bar_index,low[AAAA],color = color.red)
// BBBBB:=line.new(bar_index-AAAA,high[AAAA],bar_index,high[AAAA],color = color.red)
BBBBBB:=box.new(bar_index-AAAA,high[AAAA],bar_index,low[AAAA],border_color = Ff, bgcolor = Fff,text = "Covered OB", text_color = color.rgb(255, 255, 255, 80), text_size = size.small)
if Aaaaa and AAAAAAAAAAAA and AAAAAAAAAAAAAA
AAAA:= 4
// BBBB:=line.new(bar_index-AAAA,low[AAAA],bar_index,low[AAAA],color = color.red)
// BBBBB:=line.new(bar_index-AAAA,high[AAAA],bar_index,high[AAAA],color = color.red)
BBBBBB:=box.new(bar_index-AAAA,high[AAAA],bar_index,low[AAAA],border_color = Ff, bgcolor = Fff,text = "Covered OB", text_color = color.rgb(255, 255, 255, 80), text_size = size.small)
//plotshape(newsell, style = shape.labeldown, location = location.abovebar, color = color.red, text = 'ConS', textcolor = color.rgb(255, 255, 255))
barcolor(AA and Aaaa ? C : AAA and Aaaa ? Cc : na, offset = -1,title = "FVG bar color")
barcolor((AAAAA and Aaaaaa) ? E : (AAAAAAAAAA and Aaaaaa) ? EE : na, offset = -2,title= "OB bar color")
barcolor(((AAAAAA and AAAAAAAA)) and Aaaaaa ? E : ((AAAAAAAAAAA and AAAAAAAAAAAAA)) and Aaaaaa ? EE : na, offset = -3,title= "OB bar color")
barcolor(((AAAAAAA and AAAAAAAAA)) and Aaaaaa ? E: ((AAAAAAAAAAAA and AAAAAAAAAAAAAA)) and Aaaaaa ? EE : na, offset = -4,title= "OB bar color")