3.0 KiB
You are tasked with generating a PineScript trading strategy that works in TradingView's strategy tester and can be used to send actual orders to a brokerage. Follow these instructions carefully to create a strategy based on the provided framework.
- Trend Determination: Analyze the user's input for trend determination: <user_trend_indicator> {{USER_TREND_INDICATOR}} </user_trend_indicator>
If the user has provided a specific indicator, use it. Otherwise, choose an appropriate indicator to determine the market trend. Ensure that the strategy only allows entries aligned with the trend.
- Entry Confirmations: Review the user's input for entry confirmations: <user_entry_confirmations> {{USER_ENTRY_CONFIRMATIONS}} </user_entry_confirmations>
Implement between 1 and 3 confirmations for entry. If the user has provided specific indicators, use them. Otherwise, select appropriate indicators that complement the trend determination.
- Exit Strategy: Examine the user's input for the exit strategy: <user_exit_strategy> {{USER_EXIT_STRATEGY}} </user_exit_strategy>
Implement a stop loss and profit target based on the user's input. If the user hasn't specified a method, choose an appropriate approach (e.g., indicator-based, static R:R ratio).
- Parameter Configuration: Set up the strategy parameters based on the user's input: <user_parameters> {{USER_PARAMETERS}} </user_parameters>
Include configurations for:
- Key indicator parameters
- Instrument to trade (default to chart)
- Timeframe (default to chart)
- Trading window (e.g., 9:30 AM - 4:00 PM EST)
- Number of contracts to trade
- Any other relevant settings
-
PineScript Code Generation: Generate the PineScript code for the strategy, incorporating all the elements above. Use clear variable names and add comments to explain each section of the code.
-
Output Format: Provide your response in the following format:
<strategy_summary> Briefly describe the key components of the strategy, including the trend determination method, entry confirmations, and exit strategy. </strategy_summary>
<pinescript_code> // Strategy Name: [Give your strategy a descriptive name] // Author: AI Assistant // Date: [Current date]
// Strategy Parameters [Include all configurable parameters here]
// Trend Determination [Include trend determination code]
// Entry Confirmations [Include entry confirmation code]
// Exit Strategy [Include exit strategy code]
// Strategy Logic [Include main strategy logic, combining trend, entry, and exit components]
// Plotting (optional) [Include any plotting code for visual representation on the chart] </pinescript_code>
<usage_instructions> Provide brief instructions on how to use the strategy in TradingView, including how to adjust parameters and any important considerations for live trading. </usage_instructions>
Ensure that the generated PineScript code is complete, well-commented, and ready to be used in TradingView's strategy tester. The code should also be suitable for sending actual orders to a brokerage when properly configured.