- Canberk Dogan Denizli: Here is an example of MQL5 code for a moving average crossover robot:
double ma_short = iMA(_Symbol, _Period, 12, 0, MODE_SMA, PRICE_CLOSE, 0); double ma_long = iMA(_Symbol, _Period, 24, 0, MODE_SMA, PRICE_CLOSE, 0);
OrderSend(_Symbol, OP_BUY, 0.1, Ask, 3, Bid-StopLoss*Point, Ask+TakeProfit*Point, "MA Cross", 12345, 0, Green);
MT5 iMA does not return a double, and does not contain a bar index. MQL5 OrderSend only has two. That is NOT MQL5 code.
-
SetInputParameters
There is no such function in MQLx
-
You buy at the Ask and sell at the Bid. Pending Buy Stop orders become market orders when hit by the Ask.
-
Your buy order's TP/SL (or Sell Stop's/Sell Limit's entry) are triggered when the Bid / OrderClosePrice reaches it. Using Ask±n, makes your SL shorter and your TP longer, by the spread. Don't you want the specified amount used in either direction?
-
Your sell order's TP/SL (or Buy Stop's/Buy Limit's entry) will be triggered when the Ask / OrderClosePrice reaches it. To trigger close at a specific Bid price, add the average spread.
MODE_SPREAD (Paul) - MQL4 programming forum - Page 3 #25 -
The charts show Bid prices only. Turn on the Ask line to see how big the spread is (Tools → Options (control+O) → charts → Show ask line.)
Most brokers with variable spreads widen considerably at end of day (5 PM ET) ± 30 minutes.
My GBPJPY shows average spread = 26 points, average maximum spread = 134.
My EURCHF shows average spread = 18 points, average maximum spread = 106.
(your broker will be similar).
Is it reasonable to have such a huge spreads (20 PIP spreads) in EURCHF? - General - MQL5 programming forum (2022)
-

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Trading robots, also known as Expert Advisors (EAs) in the MQL5 language, have become increasingly popular in the financial markets. With the advancement of artificial intelligence and machine learning techniques, trading robots can now incorporate sophisticated algorithms that can learn from data and make intelligent trading decisions.
However, developing trading robots with advanced AI and neural networks is not without its challenges. One of the main difficulties is the complexity of the algorithms involved. Neural networks can have many layers and parameters, and optimizing them can be a time-consuming process. Additionally, creating a trading strategy that performs well in different market conditions can be challenging.
In this discussion, we can explore the challenges of developing trading robots with advanced AI and neural networks and discuss strategies for overcoming these challenges. We can share tips on how to optimize neural network parameters and how to create effective trading strategies. We can also discuss the best practices for testing and backtesting trading robots to ensure their reliability and accuracy.
Overall, this topic can be a great opportunity for developers to share their experiences and learn from each other on the complex and rewarding journey of building trading robots with advanced AI and neural networks.
One of the key features of MQL5 is its support for machine learning libraries, such as TensorFlow and PyTorch. These libraries can be integrated with MQL5 to create powerful trading robots that can learn from data and make intelligent decisions.
To use these libraries, developers can write custom code in MQL5 to interface with the machine learning libraries. This involves creating functions to load data into the library, train the neural network, and make predictions based on the trained model. Developers can also create custom indicators and other tools to visualize the data and results of the machine learning algorithms.
One challenge of using machine learning in trading robots is the need for large amounts of data. Developers need to gather and process data from multiple sources, such as financial databases and news feeds, to train the neural network effectively. Additionally, developers need to carefully select the data to ensure that it is relevant to the trading strategy and free of biases.
Another challenge is the optimization of the neural network's parameters. This involves tuning the values of the network's hyperparameters, such as the number of layers, the number of neurons in each layer, and the learning rate. Developers can use various techniques, such as grid search and random search, to optimize these parameters and find the best configuration for the network.
MQL5 also provides a range of tools for testing and backtesting trading robots. The built-in Strategy Tester allows developers to test their robots on historical data and evaluate their performance. Additionally, MQL5 supports real-time testing and optimization, which allows developers to fine-tune their robots based on current market conditions.
In conclusion, developing trading robots with advanced AI and neural networks in MQL5 requires a combination of technical skills in programming and machine learning, as well as a deep understanding of the financial markets. MQL5's support for machine learning libraries and advanced testing and optimization tools make it a powerful platform for developing intelligent trading robots.
Here is an example of MQL5 code for a moving average crossover robot:
Here's an example of how you can create a simple trading robot using a neural network in MQL5: