TradingView strategy research

Futures spread trading: calendar and intercommodity exposures

Futures spread trading holds opposing futures positions to trade their relative price movement. A calendar spread uses different delivery months of the same product; an intercommodity or intermarket spread compares related products with an explicit contract ratio. The result depends on both legs, their multipliers and actual fills. A small quoted spread or reduced margin does not cap losses. TradingView can display spread observations, but a single-chart strategy report does not independently backtest every futures leg.

See the decision guide

Calendar and intercommodity spreads trade different risks

CME distinguishes intramarket calendar spreads, intermarket spreads and commodity-product spreads. The terminology overlaps in market usage, so write down the actual products and months. A label alone cannot determine the hedge or which leg a spread purchase buys.

  • For this page, a long calendar spread means long nearby and short deferred; a long gasoline crack means long gasoline and short crude. Check the exchange spread definition before submitting an order because conventions can differ.
  • A calendar spread is not an options calendar. There is no purchased-option premium that defines maximum loss. An expected convergence can fail before either contract expires.
  • An exchange-listed spread order can execute its specified legs together. Sending two outright orders separately creates an interval of unmatched exposure; a synthetic TradingView expression does not supply atomic execution.
StructureExplicit position exampleRelationship at risk
Calendar spreadLong one nearby WTI contract; short one later WTI contract.The term structure changes with inventory, storage conditions, seasonal demand and delivery pressure.
Intercommodity / intermarket spreadLong one RBOB gasoline contract; short one WTI crude contract, with specified delivery months.Product prices can move differently. Quote conversion and quantities determine exposure.
Processing spreadA 3:2:1 crack compares three crude contracts with two gasoline and one ULSD contract.A simplified product-yield relationship, not the full operating profit of a refinery.

Convert price moves to cash before comparing hedges

For fixed USD-denominated futures positions, gross price-change P&L = sum of q(i) × M(i) × [Fexit(i) - Fentry(i)]. Here q is signed contract quantity, M is dollars per one quoted price-unit move per contract, and F is the price in that contract quote units. Fees and other cash flows are separate. If currencies differ, convert each cash flow at the applicable FX rate; one final FX rate is not a complete cash ledger.

  • CME specifies 42 U.S. gallons per barrel. For RB quoted in dollars per gallon, 42 × RB converts the quote to dollars per barrel. If a data export instead uses cents per gallon, first divide that quote by 100.
  • For S = FA - h × FB in the original quote units, a fixed long spread with qA contracts requires qB = -qA × MA × h / MB. This follows by matching the coefficients in the P&L equation. A fitted price coefficient h is not automatically a contract ratio.
  • Equal-notional sizing instead uses |qB| = |qA| × MA × FA / (MB × FB) for positive prices in the same currency. It depends on prices, unlike a physical-unit ratio. Round to tradable lots and report the remaining exposure; rebalancing changes turnover.
ContractQuoted price and sizeCash change per tick
WTI crude (CL)USD/barrel; 1,000 barrels$0.01 × 1,000 = $10
RBOB gasoline (RB)USD/gallon; 42,000 gallons$0.0001 × 42,000 = $4.20

Calendar example: a negative spread can still earn a gain

Assume a hypothetical long position in one nearby CL at $70.00/barrel and a short position in one deferred CL at $71.20/barrel. Both contracts have the same 1,000-barrel multiplier. Define S = nearby - deferred, so the entry spread is -$1.20/barrel. These are arithmetic assumptions, not historical quotes or a recommended trade.

  • The identity is P&L = 1,000 × (Sexit - Sentry) for these fixed quantities. The profitable branch does not require either convergence to zero or a falling outright oil price.
  • If nearby is below deferred, this pair of prices is in contango. That observation does not make buying nearby and selling deferred a risk-free trade: the curve can steepen further and the contracts deliver at different times.
  • A spread move of $0.40/barrel has a $400 result here. Do not divide by the $1.20 quoted spread and call that an account return; account equity, margin and cash flows need their own denominator.
Later pricesLeg calculationsCombined gross P&L
Nearby $71.00; deferred $71.80Long: 1,000 × 1.00 = +$1,000. Short: -1,000 × 0.60 = -$600.+$400; S moves from -1.20 to -0.80.
Nearby $69.00; deferred $70.20Long: -$1,000. Short: +$1,000.$0 before costs; S stays at -1.20.
Nearby $68.50; deferred $70.80Long: -$1,500. Short: +$400.-$1,100; S falls to -2.30.

