Skip to content
TheChatArchiveThe Chat Archive
o1-mini-2024-09-12· OpenAIAi2 WildChat-4.8M (AI2)

PROMPTTEMPLATE9 = """# Expert Candlestick Chart Pattern Analyst You are an expert…

  1. User

    PROMPT_TEMPLATE_9 = """# Expert Candlestick Chart Pattern Analyst

    You are an expert technical analyst specializing in candlestick chart patterns. Your task is to generate mock candlestick data in JSON format based on a provided strategy description. Follow the detailed steps below to ensure accuracy and precision in your data generation, adapting to any given strategy or market setup.

    Step 1: Strategy Analysis

    1. Carefully read the strategy description: Understand the objectives and elements of the described strategy.
    2. Identify and list the following key components:
      • Setup Name
      • Strategy Type (e.g., Breakout, Reversal, Continuation, Trend Following, Mean Reversion)
      • Timeframe (e.g., Daily, Hourly, 15-minute, 5-minute)
      • Detailed Setup Steps
      • Specific Criteria or Rules (e.g., 2LYNCH criteria, RSI conditions, Moving Average crossovers)
      • Any mentioned indicators or oscillators

    Step 2: Stage Identification and Adaptation

    1. Break down the strategy into distinct stages (e.g., trend formation, consolidation, entry signal, exit signal).
    2. For each stage, determine and list:
      • Exact Number of Candles: If a range is provided, select a specific number within that range. If not specified, use a reasonable number based on the strategy type.
      • Exact Number of Bullish (Green) and Bearish (Red) Candles: Precisely define the count to match the strategy's requirements.
      • Specific Candle Characteristics: (e.g., closing near high, wide ranges, doji candles, engulfing patterns)
      • Volume Trends: Include volume analysis if mentioned in the strategy.
      • Price Action: Describe any specific price movements required (e.g., higher highs, lower lows, sideways movement).
      • Indicator Behavior: If the strategy uses indicators, describe how they should behave during each stage.

    Step 3: Data Generation

    1. Start Date: [Use the provided start date or default to current year, e.g., 2024-01-01]
    2. For each stage:
      • Generate the exact number of candles as determined in Step 2.
      • Ensure the precise number of green and red candles according to the requirements.
      • For each candle:
        • Date: Increment sequentially from the start date.
        • Open: [Previous Close + Random(1% to 20% of Previous Close)]
        • High: [Max(Open, Close) + Random(1% to 20% of Max(Open, Close))]
        • Low: [Min(Open, Close) - Random(1% to 20% of Min(Open, Close))]
        • Close: For bearish candles (red): [Open - Random(1% to 20% of Open)] For bullish candles (green): [Open + Random(1% to 20% of Open)]
        • Volume: [Base Volume + Random(-20% to +20%)] adjusted according to the volume trend requirements of each stage.
      • Adjust price movements to reflect the strategy's requirements (e.g., breakouts, pullbacks, consolidations).
      • If required, calculate and include indicator values based on the generated price data.

    Step 4: JSON Compilation

    1. Structure the data in the exact JSON format below:
    {{
      "candlestickData": [
        {{
          "date": "YYYY-MM-DD",
          "open": 100.00,
          "high": 102.00,
          "low": 99.50,
          "close": 101.80,
          "volume": 1000000
        }}
        // ... exact number of data points as specified
      ],
      "indicators": {{
        // Include any relevant indicators mentioned in the strategy
        "sma20": [100.5, 101.2, ...],
        "rsi": [45, 52, ...]
      }},
      "explanation": "Detailed explanation here"
    }}
    ## Step 5: Detailed Explanation Consistent with Final Data
    1. Provide a comprehensive explanation that includes:
       - Total Number of Candles Generated
       - Breakdown of Candles per Stage: (e.g., 7 candles for trend formation: 5 green, 2 red)
       - Accuracy of Bullish and Bearish Candle Counts per Stage
       - How Each Stage Represents the Strategy Requirements
       - Any Specific Patterns or Characteristics Implemented
       - Indicator Behavior and Significance (if applicable)
       - Key Entry and Exit Points Based on the Strategy
       - Ensure that all details in the explanation exactly match the attributes of the generated candlestick data.
    
    ## Step 6: Data Validation
    1. Review the generated data to ensure:
       - Correct Total Number of Candles
       - Accurate Number of Bullish and Bearish Candles per Stage
       - Bullish candle: Close >= Open; Bearish candle: Close < Open
       - Logical Price Movements: (e.g., High >= Open, Close >= Low)
       - Volume Trends Align with Strategy Requirements
       - Indicator Values (if included) are Consistent with Price Movements
       - The Data Accurately Reflects All Aspects of the Given Strategy
    
    ## Step 7: Data Correction
    1. If the mock data does not meet the specified requirements after validation:
       - Identify the discrepancies: Determine which aspects of the data are incorrect (e.g., incorrect number of candles, wrong candle colors, illogical price movements, misaligned indicator values).
       - Adjust the data accordingly:
         - Modify Candle Counts: Add or remove candles to match the exact number required.
         - Correct Candle Colors: Change the color of candles by adjusting the close prices appropriately.
         - Fix Price Movements: Ensure all price fields adhere to logical constraints and strategy requirements.
         - Recalculate Volumes: Adjust volume values to align with the specified volume trends.
         - Update Indicator Values: Recalculate any indicator values to ensure they match the adjusted price data.
       - Re-validate the corrected data: Ensure that all modifications now meet the original requirements and strategy specifications.
       - Update the Explanation: Regenerate the detailed explanation in Step 5 to accurately reflect the corrected data.
    
    ## Step 8: Final Data Confirmation
    1. Perform a final review to ensure all data is accurate and compliant:
       - Double-check candle counts, colors, and patterns.
       - Ensure all price movements are logical and align with the strategy.
       - Verify volume trends align with strategy requirements.
       - Confirm indicator values (if present) are correct and meaningful.
       - Ensure the JSON structure is correct and free of errors.
       - Confirm the explanation fully matches the final data and accurately describes how the data represents the given strategy.
    
    ##Execution
    Given this strategy description: {description}
    Follow each step meticulously, providing your thought process for each step. Ensure exact compliance with the strategy's requirements for candle numbers, characteristics, and any specific patterns or indicators mentioned.
    Adapt the data generation process as needed to accurately represent the given strategy."""
    Cải tiến prompt để cho mô hình yếu trong phần Step 3: Data Generation, nó sẽ taọ ra HOLC giá chuẩn xác theo công thức/ code python lắp vào mà không generate ra ngẫu nhiên nữa!
    
  2. Assistant

    Certainly! To enhance Step 3: Data Generation in your PROMPT_TEMPLATE_9, we can modify the instructions to generate precise OHLC (Open, High, Low, Close) values based on deterministic formulas or embedded Python code rather than relying on random values. This approach ensures consistency and accuracy in the generated candlestick data.

    Below is the updated PROMPT_TEMPLATE_9 with the improved Step 3: Data Generation:

    PROMPT_TEMPLATE_9 = """# Expert Candlestick Chart Pattern Analyst
    
    You are an expert technical analyst specializing in candlestick chart patterns.
    Your task is to generate mock candlestick data in JSON format based on a provided strategy description.
    Follow the detailed steps below to ensure accuracy and precision in your data generation, adapting to any given strategy or market setup.
    
    ## Step 1: Strategy Analysis
    1. Carefully read the strategy description: Understand the objectives and elements of the described strategy.
    2. Identify and list the following key components:
       - Setup Name
       - Strategy Type (e.g., Breakout, Reversal, Continuation, Trend Following, Mean Reversion)
       - Timeframe (e.g., Daily, Hourly, 15-minute, 5-minute)
       - Detailed Setup Steps
       - Specific Criteria or Rules (e.g., 2LYNCH criteria, RSI conditions, Moving Average crossovers)
       - Any mentioned indicators or oscillators
    
    ## Step 2: Stage Identification and Adaptation
    1. Break down the strategy into distinct stages (e.g., trend formation, consolidation, entry signal, exit signal).
    2. For each stage, determine and list:
       - Exact Number of Candles: If a range is provided, select a specific number within that range. If not specified, use a reasonable number based on the strategy type.
       - Exact Number of Bullish (Green) and Bearish (Red) Candles: Precisely define the count to match the strategy's requirements.
       - Specific Candle Characteristics: (e.g., closing near high, wide ranges, doji candles, engulfing patterns)
       - Volume Trends: Include volume analysis if mentioned in the strategy.
       - Price Action: Describe any specific price movements required (e.g., higher highs, lower lows, sideways movement).
       - Indicator Behavior: If the strategy uses indicators, describe how they should behave during each stage.
    
    ## Step 3: Data Generation
    1. **Start Date:** Use the provided start date or default to the current year, e.g., `2024-01-01`.
    
    2. **Generation Logic:**
       - Instead of using random values, generate OHLC data based on precise mathematical formulas or deterministic Python code snippets to ensure reproducibility and accuracy.
       
    3. **Data Generation Process:**
       - **Initial Parameters:**
         - **Base Close Price:** Initialize with a base close price (e.g., 100.00).
         - **Base Volume:** Initialize with a base volume (e.g., 1,000,000).
    
       - **For Each Stage:**
         - **Number of Candles:** As determined in Step 2.
         - **Bullish and Bearish Candles:**
           - Define a sequence or pattern that matches the exact number of bullish (green) and bearish (red) candles required.
       
         - **Candle Generation Logic:**
           - **Date:** Increment sequentially from the start date.
           - **Open:** Set as the previous candle's close.
           - **Close:**
             - For bearish candles (red): `Close = Open * (1 - X)` where `X` is a predetermined percentage (e.g., 0.02 for 2%).
             - For bullish candles (green): `Close = Open * (1 + X)` where `X` is a predetermined percentage (e.g., 0.02 for 2%).
           - **High:** `High = max(Open, Close) * (1 + Y)` where `Y` is a small fixed percentage (e.g., 0.01 for 1% above the higher of Open or Close).
           - **Low:** `Low = min(Open, Close) * (1 - Y)` where `Y` is a small fixed percentage (e.g., 0.01 for 1% below the lower of Open or Close).
           - **Volume:** `Volume = Base Volume * Z` where `Z` is a multiplier based on volume trends (e.g., increasing, decreasing, or steady).
    
         - **Example Python Snippet for Candle Generation:**
           ```python
           from datetime import datetime, timedelta
    
           start_date = datetime(2024, 1, 1)
           base_close = 100.00
           base_volume = 1000000
           volume_trend = 1.0  # Adjust this based on volume trends
    
           candlestick_data = []
    
           for stage in stages:
               for candle in stage.candles:
                   date = start_date.strftime("%Y-%m-%d")
                   open_price = base_close
                   if candle.type == "bullish":
                       close_price = open_price * 1.02  # 2% increase
                   else:
                       close_price = open_price * 0.98  # 2% decrease
                   high_price = max(open_price, close_price) * 1.01  # 1% above
                   low_price = min(open_price, close_price) * 0.99  # 1% below
                   volume = base_volume * volume_trend
                   
                   candlestick = {
                       "date": date,
                       "open": round(open_price, 2),
                       "high": round(high_price, 2),
                       "low": round(low_price, 2),
                       "close": round(close_price, 2),
                       "volume": int(volume)
                   }
                   candlestick_data.append(candlestick)
                   
                   # Update for next candle
                   start_date += timedelta(days=1)
                   base_close = close_price
                   # Adjust volume_trend as needed
           ```
    
         - **Indicator Calculations:**
           - Calculate indicators deterministically based on the generated price data.
           - Example for Simple Moving Average (SMA):
             ```python
             sma_period = 20
             sma_values = []
             for i in range(len(candlestick_data)):
                 if i < sma_period - 1:
                     sma = None  # Not enough data
                 else:
                     sma = sum([c.close for c in candlestick_data[i-sma_period+1:i+1]]) / sma_period
                 sma_values.append(round(sma, 2) if sma else None)
             ```
    
    ## Step 4: JSON Compilation
    1. Structure the data in the exact JSON format below:
    
    ```json
    {
      "candlestickData": [
        {
          "date": "YYYY-MM-DD",
          "open": 100.00,
          "high": 102.00,
          "low": 99.50,
          "close": 101.80,
          "volume": 1000000
        }
        // ... exact number of data points as specified
      ],
      "indicators": {
        // Include any relevant indicators mentioned in the strategy
        "sma20": [100.5, 101.2, ...],
        "rsi": [45, 52, ...]
      },
      "explanation": "Detailed explanation here"
    }
    

    Step 5: Detailed Explanation Consistent with Final Data

    1. Provide a comprehensive explanation that includes:
      • Total Number of Candles Generated
      • Breakdown of Candles per Stage: (e.g., 7 candles for trend formation: 5 green, 2 red)
      • Accuracy of Bullish and Bearish Candle Counts per Stage
      • How Each Stage Represents the Strategy Requirements
      • Any Specific Patterns or Characteristics Implemented
      • Indicator Behavior and Significance (if applicable)
      • Key Entry and Exit Points Based on the Strategy
      • Ensure that all details in the explanation exactly match the attributes of the generated candlestick data.

    Step 6: Data Validation

    1. Review the generated data to ensure:
      • Correct Total Number of Candles
      • Accurate Number of Bullish and Bearish Candles per Stage
      • Bullish candle: Close >= Open; Bearish candle: Close < Open
      • Logical Price Movements: (e.g., High >= Open, Close >= Low)
      • Volume Trends Align with Strategy Requirements
      • Indicator Values (if included) are Consistent with Price Movements
      • The Data Accurately Reflects All Aspects of the Given Strategy

    Step 7: Data Correction

    1. If the mock data does not meet the specified requirements after validation:
      • Identify the discrepancies: Determine which aspects of the data are incorrect (e.g., incorrect number of candles, wrong candle colors, illogical price movements, misaligned indicator values).
      • Adjust the data accordingly:
        • Modify Candle Counts: Add or remove candles to match the exact number required.
        • Correct Candle Colors: Change the color of candles by adjusting the close prices appropriately.
        • Fix Price Movements: Ensure all price fields adhere to logical constraints and strategy requirements.
        • Recalculate Volumes: Adjust volume values to align with the specified volume trends.
        • Update Indicator Values: Recalculate any indicator values to ensure they match the adjusted price data.
      • Re-validate the corrected data: Ensure that all modifications now meet the original requirements and strategy specifications.
      • Update the Explanation: Regenerate the detailed explanation in Step 5 to accurately reflect the corrected data.

    Step 8: Final Data Confirmation

    1. Perform a final review to ensure all data is accurate and compliant:
      • Double-check candle counts, colors, and patterns.
      • Ensure all price movements are logical and align with the strategy.
      • Verify volume trends align with strategy requirements.
      • Confirm indicator values (if present) are correct and meaningful.
      • Ensure the JSON structure is correct and free of errors.
      • Confirm the explanation fully matches the final data and accurately describes how the data represents the given strategy.

    Execution

    Given this strategy description: {description} Follow each step meticulously, providing your thought process for each step. Ensure exact compliance with the strategy's requirements for candle numbers, characteristics, and any specific patterns or indicators mentioned. Adapt the data generation process as needed to accurately represent the given strategy."""

    
    ### **Key Enhancements in Step 3: Data Generation**
    
    1. **Deterministic Generation:**
       - **Removal of Randomness:** Replaced random percentage-based adjustments with fixed or formula-based calculations to ensure consistency.
       - **Mathematical Formulas:** Utilized precise mathematical formulas for calculating `Open`, `High`, `Low`, and `Close` prices.
    
    2. **Embedded Python Snippets:**
       - **Code Integration:** Provided example Python code snippets to demonstrate how OHLC data can be generated deterministically.
       - **Indicator Calculations:** Included sample code for calculating indicators like Simple Moving Average (SMA), ensuring indicators are based on the generated data.
    
    3. **Structured Approach:**
       - **Initial Parameters:** Defined base values for `Close` price and `Volume` to serve as starting points.
       - **Sequential Processing:** Ensured that each candle's `Open` price is the previous candle's `Close` price, maintaining logical continuity.
       - **Volume Trends:** Introduced a `volume_trend` multiplier to adjust volume based on strategy requirements without randomness.
    
    4. **Flexibility for Strategy Requirements:**
       - **Stage-Based Generation:** Allowed for different stages of the strategy to have tailored candle generation logic, accommodating various strategy nuances.
       - **Indicator Integration:** Ensured that any indicators used are calculated based on the deterministic price data, maintaining consistency across the dataset.
    
    ### **Benefits of These Enhancements**
    
    - **Consistency:** Eliminates variability in the generated data, making it more reliable for testing and analysis.
    - **Reproducibility:** Allows for the same dataset to be regenerated using the provided formulas or code, facilitating verification and debugging.
    - **Accuracy:** Ensures that the OHLC values adhere strictly to the defined formulas, aligning perfectly with the strategy's requirements.
    - **Clarity:** Provides clear guidelines and example code, making it easier to implement and adapt to various strategies.
    
    ### **Implementation Tips**
    
    - **Adjusting Parameters:** Depending on the strategy, you can modify the fixed percentages (`X` and `Y`) to better reflect the desired price movements.
    - **Volume Trends:** Customize the `volume_trend` multiplier logic to simulate different volume behaviors (e.g., increasing, decreasing, steady) as per strategy needs.
    - **Indicator Customization:** Extend the indicator calculations to include other relevant indicators, ensuring they are derived from the deterministic price data.
    
    By implementing these enhancements, the data generation process becomes more robust, precise, and tailored to accurately reflect the specified trading strategy without relying on random variations.