本页源码来自 TradingView 公开发布的开源脚本,版权归原作者所有, 请遵循其原始许可(Pine 脚本常见 CC BY-NC-SA / MPL-2.0 / MIT)。 本项目仅用于研究检索与许可范围内的移植。
// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © TFlab
//@version=5
indicator("ICT KillZones + Pivot Points [TradingFinder] Support/Resistance Sweeps", 'Pivot Point | Killzone TFlab' , overlay = true, max_bars_back = 5000, max_boxes_count = 500, max_labels_count = 500, max_lines_count = 500)
import TFlab/SessionAndKillZoneLibrary_TradingFinder/1 as Sess
// Global Setting
ShowMoreInfo = input.bool(false, 'Show More Info', inline = 'More' , group = 'Global Setting')
ColorMoreInfo = input.color(#0c3299, '', inline = 'More' , group = 'Global Setting')
//input
//Pivot Range
PPType = input.string('Floor', 'Pivot Point Type', ['Floor', 'Woodie', 'Camarilla', 'Fibonacci'], inline = 'PP', group = 'Pivot Point Types')
Color = input.color(#0c3299, '', inline = 'PP', group = 'Pivot Point Types')
//Session Asia
show_AsiaSess = input(true, 'Asia Session',inline = 'sesasia', group = 'Asia Session', tooltip = 'Sydney + Tokyo')
Asia_SessTime = input.session('2300-0600', '', group = 'Asia Session')
Asia_color = input.color(#da6e0a, '', inline = 'sesasia', group = 'Asia Session')
show_AsiaKill = input(true, 'Asia Kill Zone', group = 'Asia Session')
Asia_KillTime = input.session('2300-0355', '', group = 'Asia Session')
//Session London
show_LondonSess = input(true, 'London Session', inline = 'seslondon', group = ' London Session')
London_SessTime = input.session('0700-1425', '', group = ' London Session')
London_color = input.color(#850244, '', inline = 'seslondon', group = ' London Session')
show_LondonKill = input(true, 'London Kill Zone', group = ' London Session')
London_KillTime = input.session('0700-0955', '', group = ' London Session')
//Session AM NewYork
show_amNewyorkSess = input(true, 'Newyork', inline = 'sesamNewyork', group = 'Newyork Session')
amNewyork_SessTime = input.session('1430-2255', '', group = 'Newyork Session')
amNewyork_color = input.color(#008b85, '', inline = 'sesamNewyork', group = 'Newyork Session')
show_amNewyorkKill = input(true, 'Newyork Kill Zone', group = 'Newyork Session')
amNewyork_KillTime = input.session('1430-1655', '', group = 'Newyork Session')
//Variables
var line R4Line = na
var line R3Line = na
var line R2Line = na
var line R1Line = na
var line PPLine = na
var line S1Line = na
var line S2Line = na
var line S3Line = na
var line S4Line = na
var label R4Label = na
var label R3Label = na
var label R2Label = na
var label R1Label = na
var label PPLabel = na
var label S1Label = na
var label S2Label = na
var label S3Label = na
var label S4Label = na
//get data
//Pivot Point Function
PivotPoint (PPType) =>
var float O = 0.0
var float H = 0.0
var float L = 0.0
var float C = 0.0
var float R4 = 0.0
var float R3 = 0.0
var float R2 = 0.0
var float R1 = 0.0
var float PP = 0.0
var float S1 = 0.0
var float S2 = 0.0
var float S3 = 0.0
var float S4 = 0.0
if minute(time_close('1D', syminfo.timezone)) == minute(time, syminfo.timezone)
O := open[0]
H := high[0]
L := low[0]
C := close[0]
if PPType == 'Floor'
PP := (H + L + C) / 3
R1 := (2 * PP) - L
R2 := PP + H - L
R3 := H + (2 * (PP - L))
S1 := (2 * PP) - H
S2 := PP - H + L
S3 := L - (2 * (H - PP))
if PPType == 'Woodie'
PP := (H + L + 2 * C) / 4
R1 := (2 * PP) - L
R2 := PP + H - L
S1 := (2 * PP) - H
S2 := PP - H + L
if PPType == 'Camarilla'
PP := (H + L + C) / 3
R4 := (((H - L) * 1.1) / 2) + C
R3 := (((H - L) * 1.1) / 4) + C
R2 := (((H - L) * 1.1) / 6) + C
R1 := (((H - L) * 1.1) / 12) + C
S1 := C - (((H - L) * 1.1) / 12)
S2 := C - (((H - L) * 1.1) / 6)
S3 := C - (((H - L) * 1.1) / 4)
S4 := C - (((H - L) * 1.1) / 2)
if PPType == "Fibonacci"
PP := (H + L + C) / 3
R3 := PP + ((H - L) * 1.000)
R2 := PP + ((H - L) * 0.618)
R1 := PP + ((H - L) * 0.382)
S1 := PP - ((H - L) * 0.382)
S2 := PP - ((H - L) * 0.618)
S3 := PP - ((H - L) * 1.000)
[PP,R1,R2,R3,R4,S1,S2,S3,S4,O,H,L,C]
//Call PP Function
[PP,R1,R2,R3,R4,S1,S2,S3,S4,O,H,L,C] = request.security(syminfo.tickerid, '1D', PivotPoint (PPType))
//Call Session Killzone
[SessTimeA, KillTimeA, OpenA, HighA, LowA, CloseA, LowTouchAlertA, HighTouchAlertA] = Sess.SessionDetector('Asia' , Asia_SessTime, Asia_KillTime, show_AsiaSess, show_AsiaKill, 'Kill Zone', ShowMoreInfo ,Asia_color,ColorMoreInfo)
[SessTimeL, KillTimeL, OpenL, HighL, LowL, CloseL, LowTouchAlertL, HighTouchAlertL] = Sess.SessionDetector('London', London_SessTime, London_KillTime, show_LondonSess, show_LondonKill, 'Kill Zone', ShowMoreInfo ,London_color,ColorMoreInfo)
[SessTimeNYa, KillTimeNYa, OpenNYa, HighNYa, LowNYa, CloseNYa, LowTouchAlertNYa, HighTouchAlertNYa] = Sess.SessionDetector('NewYork' , amNewyork_SessTime, amNewyork_KillTime, show_amNewyorkSess, show_amNewyorkKill, 'Kill Zone', ShowMoreInfo ,amNewyork_color,ColorMoreInfo)
//Drawing Lines
A = if SessTimeA == 1
SessTimeA[1] == 0 and SessTimeA == 1 and show_AsiaSess
else if SessTimeL == 1
SessTimeL[1] == 0 and SessTimeL == 1 and show_LondonSess
else if SessTimeNYa == 1
SessTimeNYa[1] == 0 and SessTimeNYa == 1 and show_amNewyorkKill
B = if SessTimeA == 1
SessTimeA[1] == 1 and SessTimeA == 1 and show_AsiaSess
else if SessTimeL == 1
SessTimeL[1] == 1 and SessTimeL == 1 and show_LondonSess
else if SessTimeNYa == 1
SessTimeNYa[1] == 1 and SessTimeNYa == 1 and show_amNewyorkSess
if A
if R4 > 0
R4Line := line.new( bar_index, R4, bar_index, R4, style = line.style_dashed , color = Color)
R4Label:= label.new(bar_index , R4 , 'R4', color = #ffffff00, textcolor = Color , style = label.style_label_left , size = size.normal)
if R3 > 0
R3Line := line.new(bar_index, R3, bar_index, R3, style = line.style_dotted , color = Color)
R3Label:= label.new(bar_index , R3 , 'R3', color = #ffffff00, textcolor = Color , style = label.style_label_left , size = size.normal)
if R2 > 0
R2Line := line.new(bar_index, R2, bar_index, R2, style = line.style_dashed , color = Color)
R2Label:= label.new(bar_index , R2 , 'R2', color = #ffffff00, textcolor = Color , style = label.style_label_left , size = size.normal)
if R1 > 0
R1Line := line.new(bar_index, R1, bar_index, R1, style = line.style_dotted , color = Color)
R1Label:= label.new(bar_index , R1 , 'R1', color = #ffffff00, textcolor = Color , style = label.style_label_left , size = size.normal)
if PPType != "Camarilla"
PPLine := line.new(bar_index, PP, bar_index, PP, style = line.style_solid , color = Color)
PPLabel:= label.new(bar_index , PP , 'PP', color = #ffffff00, textcolor = Color , style = label.style_label_left , size = size.normal)
if S1 > 0
S1Line := line.new(bar_index, S1, bar_index, S1, style = line.style_dotted , color = Color)
S1Label:= label.new(bar_index , S1 , 'S1', color = #ffffff00, textcolor = Color , style = label.style_label_left , size = size.normal)
if S2 > 0
S2Line := line.new(bar_index, S2, bar_index, S2, style = line.style_dashed , color = Color)
S2Label:= label.new(bar_index , S2 , 'S2', color = #ffffff00, textcolor = Color , style = label.style_label_left , size = size.normal)
if S3 > 0
S3Line := line.new(bar_index, S3, bar_index, S3, style = line.style_dotted , color = Color)
S3Label:= label.new(bar_index , S3 , 'S3', color = #ffffff00, textcolor = Color , style = label.style_label_left , size = size.normal)
if S4 > 0
S4Line := line.new(bar_index, S4, bar_index, S4, style = line.style_dashed , color = Color)
S4Label:= label.new(bar_index , S4 , 'S4', color = #ffffff00, textcolor = Color , style = label.style_label_left , size = size.normal)
if B
R4Line.set_x2(bar_index)
R3Line.set_x2(bar_index)
R2Line.set_x2(bar_index)
R1Line.set_x2(bar_index)
PPLine.set_x2(bar_index)
S1Line.set_x2(bar_index)
S2Line.set_x2(bar_index)
S3Line.set_x2(bar_index)
S4Line.set_x2(bar_index)
R4Label.set_x(bar_index)
R3Label.set_x(bar_index)
R2Label.set_x(bar_index)
R1Label.set_x(bar_index)
PPLabel.set_x(bar_index)
S1Label.set_x(bar_index)
S2Label.set_x(bar_index)
S3Label.set_x(bar_index)
S4Label.set_x(bar_index)