You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
I tried to use this article to make my own program, but it's too complicated for my simple purposes. Here I tried to make a simple program, but the compiler found (only) one error: Class with "no type". And no matter what I put in as a Class "type" or "name" there was no change.
Here is the beginning. What am I doing wrong?:
//| KaufVerkauf.mq5 |
//| Copyright .... 2012 |//| http://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright .... 2012"
#property link "http://www.mql5.com"
#property version "1.00"
//+------------------------------------------------------------------+
//| Include |
//+------------------------------------------------------------------+
#include <Expert\Expert.mqh>
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| Expert object initialization |
//+------------------------------------------------------------------
//---- handles for indicators
int RSI_handle = 0; // handle of the indicator iRSI
int ADX_handle = 0; // handle of the indicator iADX
int Force_handle = 0; // handle for the indicator iForce
int AD_handle = 0; // handle for the indicator iAD
int Close_handle = 0;
int High_handle = 0;
int Low_handle = 0;
int VTick_handle = 0;
int VReal_handle = 0;
int sig =0;
double MqlParams[]; // Array for storing indicator params
//+------------------------------------------------------------------+
//| Expert initialization function RSI |
//+------------------------------------------------------------------+
Class CExpertSignal
{
private:
int OnInit()
//--- creation of the indicator iRSI...........
Thanks alot.
I try to test this:
- Download your code, copy to MQL5 and compiled: successful no errors.
- But EA cannot run, it generate an error as below:
Please help me what wrong with this parameters:
Once again, thank you alot.
First off all I would like to thank the author(s) for this article.
I'm new to MetaTrader, MQL5 and Forex trading, so these articles are really useful!
When I test this EA, I notice that for closing a long position, it gives a sell signal with a doubled lot size.
Why does it not only close my long position, but directly enters a short at the same signal?
As a first test to understand all the programming, I would like to only go long, so only open and close a long
position without entering a short position at the closing/sell signal.
Thanks in advance.
Good afternoon,
Please advise me how to increase (top up) a position in an Expert Advisor, which is written on the basis of MQL5 Wizard and where positions are opened via
virtual int LongCondition();
virtual int ShortCondition();
I wrote the robot according to the recommendations in the article
https://www.mql5.com/en/articles/367 "create a trading robot in 6 steps" and it works fine, but attempts to influence the position size (no matter whether to increase or decrease)
(no matter whether to increase or decrease) through repeated generation of the condition in , for example in
LongCondition();
does not lead to anything, the already open position is not changed, it can only be deleted by executing the close condition or by triggering sl , tp.
I like the MQL5 Wizard, you can easily and quickly "build" a multi-indicator Expert Advisor, change the sl tracking module, change the money management module.
But my attempt to write an Expert Advisor that opens a minimum position when a condition is formed by one indicator and increases (fills) the position when the trend is confirmed by another indicator.
I came across the above described problem - the already opened position does not change when the signal to open through. e.g. LongCondition() is issued again;
Thank you.
If I run this example in the mt5 strategy tester, and choose the asset as pex. Vale5, genetic algorithm, d1, ohlc 1 minute, max balance, it gives an error!
If I run it on a forex pair, the same optimisation seems to complete (I didn't expect it to because it takes too long on the local agent).
The error that appears in the tester's diary, in this case for Vale5, has something to do with OnInit. Has anyone detected the same problem? If so, have you reached any solutions and/or conclusions?
Thanks if anyone can help!
If I run this example in the mt5 strategy tester, and choose the asset as pex. Vale5, genetic algorithm, d1, ohlc 1 minute, max balance, it gives an error!
If I run it on a forex pair, the same optimisation seems to complete (I didn't expect it to because it takes too long on the local agent).
The error that appears in the tester's diary, in this case for Vale5, has something to do with OnInit. Has anyone detected the same problem? If so, have you reached any solutions and/or conclusions?
Thanks if anyone can help!
Hi, please provide additional information, such as an error log or screenshots, so we can try to better analyse the problem.
A simple description like the one you gave above doesn't help much in identifying the problem.
Best regards,
Malacarne
I do not have any experience (yet) with programming in MQL, but I do have some experience in programming in other languages. One of the easiest errors to make in programming (my specific class was Java, which is very similar in style to C++ and apparently MQL) is not closing the braces properly. It is one of the easiest errors to make, and conversely, also one of the harder ones to find. KJG, as far as the closing a long and heading right into a short, it is probably what this style of EA is designed to do. I have seen many trading styles with just that type of setup, I believe they were designed for a market that has a lot of volatility and wide price swings happening all the time, like something that would likely happen on a minute time frame chart.
Good article as well. I definitely will be making use of this one and many others here I am sure.
Good evening,
You are getting the following error when you try to test the robot.
2017.07.04 18:20:27.404 tester stopped because OnInit failed
Am I doing something wrong or is there a setting to make in the robot?
Cheers
Carlos F.
The different stages of construction are well explained. It's a clear and useful job, especially for those who have never developed a robot. Thank you