cTrader Price Volume Trend (PVT) Indicator: Tick-Volume-Weighted Price Changes in C#
Beginner Trading Tutorial | cTrader Automate custom indicator | Complete C# source
Price moves are not all equally informative. A 1% close-to-close change on a quiet bar may deserve a different interpretation from an equally large change during unusually active trading. Price Volume Trend (PVT) is a cumulative indicator that weights the percentage price change by that bar’s volume reading. Unlike On-Balance Volume, which adds or subtracts the entire volume when the close changes direction, PVT scales the volume contribution by the size of the return.
For many spot FX symbols, cTrader provides tick volume, representing the number of price updates counted in the bar—not a central exchange’s traded contract total. A PVT made from that input should be interpreted as a broker-feed price/quote-activity series, not proof of actual institutional buying or selling. Our goal is an auditable educational indicator, not an automated trade recommendation.
The core formula is a signed, price-weighted contribution
Per-bar PVT change = TickVolume × (current close − previous close) ÷ previous close. The new cumulative PVT is the previous PVT plus this contribution. A positive price return adds to PVT and a negative return subtracts from it; the absolute size is proportional to both price percentage movement and quote activity.
The indicator starts its first available historical bar at PVT = 0. That is an arbitrary anchor, not an economic zero. If the chart loads more history, the cumulative curve may shift in absolute terms. Therefore, compare PVT changes and its local signal average within a chart rather than comparing raw PVT numbers across two brokers or symbols.

A two-step worked example
Begin with an illustrative close of 100 and PVT anchored at 0. The next bar closes at 102 with 1,200 ticks. Its price return is (102 − 100)/100 = +2%. Its PVT contribution is 1,200 × 2% = +24, so the accumulated value becomes +24.
On the following bar, the close falls from 102 to 101 with 900 ticks. The price return is −1/102 ≈ −0.9804%. The contribution is 900 × (−1/102) ≈ −8.82. The new PVT is approximately +15.18. Even after the decline, the cumulative total remains positive relative to the arbitrary initial anchor: the earlier rising-price contribution was larger.

