OPEN-SOURCE SCRIPT
USD Session 8FX - LDN & NY (TF-invariant, Live + Table)

What changed
Flexible session window
Removed the old fixed NY end-time selector.
Added new inputs so you can pick start time and length:
London: ldnStartSel (default 08:00) and ldnLenSel with options 45/60/90 minutes.
New York: nyStartSel (default 15:30) and nyLenSel with options 45/60/90 minutes.
The session string used by time(refTF, sess, tz) is now built dynamically as "HHMM-HHMM" from start + length (e.g., 1530-1630).
The label shown in the table (winTxt) auto-formats to HH:MM–HH:MM.
New time helpers
addMinutesHHMM() computes the end time from a "HHMM" start plus a minute length.
makeSess() produces the session string "HHMM-HHMM".
prettySess() converts "HHMM-HHMM" → "HH:MM-HH:MM".
(Kept on one line to avoid the “end of line without line continuation” error.)
Stability & UI fixes
Main table now uses table.new(f_pos(tablePos), ...) directly (no undeclared pos variable).
Trade Gate panel uses a properly initialized gatePosEnum before table.new(...) (fixes “Undeclared identifier”).
Minor cleanups; no logic changes.
What did NOT change
Scoring logic: returns → optional ATR normalization → weights → anti-USD vs USD-base averages → final score.
Thresholds: minAbsScore and live intrath alerts are unchanged.
VWAP Gate logic is the same (price vs VWAP consistency depending on USD Strong/Weak).
Freeze/Lock of values at session end is unchanged.
Alerts (session close bias, live threshold cross, and “Entry hint”) are unchanged.
Why this helps (practical impact)
Longer windows (e.g., NY 60/90, LDN 60/90) usually make the score more robust, filtering noise and reducing false signals—at the cost of a slightly slower signal.
You can now A/B test:
London: 45 vs 60 vs 90
New York: 45 vs 60 vs 90
without touching anything else; the indicator adapts automatically.
How to use
Choose Session (London / New York).
Set the start and length for that session.
The background highlight, the winTxt, and the entry/exit logic all follow the dynamic window.
Quick tips to reduce false signals
Try NY 60 or NY 90 and LDN 60 when volatility is choppy.
Keep ATR normalization ON (useATRnorm = true) for more comparable returns.
Consider raising minAbsScore slightly (e.g., from 0.12 → 0.15–0.20) if you still see noise.
Use the VWAP Gate panel: only act when Bias OK and at least one of the Top-3 pairs shows VWAP OK.
If you want, I can add quick presets (buttons) to jump between LDN 45/60/90 and NY 45/60/90, or plot two Scores side by side for direct comparison.
Flexible session window
Removed the old fixed NY end-time selector.
Added new inputs so you can pick start time and length:
London: ldnStartSel (default 08:00) and ldnLenSel with options 45/60/90 minutes.
New York: nyStartSel (default 15:30) and nyLenSel with options 45/60/90 minutes.
The session string used by time(refTF, sess, tz) is now built dynamically as "HHMM-HHMM" from start + length (e.g., 1530-1630).
The label shown in the table (winTxt) auto-formats to HH:MM–HH:MM.
New time helpers
addMinutesHHMM() computes the end time from a "HHMM" start plus a minute length.
makeSess() produces the session string "HHMM-HHMM".
prettySess() converts "HHMM-HHMM" → "HH:MM-HH:MM".
(Kept on one line to avoid the “end of line without line continuation” error.)
Stability & UI fixes
Main table now uses table.new(f_pos(tablePos), ...) directly (no undeclared pos variable).
Trade Gate panel uses a properly initialized gatePosEnum before table.new(...) (fixes “Undeclared identifier”).
Minor cleanups; no logic changes.
What did NOT change
Scoring logic: returns → optional ATR normalization → weights → anti-USD vs USD-base averages → final score.
Thresholds: minAbsScore and live intrath alerts are unchanged.
VWAP Gate logic is the same (price vs VWAP consistency depending on USD Strong/Weak).
Freeze/Lock of values at session end is unchanged.
Alerts (session close bias, live threshold cross, and “Entry hint”) are unchanged.
Why this helps (practical impact)
Longer windows (e.g., NY 60/90, LDN 60/90) usually make the score more robust, filtering noise and reducing false signals—at the cost of a slightly slower signal.
You can now A/B test:
London: 45 vs 60 vs 90
New York: 45 vs 60 vs 90
without touching anything else; the indicator adapts automatically.
How to use
Choose Session (London / New York).
Set the start and length for that session.
The background highlight, the winTxt, and the entry/exit logic all follow the dynamic window.
Quick tips to reduce false signals
Try NY 60 or NY 90 and LDN 60 when volatility is choppy.
Keep ATR normalization ON (useATRnorm = true) for more comparable returns.
Consider raising minAbsScore slightly (e.g., from 0.12 → 0.15–0.20) if you still see noise.
Use the VWAP Gate panel: only act when Bias OK and at least one of the Top-3 pairs shows VWAP OK.
If you want, I can add quick presets (buttons) to jump between LDN 45/60/90 and NY 45/60/90, or plot two Scores side by side for direct comparison.
开源脚本
本着TradingView的真正精神,此脚本的创建者将其开源,以便交易者可以查看和验证其功能。向作者致敬!虽然您可以免费使用它,但请记住,重新发布代码必须遵守我们的网站规则。
免责声明
这些信息和出版物并不意味着也不构成TradingView提供或认可的金融、投资、交易或其它类型的建议或背书。请在使用条款阅读更多信息。
开源脚本
本着TradingView的真正精神,此脚本的创建者将其开源,以便交易者可以查看和验证其功能。向作者致敬!虽然您可以免费使用它,但请记住,重新发布代码必须遵守我们的网站规则。
免责声明
这些信息和出版物并不意味着也不构成TradingView提供或认可的金融、投资、交易或其它类型的建议或背书。请在使用条款阅读更多信息。