Different quote units: one gasoline contract against one crude contract

For a hypothetical 1:1 gasoline crack, buy one RB at $2.00/gallon and sell one CL at $75.00/barrel. One RB represents 42,000 gallons, equivalent to 1,000 barrels, while one CL represents 1,000 barrels. This matches physical volume, not dollar value or all economic risks. The initial quoted crack is 42 × 2.00 - 75.00 = $9.00/barrel.

  • The new crack is $11.20/barrel and 1,000 × (11.20 - 9.00) = $2,200. Subtracting 2.10 - 77.00 mixes gallons and barrels and has no useful spread interpretation.
  • Equal-dollar sizing would require 84,000 / 75,000 = 1.12 CL shorts per RB at entry. That is not an executable one-contract hedge and is not the physical-volume ratio. With standard whole contracts, either choose an appropriate larger basket or retain and disclose the mismatch.
  • A failure branch has RB fall to $1.90 while CL rises to $78.00. The long loses $4,200 and the short loses $3,000, for -$7,200 before costs. Opposing positions can both lose.
  • The crack excludes refinery operating costs, product mix and location differences. Choose months that match the intended exposure; equal delivery-month labels do not remove processing delays or different delivery obligations.
ItemCalculationResult
Initial long RB notional42,000 × $2.00$84,000
Initial short CL notional1,000 × $75.00$75,000
RB later at $2.10/gallon42,000 × (2.10 - 2.00)+$4,200
CL later at $77.00/barrel-1,000 × (77.00 - 75.00)-$2,000
Combined gross result4,200 - 2,000+$2,200
Crack change(42 × 2.10 - 77.00) - 9.00+$2.20/barrel

Charge both entries and both exits

Apply the following illustrative cost schedule to the profitable +$2,200 crack example. Assume separate outright execution, $3 per contract per side for commission and exchange fees, and one adverse tick per fill relative to the reference prices. These are research allowances, not a broker fee quote or measured liquidity.

  • The break-even crack change is $40.40 / 1,000 = $0.0404/barrel for this basket. A move from $9.00 to $9.03 produces only $30 gross and loses $10.40 after the same allowances.
  • Use a spread-order fill model when trading a listed spread. Do not charge its spread crossing and then charge hypothetical outright crossing again. Likewise, if actual leg fills already contain slippage, do not subtract the allowance a second time.
  • Inspect executable depth, bid/ask width and trading hours on the spread book and the required legs. Volume and open interest help describe activity, but neither guarantees a fill at the close. A thin deferred month can constrain the entire position.
  • Record partial fills, rejected legs, price-limit interruptions and the cost of unwinding unmatched exposure. Add funding, currency conversion and roll fees where they occur. A backtest that simply discards failed baskets hides their risk.
DeductionArithmeticCost
Commission and exchange fees2 contracts × 2 sides × $3$12.00
RB spread/slippage allowance2 fills × $4.20$8.40
CL spread/slippage allowance2 fills × $10.00$20.00
Total execution costs12.00 + 8.40 + 20.00$40.40
Net under these assumptions2,200.00 - 40.40+$2,159.60

Rolls and margin change the cash requirements

Use dated contracts for the execution ledger and declare the exit or roll rule before evaluation. Record the last trading date of each contract, relevant delivery or notice deadlines, and the earlier broker close-out policy. A continuous symbol can switch contracts on a different date from your intended roll; back-adjustment also changes earlier prices to remove roll gaps.

  • Example roll bookkeeping: close a long January / short February calendar and open a long February / short March calendar. Executed separately, this means selling January once, buying February twice and selling March once. Netting the middle-month orders incorrectly to zero reverses the intended exposure.
  • If two old legs close and two new legs open, charge those four contract-sides and the applicable execution costs. Retain the old trade realized P&L and the new entry references. Never count the gap between old and new contract prices as an immediate cash profit.
  • CME margin recognizes some spread offsets, but eligibility, ratios, expiries and the broker requirements matter. Reduced margin is collateral relief, not a maximum-loss guarantee. Recheck it if the hedge changes or one leg closes.
  • A hypothetical cash stress starts with $6,000 account equity and a $4,000 margin requirement. A $1,500 mark-to-market loss leaves $4,500; if the required margin rises to $5,000, the account is $500 short. The final spread may later recover, but the trader must meet the intervening cash requirement or face liquidation.
  • Margin is not deducted as a trading expense merely because it is posted. Track restricted collateral, settlement cash flows and any financing costs separately. Report return on declared account equity, alongside drawdown and peak collateral demand.

