数字货币CFDs 零隔夜费
所有数字货币 CFD 交易均享 $0 隔夜仓息。
全天候交易, 覆盖 39 种热门数字货币。
仅限时供应。


全球交易者共同的选择
自 2006 年起,GO Markets 已帮助全球数十万交易者实现他们的投资目标。凭借严格监管、以客户为本的服务,以及屡获殊荣的教育资源,我们始终是交易者值得信赖的合作伙伴。


















































GO Markets
让交易更进一步
探索上千种交易机会,享受专业机构水准的交易工具、流畅稳定的交易体验,以及屡获殊荣的客户支持。开户流程简单快捷,让您轻松开启交易之旅。
.jpg)
TradingView编程系列5:循环结构(上)
循环(Loops) 是一种结构,它会根据指定的条件反复执行一段语句块。它们允许脚本在不需要重复编写代码的情况下完成重复性的任务。Pine Script提供了三种不同的循环类型:for、while 和 for…in。
一、隐式循环
Pine Script的执行模型和时间序列结构,使得在许多情况下并不需要写出明显的循环。
当用户将一个 Pine 脚本添加到图表中时,脚本会在一个等同于“大循环”的环境中运行:它会在可用数据中的每一根历史 K 线以及每一个实时 tick 上各执行一次代码。脚本可以通过历史引用运算符(history-referencing operator)访问之前 K 线上的执行结果;而通过使用 var 或 varip 关键字声明的变量,其计算结果可以在多次执行之间保持不变。这些特性使脚本能够通过逐 K 线(bar-by-bar)的计算来完成各种任务,而无需依赖显式的循环。
下面我们来看一个简单的示例,说明在 Pine Script 中不必要地使用循环的情况。

下面按逐行解释这段 Pine Script 代码的含义和执行逻辑:
首先,声明这是一个指标脚本(indicator)。test是指标在图表上显示的名称。overlay = true 表示该指标绘制在主价格图表上。
其次,声明一个整数类型变量名为lengthInput的变量。input.int()为创建一个用户可在参数设置中修改的整数输入项,其中默认值为 20 根 K 线。在参数面板中显示的名称为length。
接下来,再声明一个初始化变量为 0,浮点数类型的变量closeSum。注意,由于没有使用 var 关键字,在每一根 K 线上脚本执行时,closeSum 都会被重新置为 0。
然后进入for循环,对最近的 lengthInput 根 K 线进行循环,将每根 K 线的收盘价累加到 closeSum。在循环体中,把最近 lengthInput 根 K 线的收盘价逐一相加。
再之后,用收盘价总和除以 K 线数量,计算平均值,保存到变量avgClose中。
最后,将数据画成线,其中"Average close"为图例名称,线条颜色为橙色,线条宽度为2。
总结来说,这段代码就是用for循环计算并绘制最近 lengthInput 根 K 线的收盘价平均值。
其实,这个示例的重点在于演示 “不必要的循环”,在 Pine Script 中,这种均值计算可以直接使用内置函数ta.sma,例如:
avgClose = ta.sma(close, lengthInput)
二、显性循环
尽管 Pine 的执行模型、时间序列结构以及可用的内置函数在许多情况下都能消除对循环的需求,但并非所有迭代任务都可以不用循环。在以下几类任务中,循环是必不可少的:
- 遍历或操作集合(如数组、矩阵和映射)
- 执行无法通过无循环表达式或现有内置函数完成的计算
- 回溯历史数据以分析过去的 K 线,而比较所需的参考值仅在当前 K 线上才可用
例如,要判断哪些过去的 K 线的最高价(high)高于当前 K 线的最高价,就必须使用循环。
这是因为:当前 K 线的数值在脚本运行于之前的历史 K 线时是无法获取的。脚本只能在执行到当前 K 线时访问该 K 线的数值,并且必须在这次执行过程中向后回溯历史序列,将之前的数值与当前值进行比较。
例如,下面的脚本使用 for 循环,将之前 lengthInput 根 K 线的最高价与最后一根历史 K 线的最高价进行比较。在循环中,它调用 label.new(),在每一根最高价高于最后一根历史 K 线最高价的过去 K 线上方绘制一个圆形标签:

