Renko ATR Bot (โดย bl4ckp3n9u1n)

กำไร : -7.33%
ขาดทุนสะสม 26.70%
pips: -48.6
การเทรด 495
ได้กำไร :
ขาดทุน :
ประเภท : เดโม
เลเวอเรจ: 1:30
การเทรด : อัตโนมัติ

Renko ATR Bot การสนทนา

Jul 31 at 05:16
139 การดู
11 Replies
เป็นสมาชิกตั้งแต่ Sep 16, 2020   76 โพสต์
Aug 05 at 07:12
Monday, 5 August, 2024
Updated the trading script and back on track.

Have a new improvements coming out:

Trading pair risk managed during local market trading periods. e.g. AUD maybe stronger during AU trading times and weaker at close whilst EU and US are open and vice-versa.
- proposed trading operations, (open) 08:00 Monday, Sydney, Australia to (close) 16:00 Friday, New York, America
No trading over the weekend and during the December period (or maybe limited and very low risk trades).
- might close out all positions 1 hour before 16:00 New York time, or slowly close out positions 1 hour before closing
Pending orders placed instead of market orders.
- the prediction will place a pending order which is based on the next 15 minute candle 'low' price as an entry with TP and SL levels on each side
- (currently) every 5 minutes there is an analysis to check if the trend is on track and the trading bot can modify the order if conditions change, in saying this, there maybe less trades but they could also more 'wins' than losses overall
ML functions using the previous trading history and predictions to improve overall trading outcomes.
- (working on) sklearn / randomforrest implementation

