โœ–

Forum Replies Created

Check out all your contributions and responses across the community.

Viewing 136 post (of 136 total)
  • Author
    Posts
  • Supertrend depends on ATR, and ATR needs historical candles.

    So, you have to pass both the historical and live data.

    Aggregate the data first and then pass in Supertrend function you will get the accurate value.
    Eg code below:

    def get_supertrend_input(symbol, live_candles):
        # Fetch historical 
        query = "GET HISTORICAL DATA"
        values = [symbol, "minute"]
        historical_candles = fetch_historical_data(query, values)
        # Merge
        all_candles = historical_candles + live_candles
        # Safety check
        if len(all_candles) < 15:  # minimum for ATR(10)
            return []
        return all_candles
    
    def run_supertrend(symbol, live_candles):
        candles = get_supertrend_input(symbol, live_candles)
        if not candles:
            return None
        result = compute_supertrend(candles, period=10, multiplier=3)
        if not result:
            return None
        return result[-1]  # latest signal
Viewing 136 post (of 136 total)
×

Start a Discussion

Get help from the AlgoDelta community.

×

Welcome Back!

Enter your email to sign in or create an account. No passwords needed.

โš ๏ธ

Delete This?

Are you sure you want to delete this? This action is permanent and cannot be undone.

Scroll to Top