首先,声明这是一个名为test2的指标脚本。此脚本允许最多绘制 500 个label,否则在绘制大量标签时会触发限制错误。然后设置lengthInput变量,该变量表示要拿多少根过去的 K 线的最高价(high),来和最后一根历史 K 线的最高价比较,1和500为允许输入的最小值和最大值。
接下来,判断当前是否是最后一根已确认的历史 K 线。barstate.islastconfirmedhistory在历史数据的最后一根 K 线时返回 true,在实时 K 线或更早的历史 K 线上返回 false。
在最后一根历史K线的最高价位置画一条水平虚线。其中line.new的前四个参数分别为起点横坐标,起点纵坐标,终点横坐标,终点纵坐标。
接下来进入For循环,首先判断过去某根 K 线的最高价 > 当前(最后历史)K 线的最高价,如果高于,则紫色圆形标签自动绘制在 K 线柱的上方。
最后一行代码,使用三元运算符判断给最后一根历史 K 线上色高亮。如果是最后一根历史 K 线,则为橙色,否则不改变颜色。

可以看到,当我们将长度参数设置为 60 后,图表中会在最高价高于当前 K 线最高价的历史 K 线上方显示紫色圆点,同时还会绘制一条表示当前 K 线最高价的水平虚线,用于直观地标示该参考价位。
综上所述,本文通过示例对比说明了 Pine Script 中“不必要循环”和“必须使用循环”的典型场景。合理理解 Pine 的执行模型,优先使用内置函数,可以提升脚本的简洁性与性能;而在需要基于当前 K 线回溯并分析历史数据时,循环则不可或缺。掌握循环的正确使用方式,有助于编写更高效、清晰且功能强大的 Pine Script 脚本。

What moved the ASX 200 in 2025?
In 2025, the ASX 200 closed around 8,621 points and was up approximately 6% year to date (YTD) as of 19 December close. Market direction was most sensitive to Reserve Bank of Australia (RBA) expectations, commodity prices and China-linked demand, and (to a lesser extent) moves in the Australian dollar (AUD). The index recovered from November’s pullback, but remained below October’s record close.
Key 2025 drivers included:
- RBA policy expectations: Sentiment was shaped by shifting views on the timing and extent of rate moves. The November pullback reflected repricing towards a longer pause and higher uncertainty around whether the next move could be a hike rather than a cut, particularly as jobs and inflation data surprised.
- Resources and China sensitivity: With a meaningful resources weight, the index responded to iron ore stability, strong gold prices and relative firmness in base metals. China data and any perceived policy support (including signals from the People’s Bank of China (PBOC)) remained important for the export backdrop. A relatively stable AUD also reduced currency-related noise for exporters.
- Index composition and market structure: The ASX 200’s heavier tilt to materials and banks, and lower exposure to high-growth technology, meant it often lagged tech-led global rallies, but tended to hold up better when AI and growth valuations were questioned.
- Corporate earnings: Reporting season outcomes influenced valuation support. In September’s half-year reporting season, around 33% of ASX 200 companies beat expectations, which helped underpin pricing around current levels.
Current state
The ASX 200 was roughly 5% below its late-October record high close of 9,094 points. After the November retracement, support around 8,400 appeared to hold and buying interest improved. The 50-day EMA near 8,730 (a prior consolidation area) was a commonly watched near-term reference, noting technical indicators can be unreliable.
What to watch in January
- China and commodity demand: Growth, trade and any fresh stimulus inference from the PBOC may affect sentiment.
- Domestic inflation and labour data: CPI and jobs prints are key inputs into RBA expectations.
- Key levels and follow-through: The post-November rebound may need continued demand to sustain momentum.

