 # Implementation Plan: Neural Activation Model
 
 **Branch**: `feature/neural-activation-model` | **Date**: 2023-10-27 | **Spec**: `../docs/neural-activation-model/spec.md`
 **Input**: Feature specification from `../docs/neural-activation-model/spec.md`
 
 ## Summary
 This plan outlines the technical steps to implement a proof-of-concept for the "Neural Activation Model". We will evolve a single, existing long entry condition from a boolean `true/false` signal into a continuous, weighted "activation score". The initial implementation will run in parallel with the existing logic for visualization and analysis, with no initial impact on the strategy's trading decisions.
 
 ## Technical Context
 **Language/Version**: Pine Script v6
 **Primary Dependencies**: Existing project libraries (`LibraryLongEntry`, `LibraryUtility`)
 **Storage**: N/A
 **Testing**: Manual Backtesting and Visual Verification via a dedicated `Indicator` script.
 **Target Platform**: TradingView
 **Project Type**: Single (Strategy with supporting libraries)
 **Performance Goals**: No regression on the **256,537%** 1D baseline. The new model's performance will be evaluated in "shadow mode" during later phases.
 **Constraints**: Must be implementable within Pine Script's execution limits and not significantly increase script execution time.
 
 ## Constitution Check
 *This plan adheres to the TradingBot25 Constitution.*
 
 *   **I. Performance is Paramount**: The initial implementation is for visualization only and does not affect the trading logic, preserving the baseline.
 *   **II. Modularity Through Libraries**: The core logic will be implemented within existing libraries (`LibraryUtility`, `LibraryLongEntry`), and a new dedicated indicator script will be created for visualization, adhering to the modular approach.
 *   **IV. Isolate and Minimize Change**: The plan targets a single entry condition as a proof-of-concept, minimizing the initial scope.
 *   **V. Synchronized Visualization**: A new, dedicated indicator (`IndicatorActivationScores.pine`) is a core deliverable, ensuring visualization is a primary goal.
 
 ## Project Structure
 
 ### Documentation (this feature)
 ```
 docs/neural-activation-model/
 ├── spec.md              # The feature specification (already created)
 ├── plan.md              # This file
 └── tasks.md             # To be created by the /tasks command
 ```
 
 ### Source Code (new & modified files)
 ```
 # New Files
 IndicatorActivationScores.pine   # For visualizing the activation score
 
 # Modified Files
 LibraryUtility.pine            # To add the normalization function
 LibraryLongEntry.pine          # To add the activation score calculation function
 MainStrategy.pine              # To add inputs for weights and pass data
 ```
 
 ## Phase 0: Research (Completed)
 The specification document (`spec.md`) has sufficiently defined the concepts. The primary technical challenge is the design of a flexible normalization function.
 
 **Decision**: A normalization function that scales a value to a `-1.0` to `1.0` range based on a provided min/max is the most flexible approach.
 
 ## Phase 1: Design & Contracts
 
 1.  **Select Proof-of-Concept Condition**: We will select a condition that combines multiple indicators, such as `longCondition_base_stoch_high_range_cond`, as it relies on several numerical inputs (Stochastic, RSI, MACD slope) that are perfect candidates for this model.
 
 2.  **Data Model (`LibraryUtility.pine`)**:
     *   A new function `f_normalize_toRange(series float value, series float min, series float max) -> series float` will be created. It will take a value and its expected range, and return a normalized value between -1.0 and 1.0.
 
 3.  **Data Model (`LibraryLongEntry.pine`)**:
     *   A new `type` will be created to hold the weights for the PoC condition's components.
     *   A new exported function `f_calculateActivation_poc(...)` will be created. It will take the normalized component values and the weights, and return the final `Activation Score`.
 
 4.  **Visualization (`IndicatorActivationScores.pine`)**:
     *   This new indicator will be created.
     *   It will replicate the necessary data calculations from `MainStrategy.pine`.
     *   It will call `f_calculateActivation_poc(...)` from `LibraryLongEntry.pine`.
     *   It will plot the resulting `Activation Score` and a horizontal threshold line.
 
 ## Phase 2: Task Planning Approach
 *This section describes what the `/tasks` command will do.*
 
 The `/tasks` command will generate a step-by-step checklist based on the design from Phase 1. The tasks will be ordered to ensure a logical and safe implementation sequence:
 
 1.  **Foundation First**: Create the normalization function in `LibraryUtility.pine`.
 2.  **Build the Core Logic**: Implement the new `type` and `f_calculateActivation_poc` function in `LibraryLongEntry.pine`.
 3.  **Add Inputs**: Add the new weight inputs to `MainStrategy.pine`.
 4.  **Integrate & Visualize**: Create the `IndicatorActivationScores.pine` script, integrate the new functions, and add the plots.
 5.  **Final Verification**: A final task to confirm that the main strategy's performance is unaffected.
 
 ## Progress Tracking
 - [X] Phase 0: Research complete
 - [ ] Phase 1: Design complete (This document)
 - [ ] Phase 2: Task planning complete
 - [ ] Initial Constitution Check: PASS