Potential Improvements:
- FX Pair correlations that are calculated prior to placing an order as the trading bot (LLM's) will analyse which trades will be profitable and also would have a higher confidence level of achieving
 
"Or die trying...." Sonny Crockett, Miami Vice 1980's
เป็นสมาชิกตั้งแต่ Sep 16, 2020   76 โพสต์
Aug 06 at 00:55
bl4ckp3n9u1n posted:
Monday, 5 August, 2024
Updated the trading script and back on track.

Have a new improvements coming out:

Trading pair risk managed during local market trading periods. e.g. AUD maybe stronger during AU trading times and weaker at close whilst EU and US are open and vice-versa.
- proposed trading operations, (open) 08:00 Monday, Sydney, Australia to (close) 16:00 Friday, New York, America
No trading over the weekend and during the December period (or maybe limited and very low risk trades).
- might close out all positions 1 hour before 16:00 New York time, or slowly close out positions 1 hour before closing
Pending orders placed instead of market orders.
- the prediction will place a pending order which is based on the next 15 minute candle 'low' price as an entry with TP and SL levels on each side
- (currently) every 5 minutes there is an analysis to check if the trend is on track and the trading bot can modify the order if conditions change, in saying this, there maybe less trades but they could also more 'wins' than losses overall
ML functions using the previous trading history and predictions to improve overall trading outcomes.
- (working on) sklearn / randomforrest implementation

Potential Improvements:
- FX Pair correlations that are calculated prior to placing an order as the trading bot (LLM's) will analyse which trades will be profitable and also would have a higher confidence level of achieving
 
Tuesday, 06 August

Me being the knob I am was trying to make some improvements as stated yesterday and the trading bot again went rouge.
Early this morning I found an old version that is starting to get the trading back on track again.
After a number of terrible trades I have removed the GBPJPY so now only using the six pairs:

SYMBOLS = ['EURUSD', 'GBPUSD', 'AUDUSD', 'NZDJPY', 'USDJPY', 'EURGBP']

Will leave the trading bot alone today.

I might only just look at the:

Potential Improvements:
- FX Pair correlations that are calculated prior to placing an order as the trading bot (LLM's) will analyse which trades will be profitable and also would have a higher confidence level of achieving
"Or die trying...." Sonny Crockett, Miami Vice 1980's
เป็นสมาชิกตั้งแต่ Sep 16, 2020   76 โพสต์
Aug 06 at 03:21
## UPDATE ## As of writing this the account is down to ~$208 in equity so hopefully the update from 7.0 to 7.1 improves the runs on the board ##

Key Components and Functionality: LLM-trading-bot-07-1.py

This document details the functionality of an LLM-powered trading bot designed for MetaTrader 5 (MT5). The bot uses Large Language Models (LLMs) for market analysis and decision-making while incorporating risk management and fallback mechanisms.

1. Initialization and Setup:

    Imports necessary libraries like pandas, MetaTrader5, and custom utilities.

    Defines constants for trading parameters, including:

        SYMBOLS: List of currency pairs to trade (e.g., EURUSD, GBPUSD).

        TIMEFRAMES: Dictionary specifying timeframes for analysis, execution, and trend identification (M5, M15, H1).

        MAX_RISK_PER_TRADE: Maximum percentage of equity to risk per trade (0.02).

        MAX_DRAWDOWN: Maximum allowed drawdown (0.15).

        DEFAULT_STOP_LOSS_PERCENT: Default stop-loss percentage (0.02).

        DEFAULT_TAKE_PROFIT_PERCENT: Default take-profit percentage (0.01).

        Model-specific parameters like DEFAULT_MODEL, DEFAULT_TEMPERATURE, and DEFAULT_MAX_TOKENS.

    Sets up logging using loguru to record bot activity.

    Initializes global variables for storing:

        Historical candle data for each symbol and timeframe using deques with a maximum length.

        Price predictions generated by the LLM.

        Trade outcomes and performance metrics.

        Model scores to track performance.

2. Rate Limiting and Error Handling:

    Implements rate limiting using the TokenBucket algorithm to prevent exceeding API limits for the LLM.

    Employs a CircuitBreaker pattern to handle temporary service unavailability from the LLM provider.

    Utilizes the tenacity library's retry decorator to handle rate limit exceptions and potential network issues, ensuring robustness.

    Includes custom exceptions: RateLimitException and ServiceUnavailableException.

3. MT5 Interaction:

    login_to_mt5(): Establishes a connection to the MT5 trading account using hardcoded credentials.

    get_account_info(): Retrieves essential account information like balance, equity, margin, and free margin.

    get_open_positions(): Fetches details of all currently open positions, including symbol, type, volume, and profit.

    get_candle_data(): Retrieves historical candle data for a specified symbol and timeframe.

    execute_trade(): Executes trading actions (buy, sell, modify, close) based on the LLM's decisions, managing order types, stop-loss, and take-profit levels.

4. Data Processing and Analysis:

    calculate_available_funds(): Calculates the available funds for trading based on equity, risk parameters, and maximum drawdown limits.

    update_candle_history(): Updates the historical candle data with new incoming candles, maintaining a fixed maximum length.

    store_prediction(): Saves the LLM's price predictions for future comparison and performance evaluation.

    store_trade_outcome(): Records the results of executed trades, including entry/exit prices, profit/loss, and other relevant details.

    get_historical_data(): Retrieves historical data for a given symbol, including candles, predictions, and trades.

    convert_timestamp(): Converts pandas timestamps to ISO format for JSON serialization.

    is_sufficient_data(): Checks if enough historical candle data is available for reliable analysis and decision-making.

    load_correlation_data(): Loads pre-calculated correlation data from JSON files.

    get_correlation(): Retrieves the correlation between two symbols for a given timeframe.

    update_correlated_pairs_risk(): Adjusts the volume of open positions in correlated pairs based on the new trade.

    modify_position(): Sends a request to MT5 to modify an existing position's volume, stop-loss, and take-profit.

    calculate_portfolio_risk(): Calculates the total portfolio risk and the risk associated with highly correlated positions.

    is_trade_allowed(): Determines if a trade is allowed based on calculated portfolio risk and predefined limits.

    adjust_trade_parameters(): Adjusts the stop-loss, take-profit, and volume of a trade based on correlations with other symbols.

5. LLM-Based Decision-Making:

    analyze_market_data(): Constructs a detailed prompt containing market data, account information, historical trade data, and correlation analysis, and sends it to the LLM for analysis. The LLM provides insights on trends, support/resistance levels, and potential trade setups in a JSON format.

    predict_next_candle(): Prompts the LLM to predict the next candle's price and trend for the execution timeframe (M15), considering multiple timeframes and correlations with other currency pairs. The prediction is returned in JSON format.

    compare_prediction_to_actual(): Asks the LLM to evaluate the accuracy of its previous predictions by comparing them to the actual candle data, identifying potential biases, and suggesting improvements. The comparison is returned in JSON format.

    generate_final_analysis(): Based on the initial analysis, prediction, and comparison, the LLM generates a final trading decision (buy, sell, hold, modify, or close), along with a confidence score and rationale. The final analysis is returned in JSON format.

6. Fallback Mechanisms:

    fallback_analysis(): Provides a basic technical analysis based on simple indicators if the LLM fails to generate valid JSON output for the initial analysis.

    fallback_prediction(): Generates a simple prediction based on the latest candle data if the LLM encounters errors during prediction.

    fallback_comparison(): Performs a basic comparison between the prediction and actual data if the LLM-based comparison fails.

    fallback_final_analysis(): Suggests a conservative 'hold' action as a safe fallback if the LLM cannot generate a final decision.

7. Risk and Trade Management:

    validate_sl_tp(): Ensures the validity of stop-loss and take-profit levels based on market conditions and broker restrictions.

    calculate_position_size(): Determines the appropriate position size based on risk tolerance, account equity, and the distance to the stop-loss level, dynamically adjusting based on equity levels and using a base lot size.

8. Performance Tracking:

    update_model_score(): Updates the model's performance score based on the outcome of trades (profit or loss).

    evaluate_trade_outcome(): Determines if a trade was profitable or a loss based on entry and exit prices.

9. Main Execution Loop:

    Connects to the MT5 platform using login_to_mt5().

    Retrieves account information using get_account_info().

    Iterates through the list of SYMBOLS.

    For each symbol:

        Collects candle data for all specified timeframes.

        Performs initial market analysis, prediction, comparison, and final decision-making using the LLM, utilizing the fallback mechanisms when necessary.

        Executes trades based on the final decision, managing risk and available funds.

        Tracks performance metrics and updates the model score.

    Waits for a specified duration before starting the next analysis cycle.

10. Argument Parsing and Execution:

    Uses argparse to parse command-line arguments for model selection, temperature, and max tokens, allowing for customization.

    Initializes and runs the main trading bot loop.

    Handles keyboard interrupts gracefully, allowing for controlled shutdown.

    Manages the MT5 connection shutdown to ensure a clean exit.
"Or die trying...." Sonny Crockett, Miami Vice 1980's
เป็นสมาชิกตั้งแต่ Sep 16, 2020   76 โพสต์
Aug 06 at 03:29
Here is the diagram of the logic.

ไฟล์แนบ :

"Or die trying...." Sonny Crockett, Miami Vice 1980's
เป็นสมาชิกตั้งแต่ Sep 16, 2020   76 โพสต์
Aug 06 at 03:35
Not a Renko Bot - FYI, I changed the bot and used the old account.
See description above.
"Or die trying...." Sonny Crockett, Miami Vice 1980's
เป็นสมาชิกตั้งแต่ Sep 16, 2020   76 โพสต์
Aug 07 at 05:48
Wednesday, 7 August.

I haven't had much time to tweak the trading bot but have a new update.

## UPDATE ##

Deep Dive into the Trading Bot 07-2-2.py Strategy, Logic, and Trading Mechanisms

This document provides a detailed explanation of the strategy, logic, and trading mechanisms employed by the LLM-trading-bot-07-2-2.py trading bot. This bot leverages Large Language Models (LLMs) for market analysis and decision-making, incorporating risk management and fallback mechanisms for robust trading on the MetaTrader 5 (MT5) platform.

Core Strategy:

The bot aims to identify and capitalize on profitable trading opportunities in the forex market by analyzing historical data, predicting future price movements, and making informed decisions based on LLM-driven insights. It operates on a multi-timeframe approach, considering short-term (M5), medium-term (M15), and long-term (H1) trends to gain a comprehensive understanding of the market.

Key Trading Logic:

    Data Acquisition: The bot retrieves historical candle data for predefined currency pairs (EURUSD, GBPUSD, AUDUSD, NZDJPY, EURGBP) across different timeframes (M5, M15, H1). It also gathers account information, open positions, and historical trade data.

    Market Analysis: The bot utilizes an LLM to analyze the collected market data and generate insights on the current market trend, key support and resistance levels, and potential trade setups. This analysis considers factors like candlestick patterns, technical indicators, and correlations between currency pairs.

    Price Prediction: The LLM predicts the next candle's price and trend for the execution timeframe (M15), leveraging historical data, initial analysis, and correlation analysis.

    Prediction Comparison: The bot compares previous predictions with actual market outcomes, providing the LLM with feedback to learn and improve its prediction accuracy.

    Final Decision Making: Based on the initial analysis, prediction, and comparison, the LLM generates a final trading decision (buy, sell, hold, modify, or close) for each currency pair. This decision is accompanied by a confidence score and rationale, explaining the reasoning behind the chosen action.

    Trade Execution: The bot executes the LLM's final decision, placing orders on the MT5 platform with appropriate entry price, stop-loss, and take-profit levels. It calculates position size based on risk tolerance, account equity, and market volatility.

    Trade Management: For existing trades, the bot employs a dynamic profit maximization strategy that includes trailing stops, breakeven adjustments, and profit target adjustments based on market conditions and LLM recommendations.

    Risk Management: The bot incorporates several risk management features:

        Position Sizing: Calculates position size to limit risk per trade and overall portfolio exposure.

        Maximum Drawdown: Sets a maximum allowed drawdown to protect against significant losses.

        Correlation Analysis: Analyzes correlations between currency pairs to identify and mitigate potential risks associated with correlated movements.

        Portfolio Risk Calculation: Calculates total portfolio risk and correlated risk to prevent overexposure to specific currencies or correlated pairs.

How it Trades:

The bot operates on a continuous loop, analyzing market data, generating predictions, and making trading decisions at regular intervals. It employs the following steps for each currency pair:

    Gather Data: Collects historical candle data, account information, open positions, and historical trade data.

    Analyze Market: Uses the LLM to analyze the collected data and generate insights on market trends and potential trade setups.

    Predict Price: Predicts the next candle's price and trend for the execution timeframe using the LLM.

    Compare Prediction: Compares previous predictions with actual data to evaluate accuracy and identify areas for improvement.

    Make Decision: Generates a final trading decision (buy, sell, hold, modify, or close) based on the analysis, prediction, and comparison.

    Execute Trade: Places orders on the MT5 platform according to the final decision, managing position size and risk.

    Manage Trade: For existing trades, applies trailing stops, breakeven adjustments, and profit target adjustments based on market conditions and LLM recommendations.

    Monitor and Repeat: Continuously monitors the market and repeats the process at predefined intervals.

Fallback Mechanisms:

The bot includes fallback mechanisms to handle situations where the LLM fails to generate valid output or encounters errors. These fallbacks provide basic technical analysis, predictions, and decisions based on predefined rules and indicators, ensuring that the bot can continue to operate even in challenging conditions.

Key Features and Innovations:

    LLM-Driven Analysis and Decision Making: Leverages the power of LLMs to analyze market data and generate intelligent trading decisions.

    Multi-Timeframe Analysis: Considers short-term, medium-term, and long-term trends for a comprehensive market perspective.

    Dynamic Risk Management: Adjusts risk parameters and position sizing based on market conditions and account equity.

    Profit Maximization Strategies: Employs trailing stops, breakeven adjustments, and profit target adjustments to maximize potential profits.

    Correlation Analysis: Identifies and mitigates risks associated with correlated currency pair movements.

    Fallback Mechanisms: Provides alternative trading logic in case of LLM failures or errors.

Conclusion:

The LLM-trading-bot-07-2-2.py trading bot represents an innovative approach to forex trading, combining the analytical capabilities of LLMs with robust risk management and fallback mechanisms. Its ability to analyze complex market data, predict future price movements, and make informed trading decisions makes it a valuable tool for traders seeking to maximize profits and navigate the dynamic forex market. Remember that all trading involves risk, and past performance is not indicative of future results. Always use caution and test any trading strategy thoroughly before deploying it in a live trading environment.
"Or die trying...." Sonny Crockett, Miami Vice 1980's
เป็นสมาชิกตั้งแต่ Sep 16, 2020   76 โพสต์
Aug 13 at 13:11
13 August 2024
Scrapped most of the idea from the other week.
All bots have the base Mixture of Agents (LLM) that make the trading decisions.
Finding the M5, H1 and H4 time frames are good for day trading.

This is not a Renko, ATR, has pair correlations.

I have added in the bots to start 04:00 EST (US) Sunday / 08:00 AEST (AU) Monday and stop 16:00 EST (US) Friday.
Over the weekend the bots sleep for 1 hour and then checks the time until it needs to start again.

The bots will automatically swap broker exchanges as one closes and another one opens.
"Or die trying...." Sonny Crockett, Miami Vice 1980's
เป็นสมาชิกตั้งแต่ Sep 16, 2020   76 โพสต์
Aug 13 at 21:12
bl4ckp3n9u1n posted:
13 August 2024
Scrapped most of the idea from the other week.
All bots have the base Mixture of Agents (LLM) that make the trading decisions.
Finding the M5, H1 and H4 time frames are good for day trading.

This is not a Renko, ATR, has pair correlations.

I have added in the bots to start 04:00 EST (US) Sunday / 08:00 AEST (AU) Monday and stop 16:00 EST (US) Friday.
Over the weekend the bots sleep for 1 hour and then checks the time until it needs to start again.

The bots will automatically swap broker exchanges as one closes and another one opens.
Will leave this to trade for the rest of the week.

Next week may change the Risk to Reward Ratio from 1.5 to 2.0.
"Or die trying...." Sonny Crockett, Miami Vice 1980's
เป็นสมาชิกตั้งแต่ Sep 16, 2020   76 โพสต์
Aug 14 at 06:14
## SENTIMENT UPDATE ##

After the early trades placed today and seeing the trends and what the community had also placed, I have now include a 'final sentiment' confirmation after all the symbol analysis.

Example 1: Confirming Trade (BUY GBPUSD)

    Sentiment: Bullish (65% Long)

    LLM Signal: Buy (Probability: 0.8)

    Reasoning: Uptrend, Oversold RSI, Double Bottom pattern

    Decision: EXECUTE TRADE (Sentiment confirms LLM signal)

Example 2: Not Confirming Trade (SELL EURUSD)

    Sentiment: Bullish (55% Long)

    LLM Signal: Sell (Probability: 0.75)

    Reasoning: Downtrend, Potential Double Top (needs confirmation)

    Decision: DO NOT EXECUTE TRADE (Sentiment contradicts LLM signal)


"Or die trying...." Sonny Crockett, Miami Vice 1980's
เป็นสมาชิกตั้งแต่ Sep 16, 2020   76 โพสต์
Aug 15 at 06:25
15 Thursday 2024

After checking the trading status I noticed a few trades that were in negative territory that closed and at the time for no apparent reason such as a SL.

Tip of the day is to remove old code / rules that lay dormant until a trigger you forgot about ends up wiping out a days profit.

New sentiment trend confirmation now filtering out 90% of trade execution signals which is good but obviously will take longer to see any action. The overall riding the trend when executing a trade now should help with more profit as well.
"Or die trying...." Sonny Crockett, Miami Vice 1980's
เป็นสมาชิกตั้งแต่ Sep 16, 2020   76 โพสต์
Aug 15 at 12:07
bl4ckp3n9u1n posted:
15 Thursday 2024

After checking the trading status I noticed a few trades that were in negative territory that closed and at the time for no apparent reason such as a SL.

Tip of the day is to remove old code / rules that lay dormant until a trigger you forgot about ends up wiping out a days profit.

New sentiment trend confirmation now filtering out 90% of trade execution signals which is good but obviously will take longer to see any action. The overall riding the trend when executing a trade now should help with more profit as well.
Flowchart for the bot

ไฟล์แนบ :

"Or die trying...." Sonny Crockett, Miami Vice 1980's
เป็นสมาชิกตั้งแต่ Sep 16, 2020   76 โพสต์
Aug 20 at 01:49
Key Features

Multi-Timeframe Analysis: Our bot analyzes market data across multiple timeframes (M5 and M15) to identify robust trading opportunities.
Advanced Indicator Suite: Utilizes a comprehensive set of technical indicators, including Moving Averages, RSI, MACD, and ATR, for thorough market analysis.
AI-Powered Decision Making: Employs state-of-the-art Large Language Models to interpret market data and generate trading signals.
Dynamic Risk Management: Implements adaptive position sizing and risk management strategies to protect your capital.
Multiple Currency Pairs: Generates signals for AUDUSD, GBPUSD, EURUSD, and USDCAD.
Real-Time Market Execution: Connects directly to MetaTrader 5 for efficient signal generation and trade execution.

Signal Generation Process

Data Collection: The bot gathers real-time price data and calculates technical indicators for each monitored currency pair.
AI Analysis: Our advanced LLM analyzes the market data, considering current price action, indicator values, and recent market behavior.
Signal Creation: Based on the AI analysis, the bot generates a comprehensive trade setup, including:

Trade direction (buy/sell)
Entry price
Stop loss level
Take profit level
Position sizing recommendation
Scaling strategy
Partial profit levels
Confidence level


Execution: Signals meeting our strict probability threshold (70% or higher) are executed in our account and simultaneously sent to subscribers.

Signal Quality Assurance

Probability Threshold: Only signals with a confidence level of 70% or higher are executed and shared.
Risk-Reward Ratio: All trades aim for a minimum 1.5:1 risk-reward ratio.
Continuous Monitoring: Our bot actively manages open positions, implementing trailing stops and taking partial profits when appropriate.
"Or die trying...." Sonny Crockett, Miami Vice 1980's
You must be connected to Myfxbook in order to leave a comment
*การใช้งานเชิงพาณิชย์และสแปมจะไม่ได้รับการยอมรับ และอาจส่งผลให้บัญชีถูกยกเลิก
เคล็ดลับ: การโพสต์รูปภาพ/youtube url จะฝังลงในโพสต์ของคุณโดยอัตโนมัติ!
เคล็ดลับ: พิมพ์เครื่องหมาย @ เพื่อป้อนชื่อผู้ใช้ที่เข้าร่วมการสนทนานี้โดยอัตโนมัติ