Programming & Code AI Prompt
MT5 Horizontal Trend EA
Develops a MetaTrader 5 EA identifying horizontal trends on H1, placing breakout orders, managing trades with breakeven and lot scaling. Perfectly crafted free system prompt or custom instructions for ChatGPT, Gemini, and Claude chatbots and models.
You are to develop an Expert Advisor (EA) for MetaTrader 5 using MQL5 that identifies and trades horizontal (flat or range-bound) trends specifically on the H1 timeframe. Requirements and Functionality: 1. **Horizontal Trend Identification:** - Detect horizontal trends by confirming the presence of 2 or 3 equal highs (maximums) and 2 or 3 equal lows (minimums). - Upon confirmation, a static rectangle must be drawn on the chart encompassing these highs and lows; this rectangle should not move as new bars form. 2. **Order Placement:** - Once a horizontal trend is confirmed, the EA should: - Place a Buy Stop order just above the upper boundary (line) of the horizontal trend. - Place a Sell Stop order just below the lower boundary (line) of the horizontal trend. 3. **Breakout Confirmation and Trade Execution:** - Monitor breakout points and confirm clear breakouts only, effectively filtering out false breakouts. - When a confirmed breakout occurs, the corresponding pending order (Buy Stop or Sell Stop) should be triggered. 4. **Trade Management:** - Take Profit (TP) for both Buy and Sell orders: - Set equal to the height of the horizontal trend (distance between upper and lower boundaries). - Stop Loss (SL): - For Buy orders, SL should be at the lower boundary of the horizontal trend. - For Sell orders, SL should be at the upper boundary. - Implement a breakeven function that activates after any order is triggered: - Move SL to the entry price to secure against losses once trade is in profit. 5. **Lot Size Management:** - Begin trading with an initial lot size (e.g., 0.1 lots). - After achieving a 50% profit increase relative to the starting account balance, double the lot size. - This scaling applies proportionally: for example, doubling lots after 50% profit regardless of whether the starting balance was $1,000 or $10,000. Implementation Notes: - Ensure the rectangle drawn for the horizontal trend is static and does not adjust with incoming new bars. - Verification of equal highs and lows should allow a small tolerance to account for minor price variances. - False breakout filtering should be robust to avoid premature order execution. # Steps 1. Scan H1 historical data for horizontal trends as per specified criteria. 2. Confirm 2-3 equal highs and lows, and draw a static rectangle on the chart. 3. Place Buy Stop and Sell Stop pending orders aligned as described. 4. Monitor live price for breakout confirmation. 5. Trigger corresponding pending order on confirmed breakout. 6. Set TP and SL according to the trend's range. 7. Activate breakeven SL after order moves into profit. 8. Track account balance growth and adjust lot size by doubling after each 50% gain. # Output Format Produce full MQL5 code for the EA with inline comments explaining key sections. Include clear structure: initialization, trend detection, drawing, order management, breakout confirmation, trade management, lot sizing, and breakeven functionality. # Example [No code example needed, but code must include drawing of static rectangle with 2-3 equal highs/lows confirmation, Buy Stop and Sell Stop order placement, breakout confirmation logic, TP/SL settings based on trend height, breakeven, and lot scaling after profit targets.] # Notes - The EA should operate solely on the H1 timeframe. - Price equality tolerance must be configurable. - Breakeven activation should only occur after reaching a defined profit margin. - Consider market conditions and ensure the EA handles errors gracefully. - Use MQL5 best practices for order management and event handling. Answer with the complete and well-commented MQL5 code implementing all above features.
Create your own custom GPT chatbot with your own data and knowledge. Use for customer support, internal knowledge sharing, or anything else you can imagine.





More Programming & Code Prompts
1-Minute Scalping EA
Generates an MT4/MT5 Expert Advisor for 1-minute scalping with SL and TP settings.
1-Minute Trading Script
Creates a script for trading on a 1-minute chart using documentation guidelines.
1-Minute Trading Script
Creates a trading script for 1-minute chart buy/sell actions using provided documentation.
1-Minute Trading Script
Creates a script for buying/selling on a 1-minute chart using technical indicators.
1-Minute Trading Script
Generate a trading script for a 1-minute chart.
1-Minute Trading Script
Guidelines to create a trading script for 1-minute charts.
1-Minute Trading Script
Generate a 1-minute buy/sell trading script using documentation.
1-Minute Trading Script
Generates a trading script to automate buy/sell actions on a 1-minute chart.