本页源码来自 TradingView 公开发布的开源脚本,版权归原作者所有, 请遵循其原始许可(Pine 脚本常见 CC BY-NC-SA / MPL-2.0 / MIT)。 本项目仅用于研究检索与许可范围内的移植。
//@version=6
indicator("Knesset Election Dates | Israel", "Knesset Elections", overlay=true, max_lines_count=50, max_labels_count=50)
// Historical dates: https://main.knesset.gov.il/EN/mk/Pages/Elections.aspx
// Scheduled 26th: https://www.gov.il/he/pages/knesset-elections-2026
showLabels=input.bool(true,"Hebrew labels")
showDates=input.bool(true,"Dates in labels")
showScheduled=input.bool(true,"Scheduled 26th (subject to change)")
lineColor=input.color(color.teal,"Line color")
var years=array.from(1949,1951,1955,1959,1961,1965,1969,1973,1977,1981,1984,1988,1992,1996,1999,2003,2006,2009,2013,2015,2019,2019,2020,2021,2022,2026)
var months=array.from(1,7,7,11,8,11,10,12,5,6,7,11,6,5,5,1,3,2,1,3,4,9,3,3,11,10)
var days=array.from(25,30,26,3,15,2,28,31,17,30,23,1,23,29,17,28,28,10,22,17,9,17,2,23,1,27)
for i=0 to 25
int yy=array.get(years,i)
int mm=array.get(months,i)
int dd=array.get(days,i)
int t=timestamp(syminfo.timezone,yy,mm,dd,0,0)
bool scheduled=i==25
bool crossed=not na(time_close) and time_close>t and (na(time_close[1]) ? time<=t : time_close[1]<=t)
bool drawEvent=scheduled ? (showScheduled and barstate.islast and timenow<t) : crossed
if drawEvent
color c=scheduled?color.orange:lineColor
line.new(t,low,t,high,xloc=xloc.bar_time,extend=extend.both,color=c,style=scheduled?line.style_dashed:line.style_solid)
if showLabels
string n=i==0?"האספה המכוננת (הכנסת ה-1)":"בחירות לכנסת ה-"+str.tostring(i+1)
string s=scheduled?" (מתוכנן)":""
string d=showDates?" · "+str.tostring(dd)+"."+str.tostring(mm)+"."+str.tostring(yy):""
label.new(t,high,n+s+d,xloc=xloc.bar_time,yloc=yloc.abovebar,color=c,style=label.style_label_down,textcolor=color.white,size=size.tiny)