You only need the indicator for visualization, not to trade.
Make an EA that uses the same formula for testing purposes and it will be fast.
You only need the indicator for visualization, not to trade.
Make an EA that uses the same formula for testing purposes and it will be fast.
Thanks for your response. I did what you said and it's a little faster but not like the version I have for MQL4 of the donchian channel, something is seriously bad with the code.
Mt5 is supposed to be faster than the MT4, and in MT4 the optimization is way faster than this version, so something is bad with the code for sure.
Please someone that can help me. The code is not long, so it must be very easy for someone that really knows MQL5.
It looks like you have slow hardware.
What code have you tried ?
Except from that indicator.It looks like you have slow hardware.
What code have you tried ?
Except from that indicator.My friend I don't have a slow hardware, as I explained before, I run the same EA on MT4 and is way faster. My notebook is I7 and 16GB ram.
I have test a lot of codes in MT4 and MT5, and this is way slower than the rest, like I said, by a factor of 100 at least.
Again what code have you tried ?
You can say it is slow all day long but without code there is nothing we can do.
So, you don't see anything wrong with the code I posted (the one in MQL5)?
I'm new to MQL5, and the version of MT4 I have for the Donchian is much faster.
I don't know what else to tell you, Like I said is much faster the test in MQL4 for the SAME strategy than in MQL5, the only difference comes from the indicator.
Hope someone can help with the code for the Donchian indicator, I have tried many on this website and all are slow compared to MT4, I don't know why, all the other robots I have on MT5 use common indicators (like momentum, RSI, Moving Averages), indicators already defined in MQL5, in this case I loked the Donchian Channel and called with "iCustom", have no errors and make trades, but really slow. I think is something to do with the calculations of the indicators itself.
My friend I don't have a slow hardware, as I explained before, I run the same EA on MT4 and is way faster. My notebook is I7 and 16GB ram.
I have test a lot of codes in MT4 and MT5, and this is way slower than the rest, like I said, by a factor of 100 at least.
If you test EAs, and compare them on MT4 and MT5, you need to post EA code, not an indicator code.
The indicator you posted is not the problem.
Please also post the terminal build.
I am also experiencing extreme lagging issues on the latest beta.
Please also post the terminal build.
I am also experiencing extreme lagging issues on the latest beta.
Hello,
Thanks for the help, here I add the code of the expert. I'm not an expert and start using other code as base and make changes to make what I want.
The build is Version: 5.00 build 1940, 02 nov 2018.
Please bear in mind I use a library for making orders the same way as in MQL4, because I need it to use the Magic Number so the robot don't interfire with others, and I didn't know how to do that on MQL5 code.
The library is this one ( https://www.mql5.com/en/code/16006 ) I have use it the same way to make orders for others EA and they work fine, is just this EA that I have problem, that's why I think it was the indicator and not the EA code.
#include <Trade/Trade.mqh> #include <MT4Orders.mqh> CTrade trade; long Magic_Number=85; input int BarsToCount=20; input double Factor_stop=1; input int Periodo_ATR=10; double lot=0.1; int OnInit() {return(INIT_SUCCEEDED);} void OnDeinit(const int reason) {} void OnTick() { MqlRates PriceInfo []; ArraySetAsSeries (PriceInfo,true); int Data=CopyRates(Symbol(),Period(),0,3,PriceInfo); double myATRArray[]; int myATRDefinition = iATR(_Symbol, _Period, Periodo_ATR); ArraySetAsSeries (myATRArray, true); CopyBuffer (myATRDefinition, 0, 1, 1, myATRArray); double myATRValue= NormalizeDouble(myATRArray[0], 5); double UpperBandArray []; double LowerBandArray []; ArraySetAsSeries(UpperBandArray,true); ArraySetAsSeries(LowerBandArray,true); int DonchianDefinition = iCustom(NULL,0,"DonchianChannel",BarsToCount); CopyBuffer(DonchianDefinition,0,0,2,UpperBandArray); CopyBuffer(DonchianDefinition,1,0,2,LowerBandArray); double Donchian_upper0=NormalizeDouble(UpperBandArray[0],5); double Donchian_lower0=NormalizeDouble(LowerBandArray[0],5); double Donchian_upper1=NormalizeDouble(UpperBandArray[1],5); double Donchian_lower1=NormalizeDouble(LowerBandArray[1],5); double Ask=NormalizeDouble(SymbolInfoDouble(_Symbol,SYMBOL_ASK),_Digits); double Bid=NormalizeDouble(SymbolInfoDouble(_Symbol, SYMBOL_BID), _Digits); double StopLossPips=Factor_stop*myATRValue; if((PositionsTotal()==0) && (Donchian_upper0>Donchian_upper1) && (Donchian_lower0>Donchian_lower1)) OrderSend(Symbol(),OP_BUY,lot,Ask,30,Ask-StopLossPips,0,"",Magic_Number,0,clrGreen); if((PositionsTotal()==0) && (Donchian_upper0<Donchian_upper1) && (Donchian_lower0<Donchian_lower1)) OrderSend(Symbol(),OP_SELL,lot,Bid,30,Bid+StopLossPips,0,"",Magic_Number,0,clrRed); for( int i=OrdersTotal()-1;i>=0;i-- ) { if(OrderSelect( i, SELECT_BY_POS, MODE_TRADES )){ if(OrderType()==OP_BUY && Magic_Number==85 && PriceInfo[0].close<Donchian_lower1) OrderClose(OrderTicket(),OrderLots(),Bid,30,CLR_NONE); if(OrderType()==OP_SELL && Magic_Number==85 && PriceInfo[0].close>Donchian_upper1) OrderClose(OrderTicket(),OrderLots(),Ask,30,CLR_NONE); }}}

- www.mql5.com
Also, I forgot to tell I'm optimizing on "Open Price Only". I know, I haven't add the code for the check of the EA only when there is a new bar on the chart, I will add that later.
Like I said, it's really strange since is way slower the backtest than other EA on MQL5 I have and the same on MT4. Thanks!

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello,
I have been looking for a Donchian Channel indicator to test some strategies. I have found a lot of indicators in this website, however some have problems of buffers (don't consider the current candle) and ALL of them have a problem. The problem is when I use them on a strategy (whatever strategy, lets assume the buy when the upper channel is going higher...), when backtesting or optimizing is taking too much time to get the results. I think the code is using way to much resources (much more than need it).
I'm not an expert but seems the code is wrong since the same optimization on MT4 takes WAY LESS time to finish, I mean 100 times less.
This is the code I have for the indicator, please help me understand what is wrong and why it takes so much time, considering the MT5 is much faster than MT4, obviously is something wrong with the code. Thanks!