# Example2:  Complete Trading Bot with TI

This is a sample trading bot made with technical indicators

```move
module my_address::trading_bot {
    use supra_oracle::supra_oracle_ti;
    use std::option;
    
    const ONE_HOUR: u64 = 3_600_000;
    const TOLERANCE: u64 = 1000;  // 10% missing candles tolerance
    
    public entry fun execute_strategy(pair_id: u32) {
        // Get multiple indicators
        let (rsi, _) = supra_oracle_ti::compute_rsi(
            pair_id,
            14,         // 14-period RSI
            ONE_HOUR,
            TOLERANCE
        );
        
        let (fast_ema, _, _) = supra_oracle_ti::compute_ema(
            pair_id,
            9,          // 9-period fast EMA
            ONE_HOUR,
            TOLERANCE
        );
        
        let (slow_ema, _, _) = supra_oracle_ti::compute_ema(
            pair_id,
            21,         // 21-period slow EMA
            ONE_HOUR,
            TOLERANCE
        );
        
        // Check all indicators are available
        if (option::is_none(&rsi) || 
            option::is_none(&fast_ema) || 
            option::is_none(&slow_ema)) {
            return  // Not enough data yet
        };
        
        // Extract values
        let rsi_val = option::extract(&mut rsi);
        let fast = option::extract(&mut fast_ema);
        let slow = option::extract(&mut slow_ema);
        
        // Trading logic
        if (fast > slow && rsi_val < 70) {
            // Bullish signal + not overbought
            execute_long_position(pair_id);
        } else if (fast < slow && rsi_val > 30) {
            // Bearish signal + not oversold
            execute_short_position(pair_id);
        }
    }
    
    fun execute_long_position(pair_id: u32) {
        // Your position logic here
    }
    
    fun execute_short_position(pair_id: u32) {
        // Your position logic here
    }
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://supraoracles.gitbook.io/supra/oracles/technical-indicators/example2-complete-trading-bot-with-ti.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
