I would like to know whether it is possible to program an indicator that identifies the transition from contango to backwardation and vice versa by analyzing two futures contracts of the same commodity with different expiration dates; for example, CLH6 compared with CLM6. Such an indicator would make it possible to observe, within a specific market, how buying and selling activity shifts for traders like me who operate through spread trading.
I am not experienced in programming, and I do not usually use technical indicators, except for COT data and volume analysis.
I believe that a comparison between two instruments is required in order to use this indicator. Specifically, the indicator should take into account the daily closing prices of the two selected contracts (I trade on daily charts). Essentially, to give a clearer idea, we are interested in identifying when the market begins to move from contango (where longer-dated contracts trade at higher prices) to backwardation, a situation in which nearer expirations start trading at higher prices. This condition typically leads to a widening of the spread, allowing for potentially interesting trading opportunities.
To complete the explanation, I am attaching images of the CLH6–CLM6 spread chart and of the price comparison between the two contracts. By observing the daily closing data, we can see that on December 19, 2025, a clear inversion (backwardation) begins, which causes the spread to widen.
Thank you in advance to anyone who may be able to provide information on this topic.
Kind regards,
Please do not duplicate messages in the forums.
Hello. Reference to other assets cannot be made in the indicators module, nor in the backtester module. What can be done is to create a “calculated instrument”. See screenshots.
Hello Ivan, thanks for you help.
At the end I’ve got what I need.
With best regards,
Andrea
REM === BAR COUNT BACKWARDATION ===
Spread = CLOSE
IF Spread > 0 THEN
cpt = cpt + 1
ELSE
cpt = 0
ENDIF
RETURN cpt AS “Backwardation Bars”