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
It works. There's an issue elsewhere in your code. A big part of programming is debugging and unit testing. If you don't know how to do those then I'd recommend you spend some time learning them. For example you could have made a unit test to check the break even function as a process of elimination...
There is no such thing as clean-code with non-const global variables, especially when they aren't labeled using the "g_variable" convention. Abusing global variables is a mortal sin
I'm actually refactoring 1,000's of lines of code because I used a global variable called: g_chartSymbol.
Granted, I used the "g_" naming convention, but even so.
When I initially began the EA, I never thought it would handle multiple currencies. So my variable of convenience (and/or expedience) has nabbed me.
A big part of programming is debugging and unit testing.
I <3 Unit Tests.
This was a great thread. Listen to @nicholi shen -- he is speaking the truth.
I'm actually refactoring 1,000's of lines of code because I used a global variable called: g_chartSymbol.
Granted, I used the "g_" naming convention, but even so.
When I initially began the EA, I never thought it would handle multiple currencies. So my variable of convenience (and/or expedience) has nabbed me.
I <3 Unit Tests.
This was a great thread. Listen to @nicholi shen -- he is speaking the truth.
Hi Anthony....
I've been scratching my head for days now wondering why Nicholi said that "Global" variables are a mortal sin to use.... but, I get it now and maybe this will help others to understand:
"Most" of us (well, me...) refer to a variable created in the "Global Scope" as a "Global Variable".... I did'nt even know that we have access to "Client Terminal Global Variables".... but I'm getting off-point here...
Could you please be more specific w.r.t "This was a great thread" - I <3 Unit Tests...? I'd be interested to read that... thanx
Hi Anthony.... Could you be more specific w.r.t "This was a great thread" - I <3 Unit Tests...?
Sure.
(1) This was a great thread ==> @nicholi shen gave some great advice for programming/programmers in this thread.
(2) Unit tests are beneficial for all sorts of reasons. Writing unit tests, while programming, highlights external dependencies and gives you a better perspective on how to structure your code. If a piece of code isn't testable, it could/should probably be broken down into components that are. If your unit tests check edge cases, you will find bugs quicker. The overall quality of your code is enhanced with unit tests.
While I am not an advocate of TDD, I always wanted the programmers working with/for me to use unit tests. Usually they're too lazy, and that always comes back to haunt the project later.
That said, I've fallen into the trap myself. If I have an idea I am chasing down, I may get a little sloppy. But in general, for core code, I want the quality assurance that unit tests provide.
Sure.
(1) This was a great thread ==> @nicholi shen
I had a look there but couldn't find the thread.... must have missed it... but thanx... looks like something I need to know more about...
I had a look there but couldn't find the thread.... must have missed it... but thanx... looks like something I need to know more about...
Oh... sorry... but it prompted me to look into this further and found this link... so thanx (sorry Roberto)
https://www.mql5.com/en/articles/1579
Oh... sorry... but it prompted me to look into this further and found this link... so thanx (sorry Roberto)
https://www.mql5.com/en/articles/1579
In the comments of the article you mention, femto gives a link to his github site. That's the same code I use for my unit tests, although I ported it to MQL5.
Be warned:
You need to rewrite the code for assertEquals() for floats and doubles. He uses a simple equality operation, which doesn't work for float and double comparisons.
My recommendation would be to look to see if there are any errors in the expert log. If not then I would put some print lines in my code at various places.. is the breakeven function running when it should? put a print line to find out.. if it is running put some error checking code on the ordermodify result.
Are you sure you only want the breakeven opportunity to be checked once on each new candle or would you like it to run on each tick? It may move into an area that warrants moving to breakeven AFTER the candle has been building a while.. only to retreat by candle close and stopping you out. Just something to think about..
As regards the Order_Magic and Breakeven variables. You can use input instead of extern if they are not going to be changed by the program. If however, your program changes breakeven amount based on timeframes or currency pairs.. then leave it a variable.. or perhaps you have the EA build a unique magic number based on each currency pair.
As long as your expert template uses the same names in your EA's I see no problem.
Obviously you have something else going on. A few print lines will tell the story. When you see what the EA is seeing you will have an Aha! moment.. be sure to come back and tell us what simple thing you forgot to do..
Pip Pip.. Jimdandy