Why a direct line-by-line conversion may not work
Pine Script runs in TradingView’s charting environment. A Python implementation may need a different data source, bar timing, indicator behaviour, session calendar and execution model. A result that looks similar on a historical chart can behave differently when data arrives late or orders are filled at real market prices.
The first step is to distinguish the signal rules from chart visuals and platform-specific functions. Custom alerts, repainting behaviour, look-ahead assumptions and use of higher-timeframe data all need review before anyone can estimate a safe implementation.