Overview
This prompt aims to guide developers in creating a Python trading bot using AI for market analysis and trading execution. Programmers and traders will benefit by gaining insights into building effective automated trading systems.
Prompt Overview
Purpose: This bot aims to automate trading decisions using AI-driven analysis of candlestick data.
Audience: Targeted towards traders seeking to enhance their strategies with automated trading solutions.
Distinctive Feature: It intelligently avoids ranging markets while implementing smart risk management techniques.
Outcome: Users can expect improved trading performance through data-driven insights and automated execution.
Quick Specs
- Media: Text
- Use case: Generation
- Industry: Cryptocurrency & Blockchain, Stock Brokerage & Trading
- Techniques: Chain-of-Thought, Decomposition, Structured Output
- Models: Claude 3.5 Sonnet, Gemini 2.0 Flash, GPT-4o, Llama 3.1 70B
- Estimated time: 10-20 minutes
- Skill level: Intermediate
Variables to Fill
- [9, 21] – 9, 21
- [symbol] – Symbol
- [interval] – Interval
- [limit] – Limit
Example Variables Block
- [symbol]: BTCUSDT
- [interval]: 1m
- [limit]: 100
The Prompt
Create a detailed Python trading bot that utilizes artificial intelligence to analyze the most recent 100 candlestick data collected across three different timeframes within a 1-minute interval.
The bot should leverage price action analysis to identify trading opportunities, ensuring it intelligently follows market trends. Additionally, incorporate features for smart stop-loss and take-profit levels. The bot must have explicit logic to avoid trading in ranging markets and ensure proper execution of buy and sell orders.
### Steps
1. Data Retrieval:
Implement a function to fetch the latest 100 candlestick data from a trading API for three timeframes (e.g., 1-minute, 5-minutes, 15-minutes).
2. Market Analysis:
Use AI techniques to analyze market trends based on price action from the candlestick data. Identify signals for market entry and exit points.
3. Trading Logic:
Define specific rules to determine when to place buy/sell orders. Ensure that the bot scans for trending markets and avoids ranging markets.
4. Risk Management:
Incorporate smart stop-loss and take-profit strategies. Allow configurable parameters for risk management.
5. Order Execution:
Develop functions to execute buy and sell orders seamlessly while monitoring for success or failure responses from the trading API.
6. Testing:
Backtest the bot using historical data to evaluate its performance and make adjustments as necessary.
### Output Format
The output should provide the Python code for the trading bot, clearly organized into sections with comments explaining the purpose of each part. It should also include example configurations for the bot, detailing how to set parameters such as stop-loss and take-profit levels, timeframe selection, and risk management settings.
### Examples
– Example Configuration:
“`python
config = {
‘stop_loss’: 0.03, # 3% stop loss
‘take_profit’: 0.05, # 5% take profit
‘timeframe’: ‘1m’, # Use 1-minute interval
’emas’: [9, 21] # Exponential moving averages for analysis
}
“`
– Example Function for Data Retrieval:
“`python
import requests
def get_candlestick_data(symbol, interval, limit=100):
response = requests.get(f’https://api.example.com/candlesticks?symbol=[symbol]&interval=[interval]&limit=[limit]’)
return response.json()
“`
Screenshot Examples
How to Use This Prompt
- [DATA_RETRIEVAL]: Fetch latest candlestick data from API.
- [MARKET_ANALYSIS]: Analyze trends using AI techniques.
- [TRADING_LOGIC]: Define rules for buy/sell orders.
- [RISK_MANAGEMENT]: Implement stop-loss and take-profit strategies.
- [ORDER_EXECUTION]: Execute buy/sell orders with API.
- [TESTING]: Backtest bot performance with historical data.
- [CONFIGURATION]: Set parameters for trading strategies.
- [PRICE_ACTION]: Analyze price movements for trading signals.
Tips for Best Results
- Data Retrieval: Implement a function to fetch the latest 100 candlestick data from a trading API for three timeframes (1-minute, 5-minutes, 15-minutes).
- Market Analysis: Use AI techniques to analyze market trends based on price action from the candlestick data, identifying signals for market entry and exit points.
- Trading Logic: Define specific rules to place buy/sell orders, ensuring the bot scans for trending markets and avoids ranging markets.
- Risk Management: Incorporate smart stop-loss and take-profit strategies with configurable parameters for effective risk management.
FAQ
- What is the purpose of a trading bot?
A trading bot automates trading decisions based on market analysis and predefined strategies. - How does the bot analyze market trends?
It uses AI techniques to evaluate price action from recent candlestick data for signals. - What is the significance of stop-loss and take-profit?
They help manage risk by automatically closing trades at predetermined loss or profit levels. - Why should the bot avoid ranging markets?
Ranging markets lack clear trends, making it difficult to predict price movements effectively.
Compliance and Best Practices
- Best Practice: Review AI output for accuracy and relevance before use.
- Privacy: Avoid sharing personal, financial, or confidential data in prompts.
- Platform Policy: Your use of AI tools must comply with their terms and your local laws.
Revision History
- Version 1.0 (February 2026): Initial release.