What moved the Nikkei 225 in 2025?
In 2025, the Nikkei 225 traded around 39,200 points and was up approximately 21% year to date (YTD). Market direction was most sensitive to moves in the Japanese yen (JPY) and Bank of Japan (BOJ) communication, with the index consolidating after multi-decade highs. While broader signals remained constructive, consolidation can resolve either higher or lower.
Key influences included:
- JPY movements and earnings translation: A weaker JPY can boost the reported value of overseas earnings for some exporters, although it may also increase input and import costs. The net impact often depends on company hedging practices and varies by sector, with effects most evident in export-heavy industries such as automotive, industrials and parts of technology manufacturing.
- Gradual BOJ policy transition: The BOJ continued to step away from ultra-easy settings, but tightening was generally cautious. Markets largely priced a slow, conditional normalisation, which helped limit downside, even as policy headlines created bouts of volatility.
- Corporate governance reforms: Ongoing improvements in capital efficiency and shareholder returns supported interest from overseas investors. Share buybacks, stronger balance-sheet discipline and improved return on equity (ROE) contributed to re-rating in parts of the market.
- Global cyclical exposure: The Nikkei moved with shifts in global manufacturing sentiment and expectations for US growth, particularly during risk-on phases associated with AI-related capital spending.
Current state
After pushing to multi-decade highs earlier in the year, the Nikkei spent time consolidating but has remained structurally strong. Price sits above key long-term moving averages, and some technicians watch the 50-day exponential moving average (EMA) as a potential reference level (noting these indicators can be unreliable). Currency swings and shifting BOJ expectations were commonly cited as contributors to much of the second-half volatility, although pullbacks were generally met with buying interest.
What to watch in January for Japan
- JPY volatility: Sharper yen moves, especially if driven by BOJ or Federal Reserve expectations, could quickly change exporter earnings assumptions.
- BOJ communication: Small changes in language on inflation persistence or bond market operations may move sentiment.
- Global growth data: US and China manufacturing and trade prints remain key inputs for an externally focused economy.


2025 has seen a material decline in the fortunes of the greenback. A technical structure breakdown early in the year was followed by a breach of the 200-day moving average (MA) at the end of Q1. The index then entered correction territory, printing a three-year low at the end of Q2.
Since then, we have seen attempts to build a technical base, including a re-test of the end-of-June lows in mid-September. However, buying pressure has not been strong enough to push price back above the technically critical and psychologically important 100 level.
What the levels suggest from here
As things stand, the index remains more than 10% lower for 2025. On this technical view, the index may revisit the 96 area. However, technical levels can fail and outcomes depend on multiple factors.
US dollar index

The key question for 2026
The key question remains: are we likely to see further losses in the early part of next year and beyond, or will current support hold?
We cannot assess the US dollar in isolation and any outlook is shaped by internal and global factors, not least its relative strength versus other major currencies. Many of these drivers are interrelated, but four potential headwinds stand out for any US dollar recovery. Collectively, they may keep downside pressure in play.
Four headwinds for any US dollar recovery
1. The US dollar as a safe-haven trade
One scenario where US dollar support has historically been evident is during major global events, slowdowns and market shocks. However, the more muted response of the US dollar during risk-off episodes this year suggests a shift away from the historical norm, with fewer sustained US dollar rallies.
Instead, throughout 2025, some investors appeared to favour gold, and at other times, FX and even equities, rather than into the US dollar. If this change in behaviour persists through 2026, it could make recovery harder, even if global economic pressure builds over the year ahead.
2. US versus global trade
Trade policy is harder to measure objectively, and outcomes can be difficult to predict. That said, trade battles driven by tariffs on US imports are often viewed as an additional potential drag on the US dollar.
The impact may be twofold if additional strain is placed on the US economy through:
- a slowdown in global trade volumes as impacted countries seek alternative trade relationships, with supply chain distortions that may not favour US growth
- pressure on US corporate profit margins as tariffs lift costs for importers
3. Removal of quantitative tightening
The Fed formally halted its balance sheet reduction, quantitative tightening (QT), as of 1 December 2025, ending a program that shrank assets by roughly US$2.4 trillion since mid-2022.
Traditionally, ending QT is seen as marginally negative for the US dollar because it stops the withdrawal of liquidity, can ease global funding conditions, and may reduce the scarcity that can support dollar demand. Put simply, more dollars in the system can soften the currency’s support at the margin, although outcomes have varied historically and often depend on broader financial conditions.
4. Interest rate differential
Interest rate differential (IRD) is likely to be a primary driver of US dollar strength, or otherwise, in the months ahead. The latest FOMC meeting delivered the expected 0.25% cut, with attention on guidance for what may come next.
Even after a softer-than-expected CPI print, markets have been reluctant to price aggressive near-term easing. At the time of writing, less than a 20% chance of a January cut is priced in, and it may be March before we see the next move.
The Fed is balancing sticky inflation against a jobs market under pressure, with the headline rate back at levels last seen in 2012. The practical takeaway is that a more accommodative stance may add to downward pressure on the US dollar.
Current expectations imply around two rate cuts through 2026, with the potential for further easing beyond that, broadly consistent with the median projections shown in the chart below. These are forecasts rather than guarantees, and they can shift as economic data and policy guidance evolve.
