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
потому что вы берете каждый раз новое время тика, и оно конечно не равно предыдущему.
In the last function you took the start time of the bar. so here too, take the bar time, not the tick time.
Explain to someone who doesn't understand which parameter in the code to change to which one.
How to describe the bar time, not the tick time?
Explain to someone who doesn't understand which parameter in the code to change to which.
How to describe the bar time rather than the tick time?
Explain to someone who doesn't understand which parameter in the code to change to which.
How to describe the time of a bar, not a tick?
Here is a popular description of the "new bar" event handler
In general, do not be lazy to sometimes look at articles and code base before asking a question
Вот тут все популярно описано Обработчик события "новый бар"
In general, don't be lazy to look at articles and code bases before you ask a question.
In mql4 you could find out in five lines whether the bar was new or not. And now a whole bunch of files have been written, it's not clear where to put them, what to write inside the program...
In short, if there are experts, then give me an example of code, so that I do not suffer, and I can send anyone to the library myself, either to the electronic or real one.
I don't doubt it, but I'm asking just to check mark - has anyone created one and the same EA in mql4 and mql5 and compared the test results? It should be perfect-similar if the code is properly transformed, shouldn't it? Or am I wrong?
If the testing is paralleled there and in mql5 the logic is placed in onTick, then it will be similar.
The only difference may be in spreads. In 5, the history contains the spreads. In the 4 version, the tester spread is equal to the current spread in the terminal.
If testing "every tick", it looks like it will be even smaller, as the tick generation algorithms are different in the versions.
In mql4 you could find out in five lines whether the bar was new or not. And now a whole bunch of files have been written, it is not clear where to put them, what to write inside the program...
In short, if there are experts, then give me an example of code, so that I do not suffer, and I can send anyone to the library myself, either to the electronic or real one.
Here, declare lastbar variable as static or globally, iTime array globally
There is an example on the page with the isNewBar function
https://www.mql5.com/ru/forum/2804/38752#comment_38752
1. I did not ask for nothing about the results of testing the same strategies on mql4 and mql5.
I used to enter the market on a new bar if the conditions meet the entry requirements and close the position if the indicators show the opposite signal and enter again on a new bar.
On mql4 I used this procedure to enter on a new bar:
void Fun_New_Bar() // Ф-ия обнаружения ..
{ // ... new bar
static datetime New_Time=0; // Time of the current bar
New_Bar=false; // no new bar
if(New_Time!=Time[0]) // Compare times
{
New_Time=Time[0]; // Now the time is
New_Bar=true; // New bar is caught
}
}
This is what the result of testing the robot on mql4 using my strategy looks like:
Thank you for sending the procedures to determine the new bar. They are working. I made a script that writes Alert on a new bar and tested it on M1 so I didn't wait too long.
But the same strategy gives completely different results (and the same ones) using both procedures in mql5 Expert Advisor:
I have not been tearing my shirt and stomping my feet for nothing. I want to repeat the results, but they do not coincide.
Here is what the onStart function in mql4 approximately looks like
int start()
{
GetIns();
Fun_New_Bar();
if (New_Bar==false) return(0);
if (Total()>0)
{
CloseSellEnd();
CloseBuyEnd();
}
if (Total()<1)
{
OpenBuy();
OpenSell();
}
return(0);
}
The same in mlq5:
void OnTick()
{
GetIns();
if (NewBar())
{
if (Total()>0) TryToClose();
if (Total()<1)
{
OpenBuy(Lots,10, "EUR/USD (Buy)",102406);
OpenSell(Lots,10, "EUR/USD (Sell)",102406);
}
}
}
GetIns to process indicator parameters, and Total() - gives the number of positions with the required magic for mql4 or with the required symbol for mql5.
Help.
I think I've found the reason for the discrepancy. You won't believe it. The MT4 and MT5 have a different quote history. Seems to be slightly different and the strategy is tested with a huge difference!!!!
Here's one plot on different terminals:
You take a closer look, there is a difference. A small one? And what is the difference between the test results of the strategy, also small???
I will contact the developers! What a beta!!!