Example1 : Market Analysis with TI
Below examples have been added just to showcase what could be potentially done with this new form of information on chain. Possibilities are endless. This is just a start.
Example 1: Trend Signaling
const ONE_HOUR: u64 = 3_600_000;
const TOLERANCE_10_PCT: u64 = 1000;
public fun check_trend_signal(pair_id: u32): bool {
let (fast_ema, _, _) = supra_oracle_ti::compute_ema(
pair_id,
9, // 9-period EMA
ONE_HOUR,
TOLERANCE_10_PCT
);
let (slow_ema, _, _) = supra_oracle_ti::compute_ema(
pair_id,
50, // 50-period EMA
ONE_HOUR,
TOLERANCE_10_PCT
);
if (option::is_some(&fast_ema) && option::is_some(&slow_ema)) {
let fast = option::extract(&mut fast_ema);
let slow = option::extract(&mut slow_ema);
return fast > slow // Bullish when fast > slow
};
false
}Example 2: Overbought/Oversold Detection
Example 3: Multi-Timeframe Confirmation
Example 4: Historical Analysis
Last updated