A Pine monitor for the unit-normalized crack

This Pine v6 indicator plots 42 × RB - CL in USD/barrel on synchronized, confirmed one-day bars. Continuous default symbols demonstrate the calculation only. Select specific contract months for a dated research interval, use standard daily candles with matching session boundaries, and verify both feeds. The script observes prices; it has no orders or portfolio equity.

  • The worked inputs RB = 2.00 and CL = 75.00 give 9.00; RB = 2.10 and CL = 77.00 give 11.20. A negative crack is valid. The code does not reject negative futures prices merely because they are negative.
  • Missing or differently timed observations remain blank. Matching timestamps does not prove that both feeds were liquid or simultaneously executable. Daily chart closes may differ from official settlement prices; use settlement data for margin reconciliation.
  • Do not infer a historical 1:1 basket return from changes across continuous-symbol rolls. Keep contract selection, adjustments and roll transactions in the research record. This monitor does not automatically discover expiries, roll positions or convert currencies.
Observation indicator only. The 42 multiplier assumes USD/gallon RB and USD/barrel CL. Syntax validation does not establish executable fills or a profitable trading rule.pine
//@version=6
indicator("Gasoline crack observation", overlay = false)
string gasoline = input.symbol("NYMEX:RB1!", "RBOB: select dated contract")
string crude = input.symbol("NYMEX:CL1!", "WTI: select dated contract")
if not timeframe.isdaily or timeframe.multiplier != 1
    runtime.error("Use standard one-day candles with matching sessions.")
[rb, rbStart, rbEnd] = request.security(gasoline, "1D", [close, time, time_close], gaps = barmerge.gaps_on, lookahead = barmerge.lookahead_off)
[cl, clStart, clEnd] = request.security(crude, "1D", [close, time, time_close], gaps = barmerge.gaps_on, lookahead = barmerge.lookahead_off)
bool available = not na(rb) and not na(cl)
bool aligned = rbStart == time and clStart == time and rbEnd == time_close and clEnd == time_close
bool ready = available and aligned and barstate.isconfirmed
float crack = ready ? 42.0 * rb - cl : na
plot(crack, "Gasoline crack (USD/barrel)", color = color.blue, linewidth = 2, style = plot.style_linebr)
hline(0, "Zero crack", color = color.gray)

Test the trading rule in a separate multi-leg ledger

Define the hypothesis before choosing a threshold: a seasonal calendar relationship, an inventory-driven curve change and a gasoline crack are different experiments. Fix the contract selection, ratio, observation time and evaluation dates using information available then. A familiar seasonal pattern is a hypothesis, not a scheduled profit.

  • Specify the entry observation, next executable order time, exit condition, maximum holding period, loss budget and delivery cutoff. Reject entries with missing data or insufficient capital. Keep a declared action for an unmatched leg rather than assuming the other order always fills.
  • Evaluate later periods without refitting thresholds on their outcomes. Preserve losing seasons and all parameter trials. Compare nearby parameter choices and higher cost assumptions; a single best historical setting gives little evidence of stability.
  • Pine can request other symbols, but those requests do not create independently simulated positions. TradingView strategy orders use the chart broker emulator. Neither an indicator nor a strategy on a synthetic spread proves the underlying legs, their margin offsets or their roll execution.
  • Use Pine Script AI Coding Agent to draft observable formulas and request syntax checks. Strategy Optimizer compares supported strategy input combinations; it cannot turn this indicator into a multi-contract portfolio simulator. Reconcile all legs externally before interpreting strategy results.
Where Pineify fits

Pine Script AI Coding Agent

Draft a spread observation indicator from explicit symbols and unit conversions, request a syntax check, and inspect missing-data behavior before using the observations in research.

Also useful: Strategy Optimizer. Compare supported inputs of a TradingView strategy after reviewing its timing and costs. The observation indicator here has no strategy orders, and the optimizer does not supply a multi-leg futures ledger.

Draft a futures spread monitor

Frequently asked questions

Educational research, not investment advice. Prices, fees, margin amounts and outcomes are hypothetical arithmetic examples. No live trade or profitable strategy is claimed. Futures leverage, changing margin requirements and delivery obligations can produce losses beyond initial margin.

Sources and verification

Published by Pineify. Pineify is an independent product and is not affiliated with TradingView. Sources support the technical explanations; examples do not establish trading performance.