What a signal line adds
A single PVT step can be noisy. To make the longer-term movement easier to interpret, the code adds a 20-bar simple moving average of PVT itself. This line is derived from the same cumulative data. When PVT is above its own average, recent signed contributions have tended to lift the cumulative series relative to its local history; below the average suggests the opposite. A crossover is an observation to investigate, not a guaranteed entry or exit.
| Element | Calculation | Interpretation |
|---|---|---|
| PVT cumulative line | Previous PVT + weighted percentage return | Direction and magnitude of cumulative tick-weighted change |
| 20-bar signal SMA | Arithmetic average of last 20 PVT values | A local comparison baseline |
| PVT above signal | Current PVT > 20-bar PVT average | Recent cumulative flow stronger than its own local average |
| PVT below signal | Current PVT < 20-bar PVT average | Recent cumulative flow weaker than its own local average |
| Early bars | Fewer than 20 historical values | Signal line intentionally blank; no invented values |
Complete cTrader Automate C# source
The following is a complete cTrader custom indicator, not a cBot or a MetaTrader program. It uses the cTrader Bars.ClosePrices, Bars.TickVolumes, IndicatorDataSeries and Calculate(int index) APIs. Both the English and Chinese editions reproduce the same unmodified source.
// Price Volume Trend (PVT) with a signal average for cTrader Automate.
// Install as a custom INDICATOR, not a cBot.
using System;
using cAlgo.API;
namespace cAlgo.Indicators
{
[Indicator(IsOverlay = false, TimeZone = TimeZones.UTC,
AccessRights = AccessRights.None)]
public class PSPVTFlow : Indicator
{
[Parameter("Signal SMA Period", DefaultValue = 20, MinValue = 2)]
public int SignalPeriod { get; set; }
[Output("PVT cumulative", LineColor = "RoyalBlue", Thickness = 2)]
public IndicatorDataSeries Pvt { get; set; }
[Output("PVT signal SMA", LineColor = "Green", Thickness = 2)]
public IndicatorDataSeries Signal { get; set; }
public override void Calculate(int index)
{
// The first historical bar is an arbitrary zero anchor.
if (index == 0)
{
Pvt[index] = 0.0;
}
else
{
double previousClose = Bars.ClosePrices[index - 1];
double currentClose = Bars.ClosePrices[index];
double ticks = Bars.TickVolumes[index];
// Guard against non-price / malformed zero-close data.
double contribution = Math.Abs(previousClose) > 0.0
? ticks * (currentClose - previousClose) / previousClose
: 0.0;
Pvt[index] = Pvt[index - 1] + contribution;
}
// A full signal-window is required; never invent warm-up history.
if (index < SignalPeriod - 1)
{
Signal[index] = double.NaN;
return;
}
double total = 0.0;
for (int offset = 0; offset < SignalPeriod; offset++)
total += Pvt[index - offset];
Signal[index] = total / SignalPeriod;
}
}
}
Installation and expected output
- In cTrader open the Algo workspace and create a new custom Indicator in C#.
- Name it
PSPVTFlow, replace the generated template with the entire source above, and build it. API availability can depend on the installed cTrader release; this article does not claim a live compile test. - Attach the indicator to a chart of a symbol whose feed supplies tick-volume data. It will appear in its own panel with two lines: cumulative PVT and its signal SMA.
- Start with
Signal SMA Period = 20. Compare the PVT line with its average during a clear price advance and a choppy range. - Inspect live bar updates versus completed bars. The latest PVT point can change until the current bar closes, so use the completed bar when logging or evaluating an interpretation.
Important code mechanics and defensive choices
Calculate(index) may update the current developing bar as new quotes arrive. The code calculates each PVT value from the prior bar’s cumulative total plus the current bar’s weighted return. If the same forming index is recalculated several times, the formula does not keep adding multiple contributions to itself: it always starts from Pvt[index - 1], making the current result deterministic for the latest price and ticks.
The code handles index 0 explicitly with a zero anchor. It also checks for a zero previous close before division. For the moving average, it waits for a full window; earlier SMA outputs use double.NaN. This avoids fabricated warm-up signal values. The calculation is transparent and uses no higher-timeframe request, hidden strategy order, or future-bar reference.
Limitations: volume meaning, anchoring and data revisions
Tick volume varies by broker, symbol, feed aggregation, timezone and session. A PVT line that rises with price may indicate that price changes were accompanied by more quote updates, but it cannot establish buyer identity or true exchange-side traded size. Equity or futures volume availability can differ from decentralized FX. Never silently treat all feeds as if they recorded the same quantity.
Because PVT is cumulative, it is especially sensitive to the amount of loaded history. Adding older historical bars changes the starting context and may shift all later absolute PVT values. This matters less for some local comparisons, but the exact signal average can also change after history reloads. You should not present the absolute PVT number as a stable cross-symbol score. A hard-to-see scale difference is not a market insight.
A crossover of PVT and its SMA is not a verified trading strategy. Choppy markets can produce frequent crossings; trends can be nearly over by the time the average catches up. The current unclosed candle can temporarily lift or depress the indicator, and a historical feed revision can alter past values. This program deliberately plots diagnostics but does not place market orders, backtest entries or claim future performance.
A practical verification worksheet
First, independently calculate PVT changes for at least five adjacent completed candles using the chart’s close and tick-volume values. Confirm that the cumulative sum matches the blue line, allowing for the unknown history starting anchor. Next verify the 20-bar arithmetic average by hand for a selected historical bar. Finally, review at least 30 price/PVT relationships across both trend and range periods; log failures as carefully as successes. Include spread, slippage and the possibility of different broker-feed tick counts in any later trading-system study.
Possible custom extensions include session-reset PVT, normalized PVT changes for cross-symbol comparison, alerts only on confirmed SMA crossings, or separate signals for participation divergences. Interested in adapting this free program or idea for your workflow? Learn more through our Custom Trading Software Development Services and contact us with your requirements.
Educational information and sample source code only. This material is not personalized trading advice and does not guarantee returns. Compile and verify source in your own cTrader environment before relying on any indicator output.