Certainly! Below is the optimized version of your PROMPT_TEMPLATE_9 with enhanced instructions for generating realistic volume data. This version ensures that volume correlates logically with price ranges while allowing for slight imperfections to mimic real-world trading conditions. The prompt maintains its original length and structure, incorporating the necessary adjustments seamlessly.
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, ensuring volume correlates logically with price range:
- **Large Price Range with Small Volume:** Indicates strong price movement with limited trading activity.
- **Small Price Range with Large Volume:** Suggests heavy trading activity with constrained price movement.
- **Declining Volume to the Right Side:** Volume decreases as the price movement progresses.
- **Increasing Volume to the Right Side:** Volume grows as the price movement progresses.
- **Random Volume:** Incorporate occasional deviations to mimic real market imperfections.
- Describe volume in relation to price range, allowing for slight imperfections to reflect real-world scenarios (e.g., occasional high volume with small range due to low sellers, or large volume with limited range due to high sellers).
- 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]
+ High: [Max(Open, Close) + Random(0.1% to 2% of price)]
+ Low: [Min(Open, Close) - Random(0.1% to 2% of price)]
+ Close:
For bearish candles (red): [Open - Random(0.1% to 2% of price)]
For bullish candles (green): [Open + Random(0.1% to 2% of price)]
+ Volume:
- Base Volume + Random(-20% to +20%) adjusted based on the stage's volume trend.
- Correlate volume with price range:
* **Large Price Range:** Preferably smaller volume, with occasional higher volume to introduce realism.
* **Small Price Range:** Preferably larger volume, with occasional lower volume deviations.
* **Volume Trends:** Follow the specified trend (increasing, declining) with logical variations.
- Introduce slight imperfections to mimic real market behavior (e.g., unexpected volume spikes or drops).
- 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:
```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
- 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
- Describe volume behavior in relation to price ranges, highlighting logical correlations and any introduced imperfections.
- Ensure that all details in the explanation exactly match the attributes of the generated candlestick data.
Step 6: Data Validation
- Review the generated data to ensure:
- Correct Total Number of Candles
- Accurate Number of Bullish and Bearish Candles per Stage
- Logical Price Movements: (e.g., High > Open, Close > Low)
- Volume Trends Align with Strategy Requirements and correlate logically with price ranges
- Indicator Values (if included) are Consistent with Price Movements
- The Data Accurately Reflects All Aspects of the Given Strategy
Step 7: Data Correction
- 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 and their correlation with price ranges.
- 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
- 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 correlate logically with price ranges and 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:**
1. **Volume and Price Range Correlation:**
- **Volume Trends Section:** Expanded to include specific scenarios where volume correlates logically with price ranges, such as large price ranges with small volumes and small price ranges with large volumes.
- **Data Generation Step:** Detailed instructions on how to adjust volume based on the price range and volume trends, including the introduction of slight imperfections to mimic real-world conditions.
2. **Realistic Volume Behavior:**
- **Imperfect Volume Adjustments:** Incorporated guidelines to allow occasional deviations in volume relative to price range, simulating factors like market friction or imbalance between buyers and sellers.
- **Volume as Fuel Analogy:** Maintained the analogy where volume is related to the "fuel" needed for price movements, ensuring that high volume generally supports wider price ranges and vice versa, with exceptions to reflect market dynamics.
3. **Comprehensive Explanation:**
- Added instructions to include descriptions of how volume behaves in relation to price ranges within the detailed explanation, ensuring that the generated data's realism is fully documented.
4. **Data Validation and Correction:**
- Enhanced validation steps to ensure that volume not only follows the trend but also maintains a logical relationship with the price range, ensuring the mock data remains believable and useful for analysis.
These enhancements ensure that the generated candlestick data will have volume patterns that are both accurate to the strategy and realistic, avoiding the artificial fluctuations that previously made the data appear unrealistic to experienced chart readers.