INNER CODE UNIT · Python

band_range

zoharbabin/quantum-trader · src/analysis/technical_analysis.py:52

            band_range = upper_band.iloc[-1] - lower_band.iloc[-1]
            if band_range == 0 or pd.isna(band_range):
                bb_position = 0.5
            else:
                bb_position = (current_price - lower_band.iloc[-1]) / band_range
                bb_position = max(0, min(1, bb_position))  # Ensure between 0 and 1
            
            # Normalize signals
            rsi_signal = (rsi_value - 50) / 50  # Range: -1 to 1
            macd_signal = np.tanh(macd_value)   # Range: -1 to 1
            bb_signal = 2 * (bb_position - 0.5)  # Range: -1 to 1
            
            # Combine signals with equal weights
            combined_signal = (rsi_signal + macd_signal + bb_signal) / 3
            
            # Ensure result is within bounds
            return float(max(min(combined_signal, 1), -1))
            

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…