免责声明:GO Markets 分析师或外部发言人提供的信息基于其独立分析或个人经验。所表达的观点或交易风格仅代表其个人;并不代表 GO Markets 的观点或立场。
联系方式:
墨尔本 03 8658 0603
悉尼 02 9188 0418
中国地区(中文) 400 120 8537中国地区(英文) +248 4 671 903
作者:
Alena Wang | GO Markets 墨尔本中文部
By
Alena Wang
GO Markets 墨尔本中文部
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)。
在 Pine Script 中,for 循环是一种非常重要且高频使用的控制结构,主要用于在脚本中执行重复、可控次数的计算或操作。无论是遍历数组、逐项计算指标,还是在指定范围内生成图形元素,for 循环都能让代码更加简洁、高效和可读。与简单的条件判断不同,for 循环通过计数器精确控制迭代次数,使开发者能够清楚地掌握脚本的执行流程。理解 for 循环的语法结构、执行机制以及与 continue、break 等关键字的配合方式,是掌握 Pine Script 进阶编程的关键一步。本文将从基础概念入手,结合示例,系统地介绍 Pine Script 中 for 循环的用法与注意事项。
for 循环语句用于创建一种计数控制型循环,它通过一个计数器变量来管理其局部代码块的重复执行。计数器从预先定义的初始值开始,在每次迭代结束后按固定的步长递增或递减。当计数器达到指定的最终值时,循环停止迭代。
在 Pine Script 中,for 循环使用以下语法来定义:
[variables = | :=] for counter = from_num to to_num [by step_num]
下面这个简单的脚本演示了一个 for 循环:在最后一根历史 K 线执行脚本时,循环会在未来的柱索引位置绘制多个标签。该循环的计数器从 0 开始,每次增加 1,直到达到 10,此时执行最后一次迭代。
下面对这段 Pine Script 代码进行逐行解析。
声明这是一个指标脚本,并将指标名称设置为for loop example 1。该名称会显示在 TradingView 的指标列表和图表上。
设置一个条件判断语句,barstate.islastconfirmedhistory 在最后一根已确认的历史 K 线上返回 true。这样可以确保后面的代码只执行一次,避免在每根 K 线上重复创建标签。
定义一个 for 循环。计数器变量 i 从 0 开始,每次递增 1,直到 10 为止,一共执行 11 次迭代。
bar_index + i:标签绘制在当前 K 线之后第 i 根柱子的位置
0:标签在价格轴上的 y 坐标
str.tostring(i):将当前计数器 i 转换为字符串,作为标签文本
textcolor = color.white:设置文字颜色为白色
size = size.large:设置文字大小为大号
下面再举一个复杂一点的例子,下面的脚本用于计算并绘制 开盘价的成交量加权移动平均线(VWMA),计算范围为指定数量的 K 线。随后,脚本使用一个向下计数的 for 循环,将最后一根历史 K 线的数值与之前各根 K 线的数值进行比较,比较过程从所设定回看窗口中最早的一根 K 线开始。在每一次循环迭代中,脚本都会获取某一根过去 K 线的 vwmaOpen 值,计算它与当前 K 线数值之间的差值,并在该历史 K 线的开盘价位置通过标签显示计算结果。
最终效果如上所示:在主图中,脚本会对过去 15 根 K 线逐一计算其 VWMA 历史值与当前 VWMA 值之间的差异,并将结果以标签形式直接标注在对应的 K 线位置上。
本文围绕 Pine Script 中的 for 循环 展开,介绍了其基本语法、计数方式以及在实际指标中的应用。通过 VWMA 示例,演示了如何利用 for 循环回看历史 K 线、逐一计算并对比数据,并将结果直观地展示在主图上。同时,也指出了 overlay = true、barstate.islastconfirmedhistory 等常见但关键的细节问题。掌握 for 循环的正确用法,有助于编写更高效、清晰且可维护的 Pine Script 指标代码。
在 Pine Script 中,for 循环是一种非常重要且高频使用的控制结构,主要用于在脚本中执行重复、可控次数的计算或操作。无论是遍历数组、逐项计算指标,还是在指定范围内生成图形元素,for 循环都能让代码更加简洁、高效和可读。与简单的条件判断不同,for 循环通过计数器精确控制迭代次数,使开发者能够清楚地掌握脚本的执行流程。理解 for 循环的语法结构、执行机制以及与 continue、break 等关键字的配合方式,是掌握 Pine Script 进阶编程的关键一步。本文将从基础概念入手,结合示例,系统地介绍 Pine Script 中 for 循环的用法与注意事项。
for 循环语句用于创建一种计数控制型循环,它通过一个计数器变量来管理其局部代码块的重复执行。计数器从预先定义的初始值开始,在每次迭代结束后按固定的步长递增或递减。当计数器达到指定的最终值时,循环停止迭代。
在 Pine Script 中,for 循环使用以下语法来定义:
[variables = | :=] for counter = from_num to to_num [by step_num]
下面这个简单的脚本演示了一个 for 循环:在最后一根历史 K 线执行脚本时,循环会在未来的柱索引位置绘制多个标签。该循环的计数器从 0 开始,每次增加 1,直到达到 10,此时执行最后一次迭代。
下面对这段 Pine Script 代码进行逐行解析。
声明这是一个指标脚本,并将指标名称设置为for loop example 1。该名称会显示在 TradingView 的指标列表和图表上。
设置一个条件判断语句,barstate.islastconfirmedhistory 在最后一根已确认的历史 K 线上返回 true。这样可以确保后面的代码只执行一次,避免在每根 K 线上重复创建标签。
定义一个 for 循环。计数器变量 i 从 0 开始,每次递增 1,直到 10 为止,一共执行 11 次迭代。
bar_index + i:标签绘制在当前 K 线之后第 i 根柱子的位置
0:标签在价格轴上的 y 坐标
str.tostring(i):将当前计数器 i 转换为字符串,作为标签文本
textcolor = color.white:设置文字颜色为白色
size = size.large:设置文字大小为大号
下面再举一个复杂一点的例子,下面的脚本用于计算并绘制 开盘价的成交量加权移动平均线(VWMA),计算范围为指定数量的 K 线。随后,脚本使用一个向下计数的 for 循环,将最后一根历史 K 线的数值与之前各根 K 线的数值进行比较,比较过程从所设定回看窗口中最早的一根 K 线开始。在每一次循环迭代中,脚本都会获取某一根过去 K 线的 vwmaOpen 值,计算它与当前 K 线数值之间的差值,并在该历史 K 线的开盘价位置通过标签显示计算结果。
最终效果如上所示:在主图中,脚本会对过去 15 根 K 线逐一计算其 VWMA 历史值与当前 VWMA 值之间的差异,并将结果以标签形式直接标注在对应的 K 线位置上。
本文围绕 Pine Script 中的 for 循环 展开,介绍了其基本语法、计数方式以及在实际指标中的应用。通过 VWMA 示例,演示了如何利用 for 循环回看历史 K 线、逐一计算并对比数据,并将结果直观地展示在主图上。同时,也指出了 overlay = true、barstate.islastconfirmedhistory 等常见但关键的细节问题。掌握 for 循环的正确用法,有助于编写更高效、清晰且可维护的 Pine Script 指标代码。
January’s market action often matters more than simply marking the opening of the calendar year. Institutional positioning resets, testing of economic assumptions, and early price moves reflect how market participants interpret the first meaningful signals of the year.
While January rarely determines full-year outcomes, it frequently shapes the narratives markets carry into the first quarter (Q1).
Four critical levers: growth, labour, inflation, and policy, can provide an early indication of how markets are processing and prioritising incoming information.
Growth: manufacturing PMIs
January’s first growth test comes from the manufacturing surveys, with markets watching whether signals from S&P Global Manufacturing PMI and ISM Manufacturing PMI tell a consistent story.
Key dates:
ISM Manufacturing PMI: 5 January, 10:00 AM (ET)/ 6 January, 1:00 AM (AEDT)
What markets look for:
Attention often centres on new orders as a forward-looking indicator of demand, alongside prices paid for early insight into cost pressures.
Broad strength across both surveys would support the narrative that the growth momentum seen toward the end of 2025 may extend into early 2026, easing some concerns about a sharper slowdown. Weaker or conflicting readings would keep the growth outlook uncertain, rather than decisively negative.
How it tends to show up in markets:
Firmer growth signals often appear first in higher short-dated Treasury yields. Rising yields can tighten financial conditions, weigh on equity valuations, and support the USD, with spillover effects across foreign exchange (FX) and commodity markets.
Labour: job openings and payrolls
While early-January Non-Farm Payrolls (NFP) often drive short-term volatility, JOLTS job openings may be more influential in shaping January’s policy narrative.
Key dates:
JOLTS Job Openings: 7 January, 10:00 AM (ET)/ 8 January, 1:00 AM (AEDT)
Non-Farm Payrolls (NFP): 9 January, 8:30 AM (ET)/ 10 January, 12:30 AM (AEDT)
What markets look for:
Markets often treat JOLTS as a clearer indicator of underlying labour demand than month-to-month hiring flows.
A continued drift lower in openings would support the view that labour demand is easing in an orderly way, reinforcing confidence that inflation pressures can continue to moderate. A rebound or stalled decline would suggest labour conditions remain firmer than expected.
Market sensitivities:
For markets, easing labour demand typically supports lower short-dated yields and a softer USD, while persistent tightness can push yields higher, strengthen the USD, and increase volatility across rate-sensitive assets.
Inflation: PPI and CPI
Key Dates:
PPI: 14 January, 8:30 AM (ET)/ 15 January, 12:30 AM (AEDT)
CPI (December 2025 data): 15 January, 8:30 AM (ET)/ 16 January, 12:30 AM (AEDT)
The inflation signal can be read as a pipeline from producer prices to consumer inflation. Markets are watching whether producer-level cost pressures continue to fade or begin to re-emerge.
What markets look for:
Core PPI, particularly services-linked components, provides an early indication of cost momentum. Core CPI breadth may help determine whether inflation is continuing to cool or showing signs of persistence.
A softer pipeline would reinforce confidence that disinflation can extend into early 2026, increasing the scope for a potential March policy adjustment. Stickier CPI readings above 3% would raise questions about the durability of recent progress.
How rates and the USD often react
Market reaction tends to be led by yields. Cooling inflation pressure usually pulls short-dated yields lower and softens the USD, while persistent inflation risks can push yields higher and tighten financial conditions.
Policy: January FOMC meeting
By the time the Federal Reserve meets at the end of January, markets will have processed the early growth, labour, and inflation signals of the year.
A policy change is unlikely this month, but how those signals are framed in the statement and press conference still matters. With January cut expectations priced well below 20%, attention is on whether expectations for a March move, currently around 50%, begin to shift.
Confidence that inflation and labour pressures are easing would typically support lower yields and a softer USD. A more cautious tone could lift yields, strengthen the USD, and tighten global financial conditions.
Putting it all together
January’s data acts as condition-setters rather than decision points. The practical takeaway lies in how markets respond as those conditions become clearer:
If growth and labour soften while inflation continues to ease, markets may lean toward a more constructive risk backdrop, with Treasury yields remaining the key guide and expectations for policy easing later in Q1 firming.
If growth holds up and inflation proves sticky, a more cautious posture may be warranted, with heightened sensitivity to Treasury yields, USD strength, and pressure on equity valuations and rate-sensitive commodities.
Asia open: what matters after the Venezuela headlines
Asia starts the week with a fresh geopolitical shock that is already being framed in oil terms, not just security terms. The first-order move may be a repricing of risk premia and volatility across energy and macro, while markets wait to see whether this becomes a durable physical disruption or a fast-fading headline premium.
At a glance
What happened: US officials said the US carried out “Operation Absolute Resolve”, including strikes around Caracas, and that Venezuela’s President Nicolás Maduro and his wife were taken into US custody and flown to the United States (subject to ongoing verification against the cited reporting).
What markets may focus on now: Headline-driven risk premia and volatility, especially in products and heavy-crude-sensitive spreads, rather than a clean “missing barrels” shock.
What is not happening yet: Early pricing has so far looked more like a headline risk premium than a confirmed physical supply shock, though this can change quickly, with analysts pointing to ample global supply as a possible cap on sustained upside.
Next 24 to 72 hours: Market participants are likely to focus on the shape of the oil “quarantine”, the UN track, and whether this stays “one and done” or becomes open-ended.
Australia and Asia hook: AUD as a risk barometer, Asia refinery margins in diesel and heavy, and shipping and insurance where the price can show up in friction before it shows up in benchmarks.
What happened, facts fast
Before anyone had time to workshop the talking points, there were strikes, there was a raid, and there was a custody transfer. US officials say the operation culminated in Maduro and his wife being flown to the United States, where court proceedings are expected.
Then came the line that turned a foreign policy story into a markets story. President Trump publicly suggested the US would “run” Venezuela for now, explicitly tying the mission to oil.
Almost immediately after that came a message-discipline correction. Secretary of State Marco Rubio said the US would not govern Venezuela day to day, but would press for changes through an oil “quarantine” or blockade.
That tension, between maximalist presidential rhetoric and a more bureaucratically describable “quarantine”, is where the uncertainty lives. Uncertainty is what gets priced first.
Source: Adobe images
Why this is price relevant now
What’s new versus known for positioning
What’s new, and price relevant, is that the scale and outcome are not incremental. A major military operation, a claimed removal of Venezuela’s leadership from the country, and a US-led custody transfer are not the sort of things markets can safely treat as noise.
Second, the oil framing is explicit. Even if you assume the language gets sanded down later, the stated lever is petroleum. Flows, enforcement, and pressure via exports.
Third, the embargo is not just a talking point anymore. Reporting says PDVSA has begun asking some joint ventures to cut output because exports have been halted and storage is tightening, with heavy-crude and diluent constraints featuring prominently.
What’s still unknown, and where volatility comes from
Key unknowns include how strict enforcement is on water, what exemptions look like in practice, how stable the on-the-ground situation is, and which countries recognise what comes next. Those are not philosophical questions. Those are the inputs for whether this is a temporary risk premium or a durable regime shift.
Political and legal reaction, why this drives tail risk
The fastest way to understand the tail here is to watch who calls this illegal, and who calls it effective, then ask what those camps can actually do.
Internationally, reaction has been fast, with emphasis on international law and the UN Charter from key partners, and UN processes in view. In the US, lawmakers and commentators have begun debating the legal basis, including questions of authority and war powers. That matters for markets because it helps define whether this is a finite operation with an aftershock, or the opening chapter of a rolling policy regime that keeps generating headlines.
Market mechanism, the core “so what”
Here’s the key thing about oil shocks. Sometimes the headline is the shock. Sometimes the plumbing is the shock.
Venezuela’s heavy-crude system: Orinoco production, key pipelines, and export/refining bottlenecks
Volumes and cushion
Venezuela is not the world’s swing producer. Its production is meaningful at the margin, but not enough by itself to imply “the world runs out of oil tomorrow”. The risk is not just volume. It is duration, disruption, and friction.
The market’s mental brake is spare capacity and the broader supply backdrop. Reporting over the weekend pointed to ample global supply as a likely cap on sustained gains, even as prices respond to risk.
Quality and transmission
Venezuela’s barrels are disproportionately extra heavy, and extra heavy crude is not just “oil”. It is oil that often needs diluent or condensate to move and process. That is exactly the kind of constraint that shows up as grade-specific tightness and product effects.
Reporting has highlighted diluent constraints and storage pressure as exports stall. Translation: even if Brent stays relatively civil, watch cracks, diesel and distillates, and any signals that “heavy substitution” is getting expensive.
Heavy-light spread as a stress gauge: rising differentials can signal costly substitution and tighter heavy supply.
Products transmission, volatility first, pump later
If crude is the headline, products are the receipt, because products tell you what refiners can actually do with the crude they can actually get. The short-run pattern is usually: futures reprice risk fast, implied volatility pops; physical flows adapt more slowly; retail follows with a lag, and often with less drama than the first weekend of commentary promised.
For Australia and Asia desks, the bigger point is transmission. Energy moves can influence inflation expectations, which can feed into rates pricing and the dollar, and in turn affect Asia FX and broader risk, though the links are not mechanical and can vary by regime.
Some market participants also monitor refined-product benchmarks, including gasoline contracts such as reformulated gasoline blendstock, as part of that chain rather than as a stand-alone signal.
Historical context, the two patterns that matter
Two patterns matter more than any single episode.
Pattern A: scare premium. Big headline, limited lasting outage. A spike, then a fade as the market decides the plumbing still works.
Pattern B: structural. Real barrels are lost or restrictions lock in; the forward curve reprices; the premium migrates from front-month drama to whole-curve reality.
One commonly observed pattern is that when it is only premium, volatility tends to spike more than price. When it is structural, levels and time spreads move more durably.
The three possible market reactions
Contained, rhetorical: quarantine exists but porous; diplomacy churns; no second-wave actions. Premium bleeds out; volatility mean-reverts.
Escalation, prolonged control risk: “not governing” language loses credibility; repeated operations; allies fracture further. Longer-duration premium; broader risk-off impulse across FX and rates.
Australia and Asia angle
For Sydney, Singapore, and Hong Kong screens, this is less about Venezuelan retail politics and more about how a Western Hemisphere intervention bleeds into Asia pricing.
AUD is the quick and dirty risk proxy. Asia refiners care about the kind of oil and the friction cost. Heavy crude plus diluent dependency makes substitution non-trivial. If enforcement looks aggressive, the “price” can show up in freight, insurance, and spreads before it shows up in headline Brent.
Catalyst calendar, key developments markets may monitor
US policy detail: quarantine rules, enforcement posture, exemptions.
UN and allies: statements that signal whether this becomes a long legitimacy fight.