The information provided is of general nature only and does not take into account your personal objectives, financial situations or needs. Before acting on any information provided, you should consider whether the information is suitable for you and your personal circumstances and if necessary, seek appropriate professional advice. All opinions, conclusions, forecasts or recommendations are reasonably held at the time of compilation but are subject to change without notice. Past performance is not an indication of future performance. Go Markets Pty Ltd, ABN 85 081 864 039, AFSL 254963 is a CFD issuer, and trading carries significant risks and is not suitable for everyone. You do not own or have any interest in the rights to the underlying assets. You should consider the appropriateness by reviewing our TMD, FSG, PDS and other CFD legal documents to ensure you understand the risks before you invest in CFDs. These documents are available here.
免责声明:文章来自 GO Markets 分析师和参与者,基于他们的独立分析或个人经验。表达的观点、意见或交易风格仅代表作者个人,不代表 GO Markets 立场。建议,(如有),具有“普遍”性,并非基于您的个人目标、财务状况或需求。在根据建议采取行动之前,请考虑该建议(如有)对您的目标、财务状况和需求的适用程度。如果建议与购买特定金融产品有关,您应该在做出任何决定之前了解并考虑该产品的产品披露声明 (PDS) 和金融服务指南 (FSG)。
韩国银行(Bank of Korea, BOK)货币政策委员会于2026年1月15日决定:将韩国银行基准利率维持在2.50%,并在同一公开材料中载明该决定获得一致通过。韩国银行在决议公告中同时表示:鉴于通胀预计将逐步稳定、经济增长持续改善、且金融稳定风险仍然存在,委员会判断在评估国内外政策环境变化的同时,维持当前利率水平是适当的。
在上一篇文章中,我们已经系统介绍了 Pine Script 中的 for loop,并通过实例说明了它在固定次数遍历、区间计算等场景下的常见用法。不过,在实际策略和指标开发中,并不是所有问题都能提前确定循环次数。有些逻辑需要在“条件满足之前不断执行”,这时 while loop 就显得尤为重要。
while loop 是 Pine Script 中另一种核心循环结构,它基于条件判断来决定是否继续执行代码,而不是依赖预先设定的次数。这使它在动态计算、逐步逼近目标值、状态驱动型逻辑等场景中具有更高的灵活性。当然,也正因为这种灵活性,while loop 在使用时需要格外注意边界条件,否则可能导致脚本超时或编译错误。
本文将在 for loop 的基础上,详细介绍 Pine Script 中 while loop 的语法结构、执行机制及其与 for loop 的关键区别,并结合实际示例,帮助你理解在什么情况下应该选择 while loop,以及如何安全、高效地使用它。
while 循环语句用于创建一个由条件控制的循环,它通过一个条件表达式来控制其本地代码块的执行。只要指定的条件保持为真,循环就会持续迭代。
while 循环的头部会在每一次迭代之前对条件进行求值。因此,当脚本在某次迭代中修改了该条件时,循环头部会在下一次迭代时反映这些变化。
根据循环头部中指定的条件,while 循环的行为可以与 for 循环类似,例如持续迭代直到某个计数变量达到指定的上限。
由于 while 循环 的执行依赖于其条件始终为真,而该条件在某一次特定迭代中可能不会发生变化,因此在循环开始之前,预期的迭代次数往往是无法准确确定的。因此,while 循环通常在无法事先确定精确循环边界的场景中非常有用。
下面的脚本用于跟踪当图表的收盘价突破用户指定长度和通道宽度的 Keltner 通道时的情况。当价格突破当前 K 线的通道范围时,脚本会绘制一个方框,用来高亮显示此前所有连续收盘价仍位于该价格区间内的 K 线。该脚本使用 while 循环来分析历史 K 线的价格,并逐步调整每一个新方框的左边界,直到绘制的区域覆盖当前区间内最新的一组连续 K 线。
10. 检测“首次突破”:当前 K 线价格在通道外,上一根 K 线价格不在通道外。这表示:刚刚发生突破(避免重复画框)。
11. 创建价格窗口 Box:创建一个新的 box 对象:
左边界:bar_index
右边界:bar_index(初始宽度为 0)
上边界:channelHigh
下边界:channelLow
border_width = 2:边框宽度
bgcolor:半透明灰色背景
这个方框将用来标记“价格在通道内的历史区间”。
12. 初始化计数器:定义一个整数变量 i,用于回溯历史 K 线(close[i] 表示第 i 根之前的收盘价)。
13. while 循环:向左扩展方框:只要 第 i 根之前的收盘价仍在当前通道范围内:
close[i] >= channelLow
close[i] <= channelHigh
循环继续执行。
14. 调整方框左边界:将方框的左边界向左移动到:当前 K 线索引 – i,实现“逐根向左扩展方框”。
15. 增加回溯步数:每次循环 i 加 1
16. 绘制通道下轨。
17. 在图表上绘制通道上轨线。
K线上结果呈现如下:
本文通过一个完整的 Pine Script 示例,系统地讲解了 while 循环在 TradingView 指标中的实际应用。脚本以 EMA 与 ATR 构建 Keltner 通道为基础,当价格首次突破通道时创建一个价格窗口方框,并利用 while 循环向左逐根回溯历史 K 线,只要收盘价仍处于当前通道范围内,就不断扩展方框的左边界。相比 for 循环,while 循环不依赖预先确定的迭代次数,更适合用于回溯区间长度不确定的场景。通过这一示例,可以清楚地看到 while 循环在处理“连续条件判断”和“动态边界”问题时的优势,有助于读者在编写更灵活、逻辑更清晰的 Pine Script 脚本时,合理选择和运用循环结构。
FX markets enter an important window with a Federal Reserve policy decision and press conference, US ISM activity data, German inflation releases, China PMIs, and Australian labour figures all due.
Quick facts
The upcoming Fed policy decision and press conference are closely watched for guidance on the potential timing of rate cuts, with implications for US Treasury yields and USD direction.
Broad USD selling has intensified over the last 48 hours. The move has coincided with renewed tariff rhetoric and heightened sensitivity to FX intervention narratives.
ISM Manufacturing PMI is scheduled for Monday, 2 February, with ISM Services PMI on Wednesday, 4 February, providing timely insight into US growth momentum.
German CPI, euro area GDP and unemployment, China PMIs, and Australian labour data provide regional context, particularly for EUR and AUD crosses.
USD/JPY
What to watch
The Federal Reserve decision and subsequent press conference are key events influencing US Treasury yields.
Any shift in tone around inflation progress, economic risks, or rate cut timing expectations may affect yield differentials and near-term USD sensitivity.
Recent broad USD weakness, reinforced by tariff-related headlines and intervention sensitivity, has added downside pressure to the USD.
On the JPY side, Japan inflation signals, including Tokyo CPI, are relevant as indicators of domestic price trends and potential policy direction.
Key releases and events
Thu 30 Jan: Japan Tokyo CPI (January)
Thu 30 Jan: Federal Reserve policy decision and press conference
Mon 2 Feb: US ISM Manufacturing PMI
Wed 4 Feb: US ISM Services PMI
Technical snapshot
USDJPY has broken lower from its recent consolidation zone, with downside range evident over the last 48 hours. Price has moved down to the 200-exponential moving average (EMA) and is testing a level not seen since October 2025.
USDJPY 1-day chart
EUR/USD
What to watch
The Fed decision and press conference may influence EUR/USD primarily through USD moves linked to Treasury yield reactions.
On the EUR side, German CPI will show inflation trends, while euro area flash GDP and unemployment data inform the regional growth outlook.
Key releases and events
Thu 29 Jan: Germany CPI (preliminary)
Thu 29 Jan: Eurozone flash GDP, Q4 2025
Thu 30 Jan: Federal Reserve decision and press conference
Fri 30 Jan: Eurozone unemployment rate
Technical snapshot
EURUSD has extended above a prior resistance level, with expanded daily ranges and strong momentum. Price action in other USD crosses suggests the move may be reflecting USD weakness, rather than a material shift in euro area fundamentals.
EURUSD 1-day chart
EUR/AUD
What to watch
Alongside euro area growth numbers, Australian employment data may influence near-term EUR/AUD sensitivity ahead of the RBA policy decision next week.
China's official PMIs remain relevant, as shifts in Chinese activity expectations can influence AUD via commodity demand and regional risk sentiment.
Key releases and events
Thu 29 Jan: Australia Labour Force, Detailed (Dec 2025), 11:30am AEDT
Fri 31 Jan: China official Manufacturing and Non-Manufacturing PMIs
Tue 4 Feb: RBA policy decision
Technical snapshot
EUR/AUD has decisively broken below its prior support zone, with price now testing levels not seen since April 2025. Momentum remains negative, consistent with a renewed downside phase rather than consolidation.
EURAUD 1-day chart
Bottom line
The Fed decision and press conference, US PMI data, German inflation releases, China PMIs, and Australian labour figures are clustered in a short window.
Markets will be watching whether the USD weakness evident over the last 48 hours extends further.
Expected earnings date: Thursday, 29 January 2026 (US, after market close) / early Friday, 30 January 2026 (AEDT)
Key areas in focus
iPhone
The iPhone remains Apple’s largest revenue driver. Markets are likely to focus on unit demand, product mix (including higher-end models), and any signals on upgrade momentum and regional trends.
Services
Investors are likely to focus on growth across areas such as the App Store, iCloud, Apple Music and other subscriptions, alongside any commentary on average revenue per user (ARPU). The size and engagement of Apple’s installed base remain central to overall performance.
Wearables, home and accessories
This segment includes products such as Apple Watch, AirPods, Beats headphones, home-related devices, and accessories. Investors are likely to watch revenue trends in this segment as an indicator of discretionary consumer demand.
Cost and margin framework
Management has flagged tariff and component cost pressures in prior commentary. Markets may remain sensitive to gross margin commentary and any signals of incremental cost pressure or mitigation strategies.
What happened last quarter
Apple’s most recent quarterly update (fiscal Q4 2025) highlighted record September-quarter revenue and EPS, alongside record Services revenue and continued emphasis on installed-base strength.
The prior update also included discussion of holiday-quarter expectations and cost headwinds (including tariffs), which have influenced expected margins and management guidance.
Last earnings key highlights
Revenue: US$102.5 billion
Earnings per share (EPS): US$1.85 (diluted)
iPhone revenue: US$49.03 billion
Services revenue: US$28.75 billion
Net income: US$27.5 billion
How the market reacted last time
Apple shares rose in after-hours trading following the release, as investors assessed the results against analyst expectations and management’s holiday-quarter commentary, including tariff-related cost pressures and regional demand considerations.
Apple 2025 business highlights
What’s expected this quarter
Bloomberg consensus points to year-on-year EPS growth, with markets also focused on the revenue outcome and gross margins, given the scale and importance of the holiday quarter for Apple’s earnings profile.
Sentiment around Apple may be sensitive to any disappointment on holiday-quarter revenue, Services momentum, or margin commentary, given the stock’s large index weight and the importance of this reporting period.
Listed options were implying an indicative move of around ±3% to ±4% based on near-dated, at-the-money options-implied expected move estimates observed on Barchart at 11:00 am AEDT on 25 January 2026. Implied volatility was approximately 29% annualised at that time.
These are market-implied estimates (not a forecast) and may change. Actual post-earnings price moves can be larger or smaller.
What this means for Australian traders
Apple’s earnings can influence near-term sentiment across major US equity indices, particularly Nasdaq-linked products, with potential spillover into the Asia session following the release.
Important risk note
Immediately after the US close and into the early Asia session, Nasdaq 100 (NDX) futures and related CFD pricing can reflect thinner liquidity, wider spreads, and sharper repricing around new information.
Such an environment can increase gap risk and execution uncertainty relative to regular-hours conditions.