O Jeito Mais Fácil (e Preguiçoso) de Criar um Robô Lucrativo no MT5!!
Introduction to the Moving Average Crossover Robot
Overview of the Robot
- The video introduces a moving average crossover robot, one of the oldest trading setups still effective today.
- The presenter emphasizes that even those with minimal programming knowledge can model any type of robot using his programming base.
- This programming base includes built-in features such as break-even, trailing stop, time filters, and a results panel.
Features of the Programming Base
- The system comes with a user-friendly panel displaying key information like active trades, magic number, volume, date, and profit/loss statistics.
- A simplified setup is chosen to make it accessible for users who may find complex programming challenging.
Understanding the Crossover Setup
Mechanics of Moving Averages
- The setup involves two moving averages: a short-term average that closely follows price and a long-term average that lags behind.
- When the short-term average crosses above the long-term average, it signals a potential upward trend; conversely, crossing below indicates a downward trend.
Application in Trading
- This simple yet ancient strategy is still widely used for capturing long trades and swing trading opportunities.
Backtesting and Code Structure
Backtesting Capabilities
- Users can perform backtests with this robot; it's part of an existing package available for subscribers.
Code Insights
- The code consists of approximately 2,500 lines; however, only about 15 to 20 lines require user modifications for operational adjustments.
Setting Up Parameters
Configuration Options
- Users are guided on setting parameters such as graphical timeframes and magic numbers essential for running multiple robots simultaneously without order conflicts.
Importance of Magic Number
Understanding Trading Bots and Their Features
Overview of Trading Bot Functions
- The trading bot operates with a stop loss order that remains pending at the brokerage until triggered. Users can set operational hours for the bot, currently configured from 9:20 AM to 5:30 PM.
- Two moving averages are utilized in the strategy, specifically a 20-period and a 50-period average. Users can adjust parameters such as type (exponential or simple) and visual properties like color and thickness.
- Key features include "break even" functionality, which adjusts the stop loss to break even after a specified number of points gained, enhancing risk management.
- Financial goals can be set within the system; users can configure limits for losses or gains (e.g., stopping trading after R$50 loss or gain).
- The graphical interface allows customization of panel dimensions to ensure proper display on various monitor sizes since it is not responsive by default.
Testing and Execution of Trades
- To initiate trades, an event such as crossing of moving averages must occur. Orders are executed based on these crossings, with real-time tracking of performance.
- The bot demonstrates effective execution by entering trades upon crossover signals—both buy and sell orders are placed accordingly while managing stop losses effectively.
Advanced Features: Break Even and Trailing Stop
- The break even feature activates when a certain profit threshold is reached (e.g., 100 points), allowing users to secure their position without incurring losses.
- Users have flexibility in setting how far above or below the entry point the break even order will be placed, providing tailored risk management strategies.
- A visual indicator shows how much price movement is needed to trigger the break even order, enhancing user awareness during trading sessions.
Performance Insights
- The Blackbox robot operates under a closed strategy model where most parameters are fixed to maintain consistency in trading decisions.
- Current performance metrics indicate profitability with R$465 earned on that day alone, showcasing its effectiveness over time with consistent results reported weekly and monthly.
Community Engagement and Testing Opportunities
- Users can follow performance updates through community channels like Telegram where results from different traders are shared regularly.
Understanding Trading Robots and Parameters
Initial Investment Requirements
- The minimum investment to operate the trading robot is around R$ 4,000, with a recommended amount of R$ 10,000 for effective operation.
- Starting with insufficient funds may lead to challenges during withdrawal moments, emphasizing the need for adequate capital.
Trading Stop Mechanism
- The presentation discusses how to configure the trading stop parameters within the robot's code.
- A "trailing stop" is introduced as a trigger point that adjusts the stop loss based on price movements, maintaining a distance of 200 points from the last price.
Financial Goals Configuration
- Users can set financial goals such as profit or loss limits; once one limit is reached, the robot will cease operations for the day.
- An example shows that after reaching a loss of R$ 50, a notification appears indicating that one of the daily limits has been hit.
Code Customization Insights
- The speaker transitions into explaining how users can modify the robot's code to change setups according to their strategies.
- Emphasis is placed on filling in specific inputs related to strategy parameters without altering other pre-configured settings in the code.
Strategy Input Parameters
- Users are guided on where to input their strategy parameters within MetaTrader’s strategy editor.
- Key inputs include moving average periods and calculation methods; these are crucial for defining how indicators function within trades.
Indicator Declaration and Setup
- The process involves declaring variables for indicators used in strategies; specifically mentioning two moving averages and their respective buffers.
Understanding the Code for Trading Signals
Overview of the Code Functionality
- The code is comprehensive, performing assignments and checking for errors. It returns any failures encountered during execution.
- Utilizes
array set a seriesto sort values within a buffer, specifically for signal averages. This sorting is crucial for accurate trading signals.
- Demonstrates how to use candle data: if the closing price is above the average, it triggers a buy; if below, it triggers a sell.
Adding Indicators and Error Handling
- The function
chart indicator edautomatically adds indicators to the chart when the robot is dragged onto it. Errors in this process are also handled.
- Emphasizes memory management by removing indicators from memory upon robot removal and cleaning buffers using
array free.
Key Modifications in Trading Logic
- Discusses where users need to make changes in the code (around line 1500), focusing on defining buy/sell signals based on moving averages.
- Checks if one moving average crosses below or above another to determine buy/sell signals, highlighting complexity in sending orders.
Implementing Buy/Sell Conditions
- Explains copying buffer information for comparison between buying and selling conditions based on moving average crossovers.
- Mentions that only minor adjustments are needed to create a crossover trading robot; clean pre-programmed code will be provided.
Example of Conditional Logic Implementation
- Provides an example of modifying code: if a candle's closing price exceeds its moving average, it initiates a buy order; otherwise, it sells.
- Clarifies that changing conditional logic is straightforward—only requires adjusting comparisons between candle prices and moving averages.
Testing New Trading Rules
- After modifications, compiles the code and prepares for backtesting with new rules regarding entry points based on price relative to moving averages.
- Describes expected behavior: entering trades when prices are above or below specified averages without waiting for crossovers.
Conclusion of Coding Process