Include file breaks mysteriously

 

I want to copy an EA, change it and make another fairly similar EA.


The EA uses an .mqh include. I open the include in Meta Editor. I press F7 (compile). No errors.


I drag and copy it with another name. I open it in Meta Editor. I make NO CHANGES to it. No change whatsoever. It is an exact copy of the original include. I press F7 (compile) and get a ton of errors.

For example:

double  CurrentPrice = MarketInfo(ChartSymbol(0), MODE_BID);


Compiler says: 'MarketInfo' - undeclared identifier    main_functions.mqh    11    23


Why?

 
  1. You don't compile include files. You include them in your main file and compile that.
  2. There is no such MarketInfo in the MQL5 documentation.
 

How should someone know about your "ton of errors" except you? Also you didn't mention if it's MT4 or 5, and maybe the build number would be required.

 
Also, what's the name and the "other name"? Maybe there is a sign that needs to be escaped or a blank space or something like this?
 
William Roeder:
  1. You don't compile include files. You include them in your main file and compile that.
  2. There is no such MarketInfo in the MQL5 documentation.

1. I run the compilator on my include all the time to make sure everything is OK and fix errors. It saves me the additional step of changing to the main code tab just to press F7 then coming back to the include's tab again.

2. I am obviously running MQL4. Someone with more than 22,000 posts in the forum obviously knows that, I'm not sure why you are pretending not to.

osterchrisi:
Also, what's the name and the "other name"? Maybe there is a sign that needs to be escaped or a blank space or something like this?

The name is just simply robot.mq4 and the other name is robot2.mq4.


I still don't know what was happening, but I found that I can create a new set of files with the "New" template procedure, then Select All, copy and paste from the old onto the new. Then the code works again. Very dumb, but it works.

 
whoowl:

2. I am obviously running MQL4. Someone with more than 22,000 posts in the forum obviously knows that, I'm not sure why you are pretending not to.

It is not obvious that you are using MQL4.

Quite often people try to use MQL4 code in MQL5.


In future please post in the correct section

I will move your topic to the MQL4 and Metatrader 4 section.

 
whoowl: 2. I am obviously running MQL4. Someone with more than 22,000 posts in the forum obviously knows that, I'm not sure why you are pretending not to.

I am supposed to remember 22K posts and what user it is, what they do, their level of competency, and know that they posted in the correct place, and aren't shifting to MT5? LOL

Your rudeness puts you on my do not help list.