OPEN-SOURCE SCRIPT
Sav Fx Dynamic P & D°

//version=5
indicator("Sav Fx Dynamic P & D°", overlay = true, max_boxes_count = 50, max_labels_count = 2, max_lines_count = 10)
// Global Settings (visible)
customLineColor = input.color(#000000, "True Open", group = "Global Settings")
// Input for custom sessionTypeText size and width
sessionTypeTextSize = input.string("small", "Session Type Text Size", options=["tiny", "small", "normal", "large"], group="Text Settings")
// On/Off switches for each open line
show90MinuteCycleOpen = input.bool(true, "90 Minute Cycle Open", group="Open Lines")
showTrueNewYorkOpen = input.bool(true, "True New York Open", group="Open Lines")
showTrueDayOpen = input.bool(true, "True Day Open", group="Open Lines")
showTrueWeekOpen = input.bool(true, "True Week Open", group="Open Lines")
showTrueMonthOpen = input.bool(false, "True Month Open", group="Open Lines")
IsTime(h, m, timezone) =>
not na(time) and hour(time, timezone) == h and minute(time, timezone) == m
IsSession(sess, timezone) =>
not na(time(timeframe.period, sess, timezone))
is6_00Session = IsSession("0600-0730", "America/New_York")
is7_30Session = IsSession("0730-0900", "America/New_York")
is9_00Session = IsSession("0900-1030", "America/New_York")
is10_30Session = IsSession("1030-1200", "America/New_York")
var MOPLine = line.new(na, na, na, na, color = customLineColor, width = 1, style = line.style_dashed)
var MOPLabel = label.new(na, na, text = "True Day Open", color = color.rgb(120, 123, 134, 100), textcolor = customLineColor, size = size.small, style = label.style_label_left)
var float trueDayOpen = na
if showTrueDayOpen
if IsTime(0, 0, "America/New_York")
line.set_xy1(MOPLine, bar_index, open)
line.set_xy2(MOPLine, bar_index, open)
label.set_xy(MOPLabel, bar_index, open)
trueDayOpen := open
if barstate.islast
line.set_x2(MOPLine, bar_index + 20)
label.set_x(MOPLabel, bar_index + 20)
else
line.delete(MOPLine)
label.delete(MOPLabel)
var NYTrueOpenLine = line.new(na, na, na, na, color = customLineColor, width = 1, style = line.style_dashed)
var NYTrueOpenLabel = label.new(na, na, text = "True New York Open", color = color.rgb(105, 130, 218, 100), textcolor = customLineColor, size = size.small, style = label.style_label_left)
var float NYTrueOpen = na
if showTrueNewYorkOpen
if IsTime(1, 30, "America/New_York") or IsTime(7, 30, "America/New_York") or IsTime(13, 30, "America/New_York")
line.set_xy1(NYTrueOpenLine, bar_index, open)
line.set_xy2(NYTrueOpenLine, bar_index, open)
label.set_xy(NYTrueOpenLabel, bar_index, open)
NYTrueOpen := open
if IsTime(1, 30, "America/New_York")
label.set_text(NYTrueOpenLabel, "True London Open")
if IsTime(7, 30, "America/New_York")
label.set_text(NYTrueOpenLabel, "True New York Open")
if IsTime(13, 30, "America/New_York")
label.set_text(NYTrueOpenLabel, "True PM Session Open")
if barstate.islast
line.set_x2(NYTrueOpenLine, bar_index + 20)
label.set_x(NYTrueOpenLabel, bar_index + 20)
else
line.delete(NYTrueOpenLine)
label.delete(NYTrueOpenLabel)
var lookahead_bars = 20
var MondayLine = line.new(na, na, na, na, color = customLineColor, width = 1, style = line.style_dashed)
var MondayLabel = label.new(na, na, text = timeframe.isintraday and timeframe.multiplier >= 5 ? "True week Open" : "", color = #9b27b000, textcolor = customLineColor, size = size.small, style = label.style_label_left)
if showTrueWeekOpen
if dayofweek == dayofweek.monday and IsTime(18, 0, "America/New_York")
line.set_xy1(MondayLine, bar_index, close)
line.set_xy2(MondayLine, bar_index, close)
label.set_xy(MondayLabel, bar_index, close)
if barstate.islast
line.set_x2(MondayLine, bar_index + lookahead_bars)
label.set_x(MondayLabel, bar_index + lookahead_bars)
else
line.delete(MondayLine)
label.delete(MondayLabel)
var ninetyMinuteCycleLine = line.new(na, na, na, na, color = customLineColor, width = 1, style = line.style_dashed)
var ninetyMinuteCycleLabel = label.new(na, na, text = "90 Minute Cycle True Open", color = #4caf4f00, textcolor = customLineColor, size = size.small, style = label.style_label_left)
if show90MinuteCycleOpen
if IsTime(3, 23, "America/New_York") or IsTime(9, 23, "America/New_York") or IsTime(15, 23, "America/New_York")
line.set_xy1(ninetyMinuteCycleLine, bar_index, open)
line.set_xy2(ninetyMinuteCycleLine, bar_index, open)
label.set_xy(ninetyMinuteCycleLabel, bar_index, open)
if IsTime(3, 23, "America/New_York")
label.set_text(ninetyMinuteCycleLabel, "03:23 Cycle True Open")
if IsTime(9, 23, "America/New_York")
label.set_text(ninetyMinuteCycleLabel, "09:23 Cycle True Open")
if IsTime(15, 23, "America/New_York")
label.set_text(ninetyMinuteCycleLabel, "15:23 Cycle True Open")
if barstate.islast
line.set_x2(ninetyMinuteCycleLine, bar_index + lookahead_bars)
label.set_x(ninetyMinuteCycleLabel, bar_index + lookahead_bars)
else
line.delete(ninetyMinuteCycleLine)
label.delete(ninetyMinuteCycleLabel)
var monthOpenLine = line.new(na, na, na, na, color = customLineColor, width = 1, style = line.style_dashed)
var monthOpenLabel = label.new(na, na, text = "True Month Open", color = #ff990000, textcolor = customLineColor, size = size.small, style = label.style_label_left)
isSecondWeekSunday = dayofweek == dayofweek.sunday and (dayofmonth >= 8 and dayofmonth <= 14)
if showTrueMonthOpen
if isSecondWeekSunday and IsTime(18,0, "America/New_York")
line.set_xy1(monthOpenLine, bar_index, close)
line.set_xy2(monthOpenLine, bar_index + lookahead_bars, close)
label.set_xy(monthOpenLabel, bar_index, close)
if barstate.islast
line.set_x2(monthOpenLine, bar_index + lookahead_bars)
label.set_x(monthOpenLabel, bar_index + lookahead_bars)
else
line.delete(monthOpenLine)
label.delete(monthOpenLabel)
directionalBias = "N/A"
if is6_00Session or is7_30Session or is9_00Session or is10_30Session
directionalBias := open > NYTrueOpen ? "Bullish" : "Bearish"
var directionalBiasLabel = label.new(na, na, text = "Directional Bias: " + directionalBias, color = na, textcolor = customLineColor, size = size.normal, style = label.style_label_left)
if barstate.islast
label.set_x(directionalBiasLabel, bar_index + lookahead_bars)
label.set_text(directionalBiasLabel, "Directional Bias: " + directionalBias)
var float WeekOpen = na
if dayofweek == dayofweek.monday and IsTime(18, 0, "America/New_York")
WeekOpen := close
if showTrueWeekOpen
line.set_xy1(MondayLine, bar_index, close)
line.set_xy2(MondayLine, bar_index, close)
label.set_xy(MondayLabel, bar_index, close)
// New table for static session type display
var sessionTable = table.new(position.bottom_right, 1, 1, bgcolor = #b9b9bab8)
// Update the table.cell function call
if barstate.islast and not na(trueDayOpen) and not na(NYTrueOpen) and not na(WeekOpen)
var string sessionTypeText = syminfo.ticker + " Dead Zone"
var color sessionColor = color.rgb(126, 126, 126, 65)
// Check conditions and set session type text and color accordingly
if close < trueDayOpen and close < NYTrueOpen and close < WeekOpen
sessionTypeText := syminfo.ticker + " Week Discount"
sessionColor := #ba4b4b59
else if close > trueDayOpen and close > NYTrueOpen and close > WeekOpen
sessionTypeText := syminfo.ticker + " Week Premium"
sessionColor := #4b56ba5a
else if close < trueDayOpen and close < NYTrueOpen and close > WeekOpen
sessionTypeText := syminfo.ticker + " Day Discount & Week Dead Zone"
sessionColor := #ba4b4b59
else if close > trueDayOpen and close > NYTrueOpen and close < WeekOpen
sessionTypeText := syminfo.ticker + " Day premium & Week Dead Zone"
sessionColor := #4b56ba5a
// Using only size input for session type text
table.cell(sessionTable, 0, 0, sessionTypeText, bgcolor = sessionColor, text_color = color.black, text_size = sessionTypeTextSize)
indicator("Sav Fx Dynamic P & D°", overlay = true, max_boxes_count = 50, max_labels_count = 2, max_lines_count = 10)
// Global Settings (visible)
customLineColor = input.color(#000000, "True Open", group = "Global Settings")
// Input for custom sessionTypeText size and width
sessionTypeTextSize = input.string("small", "Session Type Text Size", options=["tiny", "small", "normal", "large"], group="Text Settings")
// On/Off switches for each open line
show90MinuteCycleOpen = input.bool(true, "90 Minute Cycle Open", group="Open Lines")
showTrueNewYorkOpen = input.bool(true, "True New York Open", group="Open Lines")
showTrueDayOpen = input.bool(true, "True Day Open", group="Open Lines")
showTrueWeekOpen = input.bool(true, "True Week Open", group="Open Lines")
showTrueMonthOpen = input.bool(false, "True Month Open", group="Open Lines")
IsTime(h, m, timezone) =>
not na(time) and hour(time, timezone) == h and minute(time, timezone) == m
IsSession(sess, timezone) =>
not na(time(timeframe.period, sess, timezone))
is6_00Session = IsSession("0600-0730", "America/New_York")
is7_30Session = IsSession("0730-0900", "America/New_York")
is9_00Session = IsSession("0900-1030", "America/New_York")
is10_30Session = IsSession("1030-1200", "America/New_York")
var MOPLine = line.new(na, na, na, na, color = customLineColor, width = 1, style = line.style_dashed)
var MOPLabel = label.new(na, na, text = "True Day Open", color = color.rgb(120, 123, 134, 100), textcolor = customLineColor, size = size.small, style = label.style_label_left)
var float trueDayOpen = na
if showTrueDayOpen
if IsTime(0, 0, "America/New_York")
line.set_xy1(MOPLine, bar_index, open)
line.set_xy2(MOPLine, bar_index, open)
label.set_xy(MOPLabel, bar_index, open)
trueDayOpen := open
if barstate.islast
line.set_x2(MOPLine, bar_index + 20)
label.set_x(MOPLabel, bar_index + 20)
else
line.delete(MOPLine)
label.delete(MOPLabel)
var NYTrueOpenLine = line.new(na, na, na, na, color = customLineColor, width = 1, style = line.style_dashed)
var NYTrueOpenLabel = label.new(na, na, text = "True New York Open", color = color.rgb(105, 130, 218, 100), textcolor = customLineColor, size = size.small, style = label.style_label_left)
var float NYTrueOpen = na
if showTrueNewYorkOpen
if IsTime(1, 30, "America/New_York") or IsTime(7, 30, "America/New_York") or IsTime(13, 30, "America/New_York")
line.set_xy1(NYTrueOpenLine, bar_index, open)
line.set_xy2(NYTrueOpenLine, bar_index, open)
label.set_xy(NYTrueOpenLabel, bar_index, open)
NYTrueOpen := open
if IsTime(1, 30, "America/New_York")
label.set_text(NYTrueOpenLabel, "True London Open")
if IsTime(7, 30, "America/New_York")
label.set_text(NYTrueOpenLabel, "True New York Open")
if IsTime(13, 30, "America/New_York")
label.set_text(NYTrueOpenLabel, "True PM Session Open")
if barstate.islast
line.set_x2(NYTrueOpenLine, bar_index + 20)
label.set_x(NYTrueOpenLabel, bar_index + 20)
else
line.delete(NYTrueOpenLine)
label.delete(NYTrueOpenLabel)
var lookahead_bars = 20
var MondayLine = line.new(na, na, na, na, color = customLineColor, width = 1, style = line.style_dashed)
var MondayLabel = label.new(na, na, text = timeframe.isintraday and timeframe.multiplier >= 5 ? "True week Open" : "", color = #9b27b000, textcolor = customLineColor, size = size.small, style = label.style_label_left)
if showTrueWeekOpen
if dayofweek == dayofweek.monday and IsTime(18, 0, "America/New_York")
line.set_xy1(MondayLine, bar_index, close)
line.set_xy2(MondayLine, bar_index, close)
label.set_xy(MondayLabel, bar_index, close)
if barstate.islast
line.set_x2(MondayLine, bar_index + lookahead_bars)
label.set_x(MondayLabel, bar_index + lookahead_bars)
else
line.delete(MondayLine)
label.delete(MondayLabel)
var ninetyMinuteCycleLine = line.new(na, na, na, na, color = customLineColor, width = 1, style = line.style_dashed)
var ninetyMinuteCycleLabel = label.new(na, na, text = "90 Minute Cycle True Open", color = #4caf4f00, textcolor = customLineColor, size = size.small, style = label.style_label_left)
if show90MinuteCycleOpen
if IsTime(3, 23, "America/New_York") or IsTime(9, 23, "America/New_York") or IsTime(15, 23, "America/New_York")
line.set_xy1(ninetyMinuteCycleLine, bar_index, open)
line.set_xy2(ninetyMinuteCycleLine, bar_index, open)
label.set_xy(ninetyMinuteCycleLabel, bar_index, open)
if IsTime(3, 23, "America/New_York")
label.set_text(ninetyMinuteCycleLabel, "03:23 Cycle True Open")
if IsTime(9, 23, "America/New_York")
label.set_text(ninetyMinuteCycleLabel, "09:23 Cycle True Open")
if IsTime(15, 23, "America/New_York")
label.set_text(ninetyMinuteCycleLabel, "15:23 Cycle True Open")
if barstate.islast
line.set_x2(ninetyMinuteCycleLine, bar_index + lookahead_bars)
label.set_x(ninetyMinuteCycleLabel, bar_index + lookahead_bars)
else
line.delete(ninetyMinuteCycleLine)
label.delete(ninetyMinuteCycleLabel)
var monthOpenLine = line.new(na, na, na, na, color = customLineColor, width = 1, style = line.style_dashed)
var monthOpenLabel = label.new(na, na, text = "True Month Open", color = #ff990000, textcolor = customLineColor, size = size.small, style = label.style_label_left)
isSecondWeekSunday = dayofweek == dayofweek.sunday and (dayofmonth >= 8 and dayofmonth <= 14)
if showTrueMonthOpen
if isSecondWeekSunday and IsTime(18,0, "America/New_York")
line.set_xy1(monthOpenLine, bar_index, close)
line.set_xy2(monthOpenLine, bar_index + lookahead_bars, close)
label.set_xy(monthOpenLabel, bar_index, close)
if barstate.islast
line.set_x2(monthOpenLine, bar_index + lookahead_bars)
label.set_x(monthOpenLabel, bar_index + lookahead_bars)
else
line.delete(monthOpenLine)
label.delete(monthOpenLabel)
directionalBias = "N/A"
if is6_00Session or is7_30Session or is9_00Session or is10_30Session
directionalBias := open > NYTrueOpen ? "Bullish" : "Bearish"
var directionalBiasLabel = label.new(na, na, text = "Directional Bias: " + directionalBias, color = na, textcolor = customLineColor, size = size.normal, style = label.style_label_left)
if barstate.islast
label.set_x(directionalBiasLabel, bar_index + lookahead_bars)
label.set_text(directionalBiasLabel, "Directional Bias: " + directionalBias)
var float WeekOpen = na
if dayofweek == dayofweek.monday and IsTime(18, 0, "America/New_York")
WeekOpen := close
if showTrueWeekOpen
line.set_xy1(MondayLine, bar_index, close)
line.set_xy2(MondayLine, bar_index, close)
label.set_xy(MondayLabel, bar_index, close)
// New table for static session type display
var sessionTable = table.new(position.bottom_right, 1, 1, bgcolor = #b9b9bab8)
// Update the table.cell function call
if barstate.islast and not na(trueDayOpen) and not na(NYTrueOpen) and not na(WeekOpen)
var string sessionTypeText = syminfo.ticker + " Dead Zone"
var color sessionColor = color.rgb(126, 126, 126, 65)
// Check conditions and set session type text and color accordingly
if close < trueDayOpen and close < NYTrueOpen and close < WeekOpen
sessionTypeText := syminfo.ticker + " Week Discount"
sessionColor := #ba4b4b59
else if close > trueDayOpen and close > NYTrueOpen and close > WeekOpen
sessionTypeText := syminfo.ticker + " Week Premium"
sessionColor := #4b56ba5a
else if close < trueDayOpen and close < NYTrueOpen and close > WeekOpen
sessionTypeText := syminfo.ticker + " Day Discount & Week Dead Zone"
sessionColor := #ba4b4b59
else if close > trueDayOpen and close > NYTrueOpen and close < WeekOpen
sessionTypeText := syminfo.ticker + " Day premium & Week Dead Zone"
sessionColor := #4b56ba5a
// Using only size input for session type text
table.cell(sessionTable, 0, 0, sessionTypeText, bgcolor = sessionColor, text_color = color.black, text_size = sessionTypeTextSize)
Script open-source
Dans l'esprit TradingView, le créateur de ce script l'a rendu open source afin que les traders puissent examiner et vérifier ses fonctionnalités. Bravo à l'auteur! Bien que vous puissiez l'utiliser gratuitement, n'oubliez pas que la republication du code est soumise à nos Règles.
Clause de non-responsabilité
Les informations et publications ne sont pas destinées à être, et ne constituent pas, des conseils ou recommandations financiers, d'investissement, de trading ou autres fournis ou approuvés par TradingView. Pour en savoir plus, consultez les Conditions d'utilisation.
Script open-source
Dans l'esprit TradingView, le créateur de ce script l'a rendu open source afin que les traders puissent examiner et vérifier ses fonctionnalités. Bravo à l'auteur! Bien que vous puissiez l'utiliser gratuitement, n'oubliez pas que la republication du code est soumise à nos Règles.
Clause de non-responsabilité
Les informations et publications ne sont pas destinées à être, et ne constituent pas, des conseils ou recommandations financiers, d'investissement, de trading ou autres fournis ou approuvés par TradingView. Pour en savoir plus, consultez les Conditions d'utilisation.