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
Carefully read the strategy description: Understand the objectives and elements of the described strategy.
Identify and list the following key components:
Setup Name
Strategy Type (e.g., Breakout, Reversal, Continuation, Trend Following, Mean Reversion)
Specific Criteria or Rules (e.g., 2LYNCH criteria, RSI conditions, Moving Average crossovers)
Any mentioned indicators or oscillators
Step 2: Stage Identification and Adaptation
Break down the strategy into distinct stages (e.g., trend formation, consolidation, entry signal, exit signal).
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
Start Date: [Use the provided start date or default to current year, e.g., 2024-01-01]
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)]
Assistant
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
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
- 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."""
Với prompt này làm sao để nó ở bước 3 generate dữ liệu thật chính xác như công thức đã cho?
To ensure that Step 3: Data Generation in your PROMPT_TEMPLATE_9_old generates candlestick data with high precision and adheres strictly to the specified formulas, you can enhance the prompt by incorporating more explicit instructions, defining clear computational guidelines, and minimizing ambiguity. Below are detailed recommendations and a revised version of Step 3 to achieve accurate data generation:
Recommendations for Enhancing Step 3
Explicit Formula Definitions:
Clearly define each calculation step with precise mathematical formulas.
Use exact percentage ranges and specify how to compute random values deterministically if needed.
Parameterized Randomness:
Instead of vague terms like Random(0.1% to 2% of price), define how to calculate these random values (e.g., using uniform distribution within the specified range).
Optionally, set a seed for random number generation to ensure reproducibility.
Sequential Data Dependencies:
Emphasize the dependency of each candle's open price on the previous candle's close price.
Ensure date increments are handled correctly, especially when dealing with non-trading days (e.g., weekends, holidays).
Volume Calculation Clarity:
Define a base volume value or range.
Specify how to apply the Random(-20% to +20%) adjustment (e.g., percentage of the base volume).
Indicator Calculations:
If indicators are to be included, provide formulas or clear instructions on how to compute them based on the generated price data.
Error Handling and Validation:
Include checks to ensure that all calculations result in logical and realistic values (e.g., High > Open, Close > Low).
Examples for Clarity:
Provide sample calculations or examples to illustrate how each part of the data generation should work.
Revised Step 3: Data Generation
markdown
## Step 3: Data Generation
1. **Start Date**:
- Use the provided start date.
- If none is provided, default to `2024-01-01`.
2. **Initialize Base Parameters**:
- **Base Volume**: Set a base volume (e.g., `1,000,000`). This can be adjusted based on the strategy requirements.
- **Price Precision**: Define the number of decimal places for price values (e.g., two decimal places).
3. **Generate Candles for Each Stage**:
For each identified stage from Step 2, perform the following:
a. **Generate Specific Number of Candles**:
- **Total Candles**: Use the exact number determined for the stage.
- **Candlestick Colors**:
- **Bullish (Green) Candles**: Number as specified.
- **Bearish (Red) Candles**: Number as specified.
- **Initialize Counters**:
- Keep track of how many bullish and bearish candles have been generated to ensure compliance.
b. **Generate Each Candle**:
For each candle in the stage, perform the following steps sequentially:
i. **Date**:
- Increment the date by one trading day from the previous candle's date.
- **Note**: Skip non-trading days (e.g., weekends, predefined holidays).
ii. **Open Price**:
- Set as the **Close** price of the previous candle.
- For the first candle, if no previous close is available, define a starting open price based on the strategy or use a default value.
iii. **Close Price**:
- **Bullish Candle (Green)**:
- `Close = Open + (Open * RandomUniform(0.1%, 2%))`
- **Bearish Candle (Red)**:
- `Close = Open - (Open * RandomUniform(0.1%, 2%))`
- Ensure the close price is rounded to the defined precision.
iv. **High Price**:
- Calculate the maximum of `Open` and `Close`.
- Add a random increment: `High = Max(Open, Close) + (Max(Open, Close) * RandomUniform(0.1%, 2%))`
- Ensure `High` is greater than both `Open` and `Close`.
v. **Low Price**:
- Calculate the minimum of `Open` and `Close`.
- Subtract a random decrement: `Low = Min(Open, Close) - (Min(Open, Close) * RandomUniform(0.1%, 2%))`
- Ensure `Low` is less than both `Open` and `Close`.
vi. **Volume**:
- Adjust based on the stage's volume trend requirements.
- Formula: `Volume = BaseVolume * (1 + RandomUniform(-20%, +20%))`
- Round to the nearest whole number.
vii. **Indicator Values** (if applicable):
- Calculate based on the current and previous price data.
- Ensure indicators are updated sequentially and correctly reflect the price movements.
viii. **Validation**:
- Confirm that `High > Open`, `High > Close`, `Low < Open`, and `Low < Close`.
- Ensure volume aligns with the stage's trend (e.g., increasing, decreasing, stable).
4. **Handle Price Adjustments for Strategy Requirements**:
- Apply any additional price movements such as breakouts, pullbacks, or consolidations as specified by the strategy.
- This may involve adjusting the `Open`, `Close`, `High`, and `Low` prices to create specific patterns or trends.
5. **Finalize Data Structure**:
- Compile all generated candles into a structured format, ensuring each candle contains:
- `date` (YYYY-MM-DD)
- `open` (float)
- `high` (float)
- `low` (float)
- `close` (float)
- `volume` (integer)
6. **Indicator Compilation** (if applicable):
- Aggregate all indicator values calculated during candle generation.
- Ensure indicators are synchronized with the corresponding candle dates.
7. **Example Calculation**:
- **Bullish Candle Example**:
- Previous Close: `$100.00`
- Open: `$100.00`
- Close: `$100.00 + ($100.00 * 1%) = $101.00`
- High: `Max($100.00, $101.00) + ($101.00 * 0.5%) = $101.00 + $0.505 = $101.51`
- Low: `Min($100.00, $101.00) - ($100.00 * 0.3%) = $100.00 - $0.30 = $99.70`
- Volume: `1,000,000 * (1 + 0.10) = 1,100,000`
8. **Final Checks**:
- After generating all candles, perform a final review to ensure all calculations and data points adhere strictly to the defined formulas and strategy requirements.
Additional Enhancements to the Prompt Template
To integrate the revised Step 3 into your PROMPT_TEMPLATE_9_old, consider the following modifications to the original template:
Incorporate Detailed Calculations:
Replace vague instructions with the precise steps outlined above.
Use placeholders like RandomUniform(0.1%, 2%) to specify the method of randomness.
Add Example Calculations:
Including examples helps clarify how each field should be calculated, reducing ambiguity.
Define Default Values and Precision:
Specify default start dates, base volumes, and price precision to ensure consistency.
Emphasize Validation Steps:
Highlight the importance of validating each candle's data against logical constraints.
Structure the Prompt for Clarity:
Use numbered lists and sub-steps to make the instructions easy to follow and implement.
Updated PROMPT_TEMPLATE_9_old
Below is the updated prompt template with the enhanced Step 3:
markdown
Implementing the Revised Step 3
When utilizing this revised prompt template, ensure the following:
Consistency in Calculations: Follow the exact mathematical operations as defined. Avoid deviations unless explicitly required by the strategy.
Precision Handling: Maintain the defined precision for price values to ensure data realism and accuracy.
Sequential Dependencies: Respect the dependency of each candle on the previous one, especially concerning the Open price.
Volume Trends: Align volume adjustments with the stage-specific trends to reflect realistic market behavior.
Indicator Accuracy: If indicators are part of the strategy, ensure their values are computed based on the generated prices and reflect the intended market signals.
Validation and Correction: Rigorously validate each generated candle and make necessary adjustments to rectify any inconsistencies or logical errors.
By incorporating these detailed instructions and enhancements into your prompt template, Step 3: Data Generation will produce highly accurate and realistic mock candlestick data that aligns precisely with the specified formulas and strategy requirements.
Not yet included in a published release.
# 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.
- If none is provided, default to `2024-01-01`.
2. **Initialize Base Parameters**:
- **Base Volume**: Set a base volume (e.g., `1,000,000`). Adjust based on strategy requirements.
- **Price Precision**: Define the number of decimal places for price values (e.g., two decimal places).
3. **Generate Candles for Each Stage**:
For each identified stage from Step 2, perform the following:
a. **Generate Specific Number of Candles**:
- **Total Candles**: Use the exact number determined for the stage.
- **Candlestick Colors**:
- **Bullish (Green) Candles**: Number as specified.
- **Bearish (Red) Candles**: Number as specified.
- **Initialize Counters**:
- Keep track of how many bullish and bearish candles have been generated to ensure compliance.
b. **Generate Each Candle**:
For each candle in the stage, perform the following steps sequentially:
i. **Date**:
- Increment the date by one trading day from the previous candle's date.
- **Note**: Skip non-trading days (e.g., weekends, predefined holidays).
ii. **Open Price**:
- Set as the **Close** price of the previous candle.
- For the first candle, if no previous close is available, define a starting open price based on the strategy or use a default value.
iii. **Close Price**:
- **Bullish Candle (Green)**:
- `Close = Open + (Open * RandomUniform(0.1%, 2%))`
- **Bearish Candle (Red)**:
- `Close = Open - (Open * RandomUniform(0.1%, 2%))`
- Ensure the close price is rounded to the defined precision.
iv. **High Price**:
- Calculate the maximum of `Open` and `Close`.
- Add a random increment:
- `High = Max(Open, Close) + (Max(Open, Close) * RandomUniform(0.1%, 2%))`
- Ensure `High` is greater than both `Open` and `Close`.
v. **Low Price**:
- Calculate the minimum of `Open` and `Close`.
- Subtract a random decrement:
- `Low = Min(Open, Close) - (Min(Open, Close) * RandomUniform(0.1%, 2%))`
- Ensure `Low` is less than both `Open` and `Close`.
vi. **Volume**:
- Adjust based on the stage's volume trend requirements.
- Formula: `Volume = BaseVolume * (1 + RandomUniform(-20%, +20%))`
- Round to the nearest whole number.
vii. **Indicator Values** (if applicable):
- Calculate based on the current and previous price data.
- Ensure indicators are updated sequentially and correctly reflect the price movements.
viii. **Validation**:
- Confirm that `High > Open`, `High > Close`, `Low < Open`, and `Low < Close`.
- Ensure volume aligns with the stage's trend (e.g., increasing, decreasing, stable).
c. **Handle Price Adjustments for Strategy Requirements**:
- Apply any additional price movements such as breakouts, pullbacks, or consolidations as specified by the strategy.
- This may involve adjusting the `Open`, `Close`, `High`, and `Low` prices to create specific patterns or trends.
4. **Finalize Data Structure**:
- Compile all generated candles into a structured format, ensuring each candle contains:
- `date` (YYYY-MM-DD)
- `open` (float)
- `high` (float)
- `low` (float)
- `close` (float)
- `volume` (integer)
5. **Indicator Compilation** (if applicable):
- Aggregate all indicator values calculated during candle generation.
- Ensure indicators are synchronized with the corresponding candle dates.
6. **Example Calculation**:
- **Bullish Candle Example**:
- Previous Close: `$100.00`
- Open: `$100.00`
- Close: `$100.00 + ($100.00 * 1%) = $101.00`
- High: `Max($100.00, $101.00) + ($101.00 * 0.5%) = $101.00 + $0.505 = $101.51`
- Low: `Min($100.00, $101.00) - ($100.00 * 0.3%) = $100.00 - $0.30 = $99.70`
- Volume: `1,000,000 * (1 + 0.10) = 1,100,000`
7. **Final Checks**:
- After generating all candles, perform a final review to ensure all calculations and data points adhere strictly to the defined formulas and strategy requirements.