Questions from Beginners MQL5 MT5 MetaTrader 5 - page 714
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
With the use of OnTradeTransaction, the optimisation time has strangely changed. A system on 15M, very simple, annual history, one run occurs in 0.3 - 0.4 seconds.
After optimization start the first 200-300 runs go at less than a second, the next ones slow down up to 15-20 seconds (50 times!);
No processor overheating or trolling, more than half of memory is free (from 16GB).
Before using the OnTradeTransaction handler there was nothing like that - even more complex Expert Advisors on small timeframes were optimized with approximately the same speed.
Does HistoryDealSelect affect the speed so much? How can we eliminate the lags?
const MqlTradeRequest &request,
const MqlTradeResult &result)
{
if( trans.type != TRADE_TRANSACTION_DEAL_ADD) return;
ENUM_TRADE_TRANSACTION_TYPE type=trans.type;
long deal_type =0;
double deal_volume =0;
long deal_magic =0;
if(HistoryDealSelect(trans.deal))
{
deal_type =HistoryDealGetInteger(trans.deal,DEAL_TYPE);
deal_volume =HistoryDealGetDouble(trans.deal,DEAL_VOLUME);
deal_magic =HistoryDealGetInteger(trans.deal,DEAL_MAGIC);
}
else
return;
if (deal_type == DEAL_TYPE_BUY && deal_magic == MagicNumber) current_position += deal_volume;
if (deal_type == DEAL_TYPE_SELL && deal_magic == MagicNumber) current_position -= deal_volume;
}
Hi!
Who knows - how to display the bars to the right of the zero bar in the indicator and how many max? (price forecast to make)
Is it HistoryDealSelect that badly affects the speed? How can the slowdown be eliminated?
The developers recommend to minimize calling History-functions (expensive) - through history caching.
I posted a working solution in kodobase (MT4Orders), but it probably will not suit you.
I haven't seen any lags after using caching.
Although, your OnTradeTransaction should not slow down, even though it is not written optimally.
Hi!
Who knows - how to display the bars to the right of the zero bar in the indicator and how many max? (price forecast to make)
Add PeriodSeconds() to the opening time of the last bar and draw a candle there with graphical objects. At most it will be visible on the right. But I haven't checked how it will be displayed if there is an exit. Probably one should take into account.
Add PeriodSeconds() to the open time of the last bar and draw the candlestick there. At most, you will see it on the right. But I haven't checked its appearance. Probably, it is necessary to take into account.
On the chart it draws a continuation, but unfortunately not in the indicator window.
Maybe I'm wrong of course...
What do you think - can I continue the indicator line beyond the zero bar to the right?
Who knows - can the indicator line be extended beyond the zero bar to the right?
You can. You can shift it, but the calculation will probably not be done using non-existing values and the time is not used in the indicator display. This is why I was talking about bar displaying using graphical elements. The ObjectCreate() contains both window number (subwindow) and time. Therefore, there should be no problems when creating graphical elements.
In the chart window, using the timestamps, you can refer to future intended bars. It has worked.
However I cannot do the same in the indicator window. I.e. I cannot write values in the indicator buffer with the index -1, -2, etc.
The question is this.
It is clear, in principle. The solution is to create an indicator by graphical objects.
In the chart window, using the timestamps, you can refer to future intended bars. It has worked.
However I cannot do the same in the indicator window. I.e. I cannot write values in the indicator buffer with the index -1, -2, etc.
The question is this.
In principle, it is clear. The solution is to create the indicator by graphical objects.