Any new software product inevitably contains bugs, which cannot always be detected even by the most thorough testing in-house. And that is why we attach great importance to all user reports of problems found in our software and try to respond to each of them.
How can we communicate if there is an erroneous response first and then we ignore it. Application 2016.06.22 08:06, #1499568
Maybe something the community can explain?
Here is part of the EA code. Inside void OnTick().
bool openNew, newDay, newHour; if((int)mqlDateTime.hour == startHour) // startHour = 0 Это условие выполнено. { newDay = newBar.IsNewBar(_Symbol, PERIOD_D1, oldDay); // if(newDay) Print("***** newDay ", newDay, " mqlDateTime.hour ", mqlDateTime.hour); // Судя по распечатке newDay = true newHour = newBar.IsNewBar(_Symbol, PERIOD_H1, oldHour); if(newHour) Print("***** newHour ", newHour); // Судя по распечатке newHour = true if(newDay && newHour) // A ЭТО УСЛОВИЕ НЕ ВЫПОЛНЕНО НЕСМОТРЯ НА ПРЕДЫДУЩИЕ РАСПЕЧАТКИ. { openNew = openNew_or_No(); Print("***** openNew ", openNew, " ***** PositionsTotal ", PositionsTotal()); // Эта распечатка отсутствует if(openNew || PositionsTotal() == 0) // Продолжение кода... // На несоответствие количества открывающих и закрывающих фигурных скобок прошу не обращать внимания.
This is the contents of the "Experts" tab.
2016.06.22 00:00:44.531 Toad Green (EURUSD,M15) ***** newHour true 2016.06.22 00:00:44.331 Toad Green (USDJPY,M15) ***** newHour true 2016.06.22 00:00:18.361 Toad Green (EURUSD,M15) ***** newDay true mqlDateTime.hour 0 2016.06.22 00:00:12.770 Toad Green (USDJPY,M15) ***** newDay true mqlDateTime.hour 0
First lines of logfile from 21.06 where it is clearly seen that the above code worked fine.
GM 0 00:00:30.116 Trades '3265046': instant buy 0.01 EURUSD at 1.13188 tp: 1.13388 (deviation: 55) NK 0 00:00:30.246 Trades '3265046': accepted instant buy 0.01 EURUSD at 1.13188 tp: 1.13388 (deviation: 55) IE 0 00:00:30.246 Trades '3265046': deal #73303810 buy 0.01 EURUSD at 1.13188 done (based on order #87892298) KI 0 00:00:30.246 Trades '3265046': order #87892298 buy 0.01 / 0.01 EURUSD at 1.13188 done in 130 ms ON 0 00:00:30.256 Trades '3265046': instant sell 0.01 EURUSD at 1.13093 tp: 1.12893 (deviation: 55) LQ 0 00:00:30.366 Trades '3265046': accepted instant sell 0.01 EURUSD at 1.13093 tp: 1.12893 (deviation: 55) HG 0 00:00:30.376 Trades '3265046': deal #73303813 sell 0.01 EURUSD at 1.13093 done (based on order #87892301) RK 0 00:00:30.376 Trades '3265046': order #87892301 sell 0.01 / 0.01 EURUSD at 1.13093 done in 120 ms MJ 0 00:00:30.376 Trades '3265046': modify #87608748 sell 0.01 EURUSD sl: 0.00000, tp: 1.12031 -> sl: 0.00000, tp: 1.12462 GK 0 00:00:30.476 Trades '3265046': accepted modify #87608748 sell 0.01 EURUSD sl: 0.00000, tp: 1.12031 -> sl: 0.00000, tp: 1.12462 OK 0 00:00:30.486 Trades '3265046': modify #87608748 sell 0.01 EURUSD -> sl: 0.00000, tp: 1.12462 done in 107 ms OH 0 00:00:30.486 Trades '3265046': modify #87892301 sell 0.01 EURUSD sl: 0.00000, tp: 1.12893 -> sl: 0.00000, tp: 1.12462 GJ 0 00:00:30.586 Trades '3265046': accepted modify #87892301 sell 0.01 EURUSD sl: 0.00000, tp: 1.12893 -> sl: 0.00000, tp: 1.12462 KI 0 00:00:30.596 Trades '3265046': modify #87892301 sell 0.01 EURUSD -> sl: 0.00000, tp: 1.12462 done in 109 ms EN 0 04:20:25.608 Trades '3265046': deal #73317674 sell 0.01 EURUSD at 1.13388 done (based on order #87906853)
The EA rests until the beginning of the next day.
Last 2 lines of log file from 21.06
OD 0 23:09:20.196 Network '3265046': scanning network for access points NR 0 23:09:33.496 Network '3265046': scanning network finished
and beginning of log from 22.06
PM 1 02:13:39.422 Network '3265046': connection to MetaQuotes-Demo lost GF 2 02:13:39.582 MQL5.community authorization failed DO 2 02:13:39.682 MQL5.community authorization failed IP 2 02:13:40.052 MQL5.community authorization failed PK 0 02:13:43.252 Network '3265046': authorized on MetaQuotes-Demo through Access Point RU Moscow (ping: 117.48 ms) DI 0 02:13:43.252 Network '3265046': previous successful authorization performed from 31.173.80.184 on 2016.06.21 14:55:11
If you have both NewDay and NewHour printed simultaneously, they should be next to each other in the logs. With the same time
Sorry for the inconvenience, I wasn't paying attention to the time. But!!! Then why at appearance of the first bar of the new day, it-also the first bar of the new hour and the new minute the same function returns someone true to someone false and when it wants can return all correctly?
Please explain what can be wrong in this function?
/*****************Определение появления нового бара******************/ class cNewBar { public: bool IsNewBar(string symbol, ENUM_TIMEFRAMES timeframe, datetime & m_tOld) { datetime tNew = (datetime)SeriesInfoInteger(symbol, timeframe, SERIES_LASTBAR_DATE); if(tNew > m_tOld) { m_tOld = tNew; return(true); } return(false); } }; /********************************************************************/Why is it that everything was working fine for many weeks and all of a sudden it went wrong?
Support Team 2016.06.22 11:31
This function cannot be used repeatedly because of
m_tOld = tNew;
Alexey Viktorov 2016.06.23 10:17
Something I didn't immediately understand yesterday... After all, the variable m_tOld is passed to the variable by reference, which is declared at the level of global variables and should not affect the multiple call if different variables are passed to the function by reference. Isn't it so? First of all, why is it working correctly in Tester and Debug, and then it's not working on demo account.
What about this check?
if(tNew > m_tOld)
Support Team 2016.06.23 10:24
Call your function 2 times in a row. If on the first call it returns true, on the next call it will return false, even though you call it on the same tick
Alexey Viktorov 2016.06.23 10:36
Well it is called. All required code I provided. Why it does not prevent in tester and debug, and in demo as you want? That's what I cannot understand. Well, if in the tester such a problem would occasionally occur, we could and should look for new ways, but there are no problems in the tester...
All the same, I have not saved an EA using the same function on mql4, but there were no problems. This problem has only appeared with mql5.Alexey Viktorov 2016.06.23 10:41
So? So the test... Because before the check, variable tNew is assigned a value and it is compared to the variable passed by reference, not to m_tOld variable itself. And it, this m_tOld can have the value of time of the previous bar of the specified period, or 01.01.1970 if it is the first call. And only on the next tick for each period the values of the same bar will be compared.
Alexey Viktorov 2016.06.23 10:57
Note, different variables and different periods are passed to the function
newDay = newBar.IsNewBar(_Symbol, PERIOD_D1, oldDay); newHour = newBar.IsNewBar(_Symbol, PERIOD_H1, oldHour);
AND ALL... After that I am completely ignored. Thanks for the prompt reply without delay, but I have not received any intelligible answer. If there's a bug in mql5, you can just write, "We're trying to fix it, so just wait...". But in this case, you are simply ignoring the problem.
A similar function in mql4 defined time change as a multiple of 15 seconds, and in mql5 this problem suddenly appeared...
This is what improperly organised observation means when conducting an experiment.
...
To answer that, you need a code. You have snippets of code. Make the minimum code so that anyone could run this code in his/her own place.
It would be also good to print in the code the values of variables - at the input to the function and at the output from the function.
Dimitri, has it started again? Maybe it is easier to answer the question "Why on 21.06.2016 the warrants opened without any problems, but on 22.06.2016 suddenly the wrong surveillance organisation" or some other problem...
If I answer simply and straightforwardly, I'll probably get banned for it.
forever...
You can't even sleep, you dream so much?
What's the point? Because it doesn't make you any wiser.
Isn't it fun to live when the meaning of life is hate? А?
To answer that, you need a code. You have snippets of code. Make the minimum code - so that anyone could run this code on their own.
It would be good to print the values of variables in the code - at the input to the function and at the output from the function.
No problem.
But note that there were no problems and suddenly... why? Apart from code snippets there are logs which show that on 21.06.2016 and before that it worked as it should be for weeks, but then on 22.06.2016 problems suddenly appeared. Before writing to SD, I repeatedly ran in tester, debugged on history and no problems were found.
That's why I doubt the usefulness of posting the code. It's just for fun.
#property strict datetime oldDay, oldHour; MqlDateTime mqlDateTime; /*******************Expert initialization function*******************/ int OnInit() { return(INIT_SUCCEEDED); }/*******************************************************************/ /************************Expert tick function************************/ void OnTick() { bool newDay, newHour; TimeToStruct(TimeCurrent(), mqlDateTime); if((int)mqlDateTime.hour == 0) { newDay = IsNewBar(_Symbol, PERIOD_D1, oldDay); // Обратите внимание на то, что это отдельная переменная передаваемая в функцию по ссылке if(newDay) Print("***** newDay ", newDay, " mqlDateTime.hour ", mqlDateTime.hour); // Судя по распечатке newDay = true newHour = IsNewBar(_Symbol, PERIOD_H1, oldHour); // А это совсем другая переменная if(newHour) Print("***** newHour ", newHour); // Судя по распечатке newHour = true if(newDay && newHour) // A ЭТО УСЛОВИЕ НЕ ВЫПОЛНЕНО НЕСМОТРЯ НА ПРЕДЫДУЩИЕ РАСПЕЧАТКИ. { Print("Ордер должен откыться. "); } } }/*******************************************************************/ /*****************Определение появления нового бара******************/ bool IsNewBar(string symbol, ENUM_TIMEFRAMES timeframe, datetime &m_tOld) { datetime tNew = (datetime)SeriesInfoInteger(symbol, timeframe, SERIES_LASTBAR_DATE); if(tNew > m_tOld) { m_tOld = tNew; return(true); } return(false); } /********************************************************************/ /******************Expert deinitialization function******************/ void OnDeinit(const int reason) { Comment(""); }/*******************************************************************/
Since the author isn't willing, I'll try it:
//+------------------------------------------------------------------+ //| test_1Vc2f.mq5 | //| Copyright © 2016, Vladimir Karputov | //| http://wmua.ru/slesar/ | //+------------------------------------------------------------------+ #property copyright "Copyright © 2016, Vladimir Karputov" #property link "http://wmua.ru/slesar/" #property version "1.00" //+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- //--- return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Expert deinitialization function | //+------------------------------------------------------------------+ void OnDeinit(const int reason) { //--- } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void OnTick() { //--- bool openNew,newDay,newHour; //--- newDay=IsNewBar(_Symbol,PERIOD_D1,oldDay); // if(newDay) Print("***** newDay ",newDay," mqlDateTime.hour ",mqlDateTime.hour); // Судя по распечатке newDay = true newHour=IsNewBar(_Symbol,PERIOD_H1,oldHour); if(newHour) Print("***** newHour ",newHour); // Судя по распечатке newDay = true } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ bool IsNewBar(string symbol,ENUM_TIMEFRAMES timeframe,datetime &m_tOld) { datetime tNew=(datetime)SeriesInfoInteger(symbol,timeframe,SERIES_LASTBAR_DATE); if(tNew>m_tOld) { Print("in: m_tOld = ",m_tOld); m_tOld=tNew; Print("out: m_tOld = ",m_tOld); return(true); } return(false); } //+------------------------------------------------------------------+
What remains to be decided is the structure"mqlDateTime" and where to declare the variables "oldDay" and "oldHour"...
Since the author is unwilling, I'll try:
What remains to be decided is the structure"mqlDateTime" and where to declare the variables "oldDay" and "oldHour"...
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use