Changing Include function Crieterion name

 

I've run into a problem trying to change the name of function Criterion in my EA which is patterned from the usualexpert.mq4. I wanted a unique trading criteria/strategy name to differentiate it from others in the metatrader include folder. The function has been renamed in the list of include files, in the start function terminal call, and in the the include function source code. I've also searched every include file for uses of the original Criterion name for conflicts.

After renaming each instance of function Criterion to the same unique name, I get this message: "Cannot open the program file". Is it possible that mq4 will not permit a substitute of any kind for this function or possibly there is a better approach. Any suggestions wil be appreciated.

William

 

never heard of Criterion.

but as long as #include <name.mqh> is ok in that "name.mqh" is in ...\experts\include AND you know the correct name of the type function() then system can build .ex4 ok

not get fully wat you say. cannot open the program file, refers not to compile time does it?

ie, when u get this message? build, run,...

system not care what call stuff long as it can find it...

wat u use:

1. #include <name.mqh>

or

2. #include "name.mqh"

if latter, name.mqh must be in same location as program file being compiled.

if former, name.mqh must be in ...\experts\include

hth

 
fbj wrote >>

never heard of Criterion.

but as long as #include <name.mqh> is ok in that "name.mqh" is in ...\experts\include AND you know the correct name of the type function() then system can build .ex4 ok

not get fully wat you say. cannot open the program file, refers not to compile time does it?

ie, when u get this message? build, run,...

system not care what call stuff long as it can find it...

wat u use:

1. #include <name.mqh>

or

2. #include "name.mqh"

if latter, name.mqh must be in same location as program file being compiled.

if former, name.mqh must be in ...\experts\include

hth

Thanks for the response. You make several good points.

Function Criterion.mgh is the include filename in the MQL4 book "usualexpert.mq4" example that describes the trading strategy. The "Cannot open the program file" error message occurs when compiling the usualexpert.mq4. Like you, I also thought you could name user defned functions anything you wished as long as it was consistent throughout the program. Function Criterion() is called indirectly in the start() function of usualexpert.mq4 with its return values passed to the Trade() function, ie ... "Trade(Criterion)". It's possible that I have overlooked another instance of function Criterion () even though I searched every include file for other references and renamed all I found.

I appreciate your help.

William

 

well... the book leaves out almost as much as it leaves in - is consumed with many inconsistencies (no point ranting on... is way too big an area to take issue with)

(ie, jjc mentions elsewhere that the WHAT's are [of course] important in docs but the WHY's are even more important and at least for me, the book falls short in this area [amongst others :] )

Are you refering to https://book.mql4.com/build/trading part of book?
if so, all .mqh's should live in ...\include and in your compile source you put eg: #include <Trade.mqh>
and in code you call eg, Trade(Trad_Oper)

The book decided to have include files make external refs to other identifiers in other include files... not in itself any big issue, but...

I would suspect that your issues lie within this area - have fun...!

eg, ya gotta have included everything including the kitchen sink or it ain't gonna work - lol

Spaghetti coding springs to mind.

To make matters worse, int Trad(int Trad_Oper) DOES NOT return a value! How sad is that?

IOW, void Trad(int Trad_Oper) is correct syntax. ie, I spent few mins getting my head around the very simple code but never the less, the formal function declaration STATES "int Trad(int Trad_Oper)" and far as I'm concerned, a function with a type = int is shouting at me that it returns a 32-bit integer value - no questions need be asked!

ok... off air - simple minded rant over with :/

please enjoy it all, is in the end, great fun and ultimately we ALL look towards making income via use of the beast...

:)

 

Fred,

First I wanted to let you know I finally resolved the function renaming problem by going back and carefully ensuring all instances of the previous name were changed. So you were right in that the complier should not care what we name our user defined functions. The comcept of having a function called indirectly by passing its parameters to another function as in Trade(Criterion) was new to me and took a while to figure out but seems to work.

I looked up your profile and see you've been at this MQL thing much longer than myself and agree that the book could needs updating .... I would certainly like to see the comments in English even though I've learned a lot by rewriting them in English for the programs I wanted to use . I've had some previous experience with C-type script writing in the Russian developed AmiBroker language which was quite limited compared to MQL4. As a relative MQL newbie, my biggest complaint is the total lack of meaningful degugging tools aside from the Print function. Hopefully, the new MQL5 version will correct some of this.

I'm an old timer now ... nearly 79 years-old but still love the challange of programing .... especially if it offers the prospects of improving my trading profits. I see a lots of comments in the Forex literature putting EA's down as totally useless but am just naive enough to think they have their place. The one or two overhyped commercial black-box EA's that I've bought have been useless and I initially decided to discontinue wasting time running them. However, I've had a fair amount of success in the stock market using breakout techniques and like the idea of EA's that can trade on these simple patterns. That's where my MQL efforts are headed at this time.

Do you think the new MQL5 is going to be a major improvement? Again, thanks for the comments.

William

 

Amibroker.... WOW - that brings back memories. I bought into that arena big time many years ago. Got to the point that felt like needed a Cray to get my 'inventions' to work.

Then I migrated to MT and went supersonic with the same code. Have, as such, never regretted letting my Ami license lapse!!!

"Do you think the new MQL5 is going to be a major improvement?"

Well... I have made comments as to my allegience for MQL4/MT4 system. Simply because for me personally, warts 'n all... it happens to have a long track record and maybe is not ideal from a modern programmer's point of view who likes all the OOPs goodies and richer C'esque syntax that '5' appears to have coupled with a more enlightened MT5 [I believe] API.

So, for me - the question is not about all the bell's and whistles. It is about simply looking in the mirror and asking yourself one question: Why is it that I cannot become financially independant from Forex trading using the existing environment?

I used to get involved all the time with 'the next great thing' and learn every aspect of it - basically forsaking all that had come before.

I now realize that is a life thing. Is what many of us do... we obfuscate, we plainly like to just play with the next best goodie on the block.

How much easier it is than to sincerely ask oneself WHY one is unable to progress with an available toolset....

Anyway, I should not go on. Personally, I stick with what I have spent just about a decade with. No damn new better, faster, shinnyer model is going to make a hill of beans difference to whether or not I become financially independant through Forex trading.

I am sick to death of the butterfly effect whereby one keeps flitting here and there looking, playing with and always in the end discarding to do a GOTO top of loop for the next goodie.

You see it all the time - bees around a honey pot, yes?

My answer? KNOW, really KNOW a system and bloody well get the proverbial finger out and hack to death UNTIL that system turns out good income.

Maybe simplistic, but the buck stops at home for me. IF one can not make income from MQL4/MT4 platform THEN they will never in a month of sundays do any better elsewhere.

It is reasonably obvious that the syntax although small in features IS perfectly capable [for all that are willing that is] to compose ANY functionality needed.

I've used OOPs this and that in compiled and interpreted environments etc, used double digit's worth of HLL's and LLL's in many environments including many hardcore chip level assembler years on many different platforms including assembler, compiler, linker etc. work.

I completely understand one's fascination with upcoming '5'. I completely dissagree that it will, as if by magic, solve ones problems regards turning a penny into a pound.

LUDDITE springs to mind!

:O)

I just LOVE Sir Alan Sugar's statement: "So live with it!"

How does it apply to my rant? That's my secret-lol

.

edit,

4got mention - rude or wat? congrats on solving issue. is great feeling, yes? I love it when for that briefest of moments it all comes together...!!!

funnily enuf, these days, syntax for me is no big thing - I'll eventually crack any nut I present self with. Instead... my issue is the one of using my mushy peas brain. Just no longer fires on 'all eight' anymore = sh*t load of time spent going over and over the same old stuff until eventially the penny drops... yep, I have many duh moments now, but again - is just matter of belief that one WILL 'get it' some time :o)

 
fbj wrote >>

Amibroker.... WOW - that brings back memories. I bought into that arena big time many years ago. Got to the point that felt like needed a Cray to get my 'inventions' to work.

Then I migrated to MT and went supersonic with the same code. Have, as such, never regretted letting my Ami license lapse!!!

"Do you think the new MQL5 is going to be a major improvement?"

Well... I have made comments as to my allegience for MQL4/MT4 system. Simply because for me personally, warts 'n all... it happens to have a long track record and maybe is not ideal from a modern programmer's point of view who likes all the OOPs goodies and richer C'esque syntax that '5' appears to have coupled with a more enlightened MT5 [I believe] API.

So, for me - the question is not about all the bell's and whistles. It is about simply looking in the mirror and asking yourself one question: Why is it that I cannot become financially independant from Forex trading using the existing environment?

I used to get involved all the time with 'the next great thing' and learn every aspect of it - basically forsaking all that had come before.

I now realize that is a life thing. Is what many of us do... we obfuscate, we plainly like to just play with the next best goodie on the block.

How much easier it is than to sincerely ask oneself WHY one is unable to progress with an available toolset....

Anyway, I should not go on. Personally, I stick with what I have spent just about a decade with. No damn new better, faster, shinnyer model is going to make a hill of beans difference to whether or not I become financially independant through Forex trading.

I am sick to death of the butterfly effect whereby one keeps flitting here and there looking, playing with and always in the end discarding to do a GOTO top of loop for the next goodie.

You see it all the time - bees around a honey pot, yes?

My answer? KNOW, really KNOW a system and bloody well get the proverbial finger out and hack to death UNTIL that system turns out good income.

Maybe simplistic, but the buck stops at home for me. IF one can not make income from MQL4/MT4 platform THEN they will never in a month of sundays do any better elsewhere.

It is reasonably obvious that the syntax although small in features IS perfectly capable [for all that are willing that is] to compose ANY functionality needed.

I've used OOPs this and that in compiled and interpreted environments etc, used double digit's worth of HLL's and LLL's in many environments including many hardcore chip level assembler years on many different platforms including assembler, compiler, linker etc. work.

I completely understand one's fascination with upcoming '5'. I completely dissagree that it will, as if by magic, solve ones problems regards turning a penny into a pound.

LUDDITE springs to mind!

:O)

I just LOVE Sir Alan Sugar's statement: "So live with it!"

How does it apply to my rant? That's my secret-lol

.

edit,

4got mention - rude or wat? congrats on solving issue. is great feeling, yes? I love it when for that briefest of moments it all comes together...!!!

funnily enuf, these days, syntax for me is no big thing - I'll eventually crack any nut I present self with. Instead... my issue is the one of using my mushy peas brain. Just no longer fires on 'all eight' anymore = sh*t load of time spent going over and over the same old stuff until eventially the penny drops... yep, I have many duh moments now, but again - is just matter of belief that one WILL 'get it' some time :o)

It' good to hear from someone who obviously has a passion for what he does. I'm still struggling a bit with the syntx ... but that will come with experience. Cheers

William

 

Passion? more like desperation....

Reason: