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
Hi Enrico,
I have found a way to handle the Calculate function now including a hysteresis feature which seems to work when the MA and the TEMA indicator crosses.
However I have run into a problem with the Order Manager. It happens when I have run the strategy tester for some loops during optimization. For the first loops it work fine but after some loops an order is placed for every candle.
Here it works fine:
But here the Order Manager starts to place multiple orders:
When I debugged the following code part of the COrderManager, the statement orders_total = OrdersTotal(); becomes 1 when it works but becomes 0 when it fails, which leads to that the if condition m_max_order>orders_total always evaluates to true.
Hopefully you can help to figure this out.
Best Regards/
Karl
Hi Karl,
I have never encountered this issue before. The OrdersTotal() method simply counts the number of active COrder objects. If there is something wrong with the coded strategy then it must be corrected. If not, then there must be some issue on how the COrder instances are managed (created/destroyed) and/or how they are counted. I will let you know as soon as I come across this problem.
Hi Enrico,
Googling on mt5 OrdersTotal() issues reveals others have problems as well. E.g. https://www.mql5.com/en/forum/1995
I'll upload the latest version of my strategy. Maybe you are able to reproduce the same issue if you try the strategy tester with this strategy. The Expert Set is also uploaded so you can run the strategy tester with the same input as I did.
Best Regards/
Karl
Hi Enrico,
Googling on mt5 OrdersTotal() issues reveals others have problems as well. E.g. https://www.mql5.com/en/forum/1995
I'll upload the latest version of my strategy. Maybe you are able to reproduce the same issue if you try the strategy tester with this strategy. The Expert Set is also uploaded so you can run the strategy tester with the same input as I did.
Best Regards/
Karl
Thanks for the files Karl. I encountered the problem you were describing.
On the main include file, change this (OnInit):
to this:
And this (OnDeinit):
to this:
For some reason, the data saved from previous sessions is being reloaded to future sessions. That is why the problem only exists after the initial backtest, sometimes with some leak in memory. Based on my testing, the issue appears to exist only on netting mode, not on MT4 or on MT5 hedging mode. But let me know if you continue to experience this problem. The code above prevents loading and saving data during backtesting and optimization (I overlooked mentioning this while writing the final article).
Also, regarding the OrdersTotal() in MT5, it only counts the pending orders (not the equivalent of MT4's OrdersTotal). The code in TradeOpen for OrderManager:
uses the OrdersTotal() method of the class, which is just a wrapper of COrders' method (also the same name). COrders extends CArrayObj, so it is not really using the MT5 native OrdersTotal() function. The above is also equivalent to using:
On the other hand, if we use:
this explicitly calls the MT5 native function. You may already be familiar with this, but just in case for other people who encounter a similar problem.
Thank you Enrico. The issue disappeared.
/Karl
Hi Enrico,
In the Github at iceron/MQLx, there is a change notice of m_new_signal and m_new_signal_close.
m_signal_new can be changed by the void CSignalsBase::NewSignal(const bool value) method, but there are no method available to change m_new_signal_close.
Could you please elaborate on the usage of m_new_signal and m_new_signal_close?
Best Regards/
Karl
Do these methods work with your MT5Bridge?
Hello Masters!
I have a serious problem with understanding "Candle counting" (First, second, third = idx, idx++, ...) in following Mql Signal code which belongs to SignalAC class.
Does anybody could help to penetrate to idx number when moving in codes down?
Thanks in advance.