![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
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
Haw can I sort closed orders (with all their information) in a descending time of closure order?
You have to make a 2 dimensional array that will be filled with close time and ticket numbers and then sort it. But, since metatrader can not sort 2 or more dimensional arrays, you also have to have a custom sort procedure for that 2 dimensional array (any sort algorithm will do : I am assuming that you are not going to have thousands of closed orders)
You have to make a 2 dimensional array that will be filled with close time and ticket numbers and then sort it. But, since metatrader can not sort 2 or more dimensional arrays, you also have to have a custom sort procedure for that 2 dimensional array (any sort algorithm will do : I am assuming that you are not going to have thousands of closed orders)
Is there an example of such a sorting function?
Hi Mladen and Mastercash,
I did get both the original and Mladen's update to work...but I didn't do anything special...just used the defaults as I said earlier...(using build 670 if that will help).
And Mladen's revised check snippet does seem to work...with limiting 1 trade on current bar...
However...there are other problems with this EA template which is why I suggested porting over the indicator and strategy to a new EA template.
Here's what I saw...as an example...
Both versions trigger a trade (eg a Buy)...but that Buy trade condition never seems to clear...and it continues trading that same Buy condition...even after the condition (crossing) changes to a Sell...
So if a Buy was triggered...the entire tester run is all Buy's...no matter how many times the EMA's cross. This is the same with Sell's... It seems to stay the same condition no matter what.
I can post a screen shot if helpful...but it may be better to just start with a new EA template.
Hope this helps you both,
Robert
PS - For testing purposes....I did shorten the trade conditions down to just the EMA crossings...to make it easier and faster to see how the trades were working. I did not check to see if the other trade conditions were causing any problems however...but the EMA crossings gave me enough trades to see how this EA works (as explained above)...
Mastercash and Mladen....
I went ahead and did a few screen shots to show the trade conditions for this EA...
You can clearly see the "all Buys" and "all Sells"...
I don't quite understand the trade code block and why it always returns a (-1)...but something keeps the trade condition the same...
That's why it seemed easier and better to just recommend a new EA template...
The trade examples are attached and I hope they help with finding the solutions to fix the problems.
Robert
Cosmiclifeform
that was my experience with the template....the one mladen edited does not even trade at all on my chart.
Mastercash and Mladen....
I went ahead and did a few screen shots to show the trade conditions for this EA...
You can clearly see the "all Buys" and "all Sells"...
I don't quite understand the trade code block and why it always returns a (-1)...but something keeps the trade condition the same...
That's why it seemed easier and better to just recommend a new EA template...
The trade examples are attached and I hope they help with finding the solutions to fix the problems.
Robert
Cosmiclifeform that was my experience with the template....the one mladen edited does not even trade at all on my chart.
And on my tests neither version trades. Not the original nor the changed one (I usually use 1 minute EURUSD for quick tests, and it was not opening any order at all on it - no error messages, no warnings. no opened orders at all regardless of the version I used)
Guys, that EA has just shown me that metatrader compiler has more bugs than I though : check lines from 39 to 49 - they are meaningless there, completely meaningless (calling iMA() outside the body of any function is anything but normal - and compiler did not issue any warning at all)
_______________________________
If that code from that lines is moved to check_signal() function it opens both long and short positions
:):)
Results when those lines are moved to check_signal() function :
When those lines are moved to same function in the original EA, it also starts to trade
This is the one tested on the above example : nicetrader_1.02.mq4
Mladen,
the original i sent was make trade, but if it enter trade, say buy on EURUSD, it will continue to take that BUY on EURUSD even when the buy condition is over.....This is it again attached below.
Mastercash
That EA is not opening order even if that check is thrown out (so if the part of code that was added to it is removed it still does not open orders). Also, when tested, the one that you posted (the original) does not open orders.
Did the version that you posted ever trade at all?Mladen, the original i sent was make trade, but if it enter trade, say buy on EURUSD, it will continue to take that BUY on EURUSD even when the buy condition is over.....This is it again attached below.
Mastercash
That is not the one that was posted here : https://www.mql5.com/en/forum/174385/page239 (check it and you shall see that they are different - there is no commented out part of the code in the one you posted there)
Anyway, use this one or the one I posted in a post prior to your post,and it should open all the positions - long and short : nicetrader-original.mq4
Mladen,
Thanks....I shall go tru it myself.If we can get this template working properly,many of will have ready template to work our ea in the new mt4 build.
Mastercash
That is not the one that was posted here : https://www.mql5.com/en/forum/174385/page239 (check it and you shall see that they are different - there is no commented out part of the code in the one you posted there)
Anyway, use this one or the one I posted in a post prior to your post,and it should open all the positions - long and short : nicetrader-original.mq4