What's wrong

 
Hi, what's missing in this EA, it does not trade, I have tried to make it work but without success. Christer
 
Christer Lundqvist: Hi, what's missing in this EA, it does not trade, I have tried to make it work but without success. Christer
  1. You have not provide any source code. Attach the the file!
  2. Are you trying to test it on a live trading (hopefully on demo account) or are your referring to Strategy Tester.
  3. What symbol? What timeframe? What inputs are you using? etc.
  4. Show us the log output! Have you checked your Experts Log (if live trading) or the Journal log (live or Strategy Tester)?
  5. Provide more details if you want a serious answer!
 
Fernando Carreiro:
  1. You have not provide any source code. Attach the the file!
  2. Are you trying to test it on a live trading (hopefully on demo account) or are your referring to Strategy Tester.
  3. What symbol? What timeframe? What inputs are you using? etc.
  4. Show us the log output! Have you checked your Experts Log (if live trading) or the Journal log (live or Strategy Tester)?
  5. Provide more details if you want a serious answer!

I sent with a file, but it failed the first time, it looks like EA'n trade the wrong way, I'm new to mql5 oop, but I'm trying to learn.

//+------------------------------------------------------------------+
//|                                                   Indicators.mqh |
//|                                                Christer Lundqvist|
//|                                     http://www.expertAdvisor.com |
//+------------------------------------------------------------------+
#property copyright "Crister Lundqvist"
#property link      "http://www.expertAdvisor.com"


#define MAX_COUNT 100


//+------------------------------------------------------------------+
//| Base Class                                                       |
//+------------------------------------------------------------------+

class CIndicator
{
        protected:
                int handle;
                double main[];
                
        public:
                CIndicator(void);
                double Main(int pShift=0);
                void Release();
                virtual int Init() { return(handle); }
};

CIndicator::CIndicator(void)
{
        ArraySetAsSeries(main,true);
}

double CIndicator::Main(int pShift=0)
{
        CopyBuffer(handle,0,0,MAX_COUNT,main);
        double value = NormalizeDouble(main[pShift],_Digits);
        return(value);
}

void CIndicator::Release(void)
{
        IndicatorRelease(handle);
}


//+------------------------------------------------------------------+
//| Moving Average                                                   |
//+------------------------------------------------------------------+

/*

CiMA MA;

sinput string MA;               // Moving Average
input int MAPeriod = 10;
input ENUM_MA_METHOD MAMethod = 0;
input int MAShift = 0;
input ENUM_APPLIED_PRICE MAPrice = PRICE_CLOSE;

MA.Init(_Symbol,_Period,MAPeriod,MAShift,MAMethod,MAPrice);

MA.Main()

*/

class CiMA : public CIndicator
{
        public:
                int Init(string pSymbol,ENUM_TIMEFRAMES pTimeframe,int pMAPeriod,int pMAShift,ENUM_MA_METHOD pMAMethod,ENUM_APPLIED_PRICE pMAPrice);
};

int CiMA::Init(string pSymbol,ENUM_TIMEFRAMES pTimeframe,int pMAPeriod,int pMAShift,ENUM_MA_METHOD pMAMethod,ENUM_APPLIED_PRICE pMAPrice)
{
        handle = iMA(pSymbol,pTimeframe,pMAPeriod,pMAShift,pMAMethod,pMAPrice);
 
Christer Lundqvist: I sent with a file, but it failed the first time, it looks like EA'n trade the wrong way, I'm new to mql5 oop, but I'm trying to learn.
That seems to be an Indicator and not an EA. It is also incomplete code. Please, attach the proper and complete file.
 
Must you must have the entire EA, or are you content with one file from oop or should you have the entire oop I have. There are 5-6 files that are connected.
 
Christer Lundqvist: Must you must have the entire EA, or are you content with one file from oop or should you have the entire oop I have. There are 5-6 files that are connected.

You have provided very little information in order to answer "what's missing in this EA, it does not trade", but you say the project consists of 5-6 files, and claim "I'm new to mql5 oop".

That is way too much code for us to analyse for such a vague question. We are not going to debug so much of your code for you.

Do some debugging of your own. Print out values to your log files and narrow down the problem.

 
Do you have the complete file, 9 files complete.
 
I've tried, but the EA's trading in the wrong direction, I can not see what's wrong, I do not get anything that says it's wrong, I who thought I was so good that I bought book, which I have translated into Swedish from English. I also tried with a Strategy Tester, nothing comes up on it that something is wrong.
 
Christer Lundqvist:
I've tried, but the EA's trading in the wrong direction, I can not see what's wrong, I do not get anything that says it's wrong, I who thought I was so good that I bought book, which I have translated into Swedish from English.
  1. You are using a Template File form the Source Code for Andrew Young's book, yet you failed to say anything about that in your original post. Luckily, I have the book too and the library source, otherwise I would not have been able to compile or test it since you were missing files.
  2. You are using the older code for the source. You should update it to the revised version of the author's code, available from his website.
  3. Your original post stated that it did not trade, yet now you say it is trading in the wrong direction. I tested it in the Strategy Tester and it does trade.
  4. There is nothing wrong with the EA, but obviously that it is "trading in the wrong direction"! It is a TEMPLATE EA file for you to fill in with your own strategy. All it does is just open a trade continuously because it is just an empty example TEMPLATE.

In other words, you have coded nothing! All the code supplied is just the standard code for the book. Nothing else.

The EA is just a template! You have not changed anything in it. As it stands, it just continually places orders. That is all, and it is working just fine in the tester.

So, read the book properly from begin to end and follow the examples and learn from it. Complaining that the sample TEMPLATE EA does not do what you want is foolish if you don't make any changes to it.


 
Thank you Fernando Carreiro, for the information MQL5 The book, I think it is 2 years since I bought the book, finally I turned to you on the forum, I do not want to be a burden to anyone, trading is the only thing I have left after my stroke, I'm lame on the right side of my body, and I'm fighting as best I can. I have lost so much, language, memory, and to think clearly, but I take it at my own pace.