Sessions [TradingFinder] New York, London, Tokyo & Sydney - Forex Market

TradingFinder · study · 172 行 · 点赞 4,249 · TradingView 原页

本页源码来自 TradingView 公开发布的开源脚本,版权归原作者所有, 请遵循其原始许可(Pine 脚本常见 CC BY-NC-SA / MPL-2.0 / MIT)。 本项目仅用于研究检索与许可范围内的移植。

Pine Script

// 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("Sessions [TradingFinder] New York, London, Tokyo & Sydney  - Forex Market", "TFlab Sessions", overlay = true)
 
//Session Asia
show_sesasia = input(true, 'Asia Session', group = 'Asia Session', tooltip = 'Sydney + Tokyo')
sesasia_ses = input.session('2300-0600', '', inline = 'sesasia', group = 'Asia Session')
sesasia_color = input.color(#EB9DA2, 'Color', inline = 'sesasia', group = 'Asia Session')
sesasia_text = 'Asia'
 
//Session Sydney
show_sesSydney = input(true, 'Sydney Session', group = 'Sydney Session') 
sesSydney_ses = input.session('2300-0500', '', inline = 'sesSydney', group = 'Sydney Session')
sesSydney_color = input.color(#F0B884, 'Color', inline = 'sesSydney', group = 'Sydney Session')
sesSydney_text = 'Sydney'
 
//Session Tokyo
show_sesTokyo = input(true, 'Tokyo Session', group = 'Tokyo Session') 
sesTokyo_ses = input.session('0000-0600', '', inline = 'sesTokyo', group = 'Tokyo Session')
sesTokyo_color = input.color(#0CC1C0, 'Color', inline = 'sesTokyo', group = 'Tokyo Session')
sesTokyo_text = 'Tokyo'
//Session Europe
show_sesEuro = input(true, 'Europe Session',  group = 'Europe Session', tooltip = 'Frankfurt + London') 
sesEuro_ses = input.session('0700-1630', '', inline = 'sesEuro', group = 'Europe Session')
sesEuro_color = input.color(#BBE8B5, 'Color', inline = 'sesEuro', group = 'Europe Session')
sesEuro_text = 'Europe'
 
show_seslondon = input(true, 'London Session',  group = ' London Session') 
seslondon_ses = input.session('0800-1630', '', inline = 'seslondon', group = ' London Session')
seslondon_color = input.color(#ACBBE8, 'Color', inline = 'seslondon', group = ' London Session')
seslondon_text = 'London'
 
//Session NewYork
show_sesNewyork = input(true, 'Newyork Session',  group = 'Newyork Session') 
sesNewyork_ses = input.session('1300-2200', '', inline = 'sesNewyork', group = 'Newyork Session')
sesNewyork_color = input.color(#C5ACE8, 'Color', inline = 'sesNewyork', group = 'Newyork Session')
sesNewyork_text = 'NewYork'
 
 
//Info Table
Show_Info_Table = input(true, 'Info Table', group   = 'Table')
 
 
//zones
On_sesasia = math.sign(nz(time(timeframe.period, sesasia_ses, 'UTC+0')))
On_sesEuro = math.sign(nz(time(timeframe.period, sesEuro_ses, 'UTC+0')))
On_sesTokyo = math.sign(nz(time(timeframe.period, sesTokyo_ses, 'UTC+0')))
On_seslondon = math.sign(nz(time(timeframe.period, seslondon_ses, 'UTC+0')))
On_sesNewyork = math.sign(nz(time(timeframe.period, sesNewyork_ses, 'UTC+0')))
On_sesSydney = math.sign(nz(time(timeframe.period, sesSydney_ses, 'UTC+0')))
On_startrankfurt = math.sign(nz(time(timeframe.period, '0700-0701', 'UTC+0')))
On_startLondon = math.sign(nz(time(timeframe.period, '0800-0801', 'UTC+0')))
 
 
//High & Low Session Detector 
LowHighSessionDetector(On_Session, Color_Session, Text_Session) =>
    var int Bar = 0
    var float High = 0.0 
    var float Low = 0.0
    var box BoX = na
    var label LabeL = na 
    if  (On_Session[1] == 0 and On_Session == 1)
        Bar := bar_index
        High := high
        Low := low
    else if (On_Session[1] == 1 and On_Session == 1)
        High := math.max(high , High) 
        Low :=   math.min(low , Low)
    else if On_Session == 0
        High := 0.0 
        Low := 0.0
        Bar := 0
 
    if On_Session > On_Session[1]
        BoX := box.new(bar_index,High, bar_index , Low, bgcolor = color.new(Color_Session, 85),
         border_color = color.rgb(34, 101, 155),
         border_style = line.style_dotted)
        
        LabeL := label.new(Bar, High , text = Text_Session ,xloc = xloc.bar_index, yloc = yloc.price, size = size.small ,
         style = (Text_Session == 'Sydney' or Text_Session == 'Europe' ) ? label.style_label_lower_right  : 
         Text_Session == 'Asia' ?  label.style_label_down :  label.style_label_lower_left,
         textcolor = Color_Session, color = color.rgb(255, 255, 255, 100))
    if On_Session and On_Session == On_Session[1]
        box.set_top(BoX, High)
        box.set_bottom(BoX, Low)
        box.set_right(BoX, bar_index)
        label.set_x(LabeL,math.round(math.avg(Bar,bar_index)))
        label.set_y(LabeL, High)
 
 
    [High , Low ]
  
 
if show_sesasia 
    [HighA, LowA]  = LowHighSessionDetector(On_sesasia, sesasia_color,sesasia_text)
 
if show_sesSydney 
    [HighS, LowS]  = LowHighSessionDetector(On_sesSydney,sesSydney_color,sesSydney_text)
 
if show_sesTokyo 
    [HighT, LowT]  = LowHighSessionDetector(On_sesTokyo,sesTokyo_color,sesTokyo_text)
 
if show_sesEuro 
    [HighE, LowE]  = LowHighSessionDetector(On_sesEuro,sesEuro_color,sesEuro_text)
 
if show_seslondon 
    [HighL, LowL]  = LowHighSessionDetector(On_seslondon,seslondon_color,seslondon_text)
 
if show_sesNewyork 
    [HighN, LowN]  = LowHighSessionDetector(On_sesNewyork,sesNewyork_color,sesNewyork_text)
 
 
 
//Info Table
 
var Info_Table = table.new(position.top_right, 4, 8, bgcolor = #283c74, border_color = #53609bcb, border_width = 1, 
 frame_color = #373a46 , frame_width = 1)
 
if Show_Info_Table
    table.cell(Info_Table, 0, 0, 'TradingFinder', text_color = color.white, text_size = size.small)
    table.merge_cells(Info_Table, 0, 0, 3, 0)
    table.cell(Info_Table, 0, 1, 'Session', text_color = color.white, text_size = size.small)
    table.cell(Info_Table, 1, 1, 'Status', text_color = color.white, text_size = size.small)
    table.cell(Info_Table, 2, 1, 'Start(UTC)', text_color = color.white, text_size = size.small)
    table.cell(Info_Table, 3, 1, 'End(UTC)', text_color = color.white, text_size = size.small)
 
    table.cell(Info_Table, 0, 2, sesasia_text, text_color = sesasia_color, text_size = size.small)
    table.cell(Info_Table, 0, 3, sesSydney_text, text_color = sesSydney_color, text_size = size.small)
    table.cell(Info_Table, 0, 4, sesTokyo_text, text_color = sesTokyo_color, text_size = size.small)   
    table.cell(Info_Table, 0, 5, sesEuro_text, text_color = sesEuro_color, text_size = size.small)
    table.cell(Info_Table, 0, 6, seslondon_text, text_color = seslondon_color, text_size = size.small)
    table.cell(Info_Table, 0, 7, sesNewyork_text, text_color = sesNewyork_color, text_size = size.small)
    table.cell(Info_Table, 1, 2, (On_sesasia ? 'Open' : 'Closed')
      , bgcolor = On_sesasia ? #56a3a6 : #db504a
      , text_color = color.rgb(0, 0, 0)
      , text_size = size.small)
    table.cell(Info_Table, 1, 3, (On_sesSydney ? 'Open' : 'Closed')
      , bgcolor = On_sesSydney ? #56a3a6 : #db504a
      , text_color = color.rgb(0, 0, 0)
      , text_size = size.small)
    table.cell(Info_Table, 1, 4, (On_sesTokyo ? 'Open' : 'Closed')
      , bgcolor = On_sesTokyo ? #56a3a6 : #db504a
      , text_color = color.rgb(0, 0, 0)
      , text_size = size.small)
    table.cell(Info_Table, 1, 5, (On_sesEuro ? 'Open' : 'Closed')
      , bgcolor = On_sesEuro ? #56a3a6 : #db504a
      , text_color = color.rgb(0, 0, 0)
      , text_size = size.small)
    table.cell(Info_Table, 1, 6, (On_seslondon ? 'Open' : 'Closed')
      , bgcolor = On_seslondon ? #56a3a6 : #db504a
      , text_color = color.rgb(0, 0, 0)
      , text_size = size.small)
    table.cell(Info_Table, 1, 7, (On_sesNewyork ? 'Open' : 'Closed')
      , bgcolor = On_sesNewyork ? #56a3a6 : #db504a
      , text_color = color.rgb(0, 0, 0)
      , text_size = size.small)
      
    table.cell(Info_Table, 2, 2, '23:00' , text_color = color.white, text_size = size.small)
    table.cell(Info_Table, 2, 3, '23:00' , text_color = color.white, text_size = size.small)
    table.cell(Info_Table, 2, 4, '00:00' , text_color = color.white, text_size = size.small)   
    table.cell(Info_Table, 2, 5, '07:00' , text_color = color.white, text_size = size.small)
    table.cell(Info_Table, 2, 6, '08:00' , text_color = color.white, text_size = size.small)
    table.cell(Info_Table, 2, 7, '13:00' , text_color = color.white, text_size = size.small)
 
    table.cell(Info_Table, 3, 2, '06:00' , text_color = color.white, text_size = size.small)
    table.cell(Info_Table, 3, 3, '05:00' , text_color = color.white, text_size = size.small)
    table.cell(Info_Table, 3, 4, '06:00' , text_color = color.white, text_size = size.small)   
    table.cell(Info_Table, 3, 5, '16:30' , text_color = color.white, text_size = size.small)
    table.cell(Info_Table, 3, 6, '16:30' , text_color = color.white, text_size = size.small)
    table.cell(Info_Table, 3, 7, '22:00' , text_color = color.white, text_size = size.small)

← 返回列表