Skip to main content

htf

Function htf 

Source
pub fn htf<C: Condition>(interval: Interval, cond: C) -> HtfCondition<C>
Expand description

Wrap a condition to be evaluated on a higher-timeframe candle series.

Bucket boundaries are UTC-aligned (offset = 0). For non-UTC exchanges use htf_region() instead.

§Arguments

  • interval – Target higher timeframe (e.g. Interval::OneWeek)
  • cond – Any condition to evaluate on the HTF candles

§Example

use finance_query::backtesting::refs::*;
use finance_query::Interval;

// Entry only when weekly price is above its 20-bar SMA
let weekly_uptrend = htf(Interval::OneWeek, price().above_ref(sma(20)));
let entry = ema(10).crosses_above_ref(ema(30)).and(weekly_uptrend);