Multicurrency advisor. Preferably the opinion of the developers. - page 3

 
Reshetov:
LeoV:
YuraZ wrote (a): To be honest and it's not very nice ... let's say the tick has not come for these pairs and you'll miss it again

If you showed a piece of code which generates the input, you could find the logic error quicker

But there should be a commonly accepted solution in MQL, right? How to "synchronize" the opening of bars for different symbols? Well, apparently, we should wait for the opening of a new bar for all symbols that are used. But how to do it correctly?

There's no need for synchronicities and other bicycle inventions. Everything has already been invented a long time ago. The presence of a new formed bar is checked only for that instrument, on which the Expert Advisor is installed at the arrival of the first tick. And the start() event also triggers only on that symbol at arrival of a new tick. I gave you a piece of code that performs this check so that the next position, in case of requotes, is not opened on the next bar and after a failure it tries to open on the same bar. It all works fine for me both in single and multicurrency modes. The deal in case of requotes is opened on the same bar, but only with some delay, and therefore not always at the open price of the bar, but with some offset. I.e. there will be differences with the tester, but not in bars, but in the opening price.


Yuri, the beginning of a new hour will happen even if the tick did not come!

We will start a new hour even if the tick did not come!


it is possible to calculate a new bar by a tick in a new bar of ANY instrument


LeoV is waiting for a new tick synchronously for all pairs used

 
YuraZ:
Thecore:

YuraZ wrote (a):

frankly and it's not exactly pretty ... If the tick did not come for these pairs and you will miss them again

If the tick did not come, you cannot place an order immediately, unless you use a script,

And only if ticks come to brokerage companies and they don't transmit them to your terminal (in the daytime).

That's why, when I was implementing a multicurrency Expert Advisor, I was making a State Machine by Miles (or Moore),

which monitored order open states for the needed pairs. Of course it was not always possible

Naturally, it was not always possible to open at the right price, but this approach guaranteed that the orders would be EXACTLY open.

easy ! it is possible to place an order :-) if the tick did not come

think it over ! if you don't , i will give you a hint !

Usually with multicurrency EAs the situation is such that if there is no 100% guarantee of order arrival

then the logic of advisor's work will be destroyed.

By the way, do not forget that your EA is working on the ticks of the pair it is hovering on,

so, even if there was a tick on another pair, and there was not a tick on the pair with your EA attached,

then the synchronization will be broken.

Do not forget about such unpleasant things as loss of connection with brokerage companies and requotes (if you are dealing with a real account).

By the way, on micro reals I often have situations when an order is never passed until the terminal is reloaded.

Even in manual mode. They are waiting for something, waiting...

That's why I have long given up systems based on pair orders.

It's too troublesome.

 
thecore:
YuraZ:
thecore:

YuraZ wrote (a):

frankly and it's not exactly pretty ... If the tick did not come for these pairs and you will miss them again

If the tick did not come, you cannot place an order at once unless you use a script,

And only if ticks come to brokerage companies and they don't transmit them to your terminal (in the daytime).

That's why, when I was implementing a multicurrency Expert Advisor, I was making a State Machine by Miles (or Moore),

which monitored order open states for the needed pairs. Of course it was not always possible

Naturally, I was not always able to open at the necessary price, but this approach guaranteed that the orders would ALWAYS be opened.

easy ! it is possible to place an order :-) if the tick did not come

think it over ! if you don't , i will give you a hint !

Usually with multicurrency EAs the situation is such that if there is no 100% guarantee of order arrival

then the logic of advisor's work will be destroyed.

By the way, do not forget that your EA is working on the ticks of the pair it is hovering on,

so, even if there was a tick on another pair, and there was not a tick on the pair with your EA attached,

then the synchronization will be broken.

Do not forget about such unpleasant things as loss of connection with brokerage companies and requotes (if you are dealing with a real account).

By the way, on micro reals I often have situations when an order is never passed until the terminal is reloaded.

Even in manual mode. They are waiting for something, waiting...

That's why I have long given up systems based on pair orders.

Painfully troublesome.

You probably meant to write TIC... but you just wrote order.


You understand that an EA may enter on EURUSD and use USDCHF.

Just write

LevelOpenBUY = MarketInfo("USDCHF",MODE_ASK);

... = OrderSend ("USDCHF",Lot, LevelOpenBUY, ...



Piece of code that works

OpenLevel = MarketInfo( sSymbol, MODE_BID );
if ( TDARELOCK == 0 )
ticket=OrderSend( sSymbol,OP_SELL,Lots,OpenLevel,3,0,0,sComment,mMagic,0,Red);


----

And the TIC for USDCHF may not be enough to get a tick for any Pair.


I hope MQL5 will not need to receive ticks for the program to work

they promised to make events, which means that any piece of code can be triggered by an event

----



the second question concerning freezes in the terminal - this problem can be solved by rebooting - this is more likely to the developers.

I have seen this too

this can also be fixed and there is an example here on the forum

Ну вот и все - отлично работает процедруа программного реконнекта :)
НЕ ЗАБУДЬТЕ ВКЛЮЧИТЬ ГАЛОЧКУ "Разрешить импорт ДЛЛ" в настройках МТ4.
//В начале советника подключаем необходимые ДЛЛ-ки и модули
#include <winuser32.mqh>
#import "user32.dll"
int GetParent(int hWnd);
#import
 
//Копируем процедуру в наш советник или библиотеку и вызываем ее там, где вам нравиться
//Лично я вызываю перед рассчетом данных - но можно перед установкой ордеров. Правда тогда
//возможно нужно будет делать задержку в пару секунд
//У меня все работает
int Reconnect()
{
int result;
int hwnd = WindowHandle(Symbol(), Period()); // получаем хендл окна графика
hwnd = GetParent(hwnd); // получаем хендл родительского окна
hwnd = GetParent(hwnd); // ...
hwnd = GetParent(hwnd); //добираемся до главного окна
result = SendMessageA(hwnd, WM_COMMAND, 37400, 0);
Print("SendMessageA = " + result); //посылаем сообщене
return;
}

---

so if you send an order but it does not open, you can send this piece of code to work out

 

YuraZ писал (а):

Usually with multicurrency EAs it is usually the case that if there is no guarantee of a 100% order coming in,

You probably meant to write TIC... You must have meant TIC, but you wrote order.

I was referring to placing an order at 100%.

 
thecore:

YuraZ wrote (a):

Usually with multicurrency EAs it's usually the case that if there's no guarantee of a 100% order coming in,

You probably meant to write TIC... You must have meant TIC

I was referring to placing a 100% order.


But you do understand that this is not only in a multicurrency system

You don't get a 100% guarantee in an ordinary Expert Advisor... never a 100% guarantee

because there are factors

INTERNET

YOUR PROVIDER

YOUR DC PROVIDER

your hardware

DC equipment

etc.

---

that's what stops are for... or a spare computer with a different provider (if the problem is on your side)

---


but if it is an error in the logic of the program!!! then it is another matter and it is treated

---


and logic should not fall apart because the entry was not at 15:00 but at 15:05 or 15:02

this is exactly what we see with the author of the thread! he is trying to enter at 15:00:00:00

( numbers are arbitrary)


he's not doing pips so entering at 15:00 or 15:01 - 15:07 shouldn't be too much trouble for him


That's what I'm saying: you cannot be bound strictly to the beginning of a bar for all necessary symbols - it's enough to get the beginning of a bar at any of them

 
YuraZ:
thecore:
YuraZ:
thecore:

YuraZ wrote (a):

frankly and it's not exactly pretty ... If the tick did not come for these pairs and you will miss them again

If the tick did not come, you cannot place an order immediately, unless you use a script,

And only if ticks come to brokerage companies and they don't transmit them to your terminal (in the daytime).

That's why, when I was implementing a multicurrency Expert Advisor, I was making a State Machine by Miles (or Moore),

which monitored order open states for the needed pairs. Of course it was not always possible

Naturally, I was not always able to open at the necessary price, but this approach guaranteed that the orders would ALWAYS be opened.

easy ! it is possible to place an order :-) if the tick did not come

think it over ! if you don't , i will give you a hint !

Usually with multicurrency EAs the situation is such that if there is no 100% guarantee of order arrival

then the logic of advisor's work will be destroyed.

By the way, do not forget that your EA is working on the ticks of the pair it is hovering on,

so, even if there was a tick on another pair, and there was not a tick on the pair with your EA attached,

then the synchronization will be broken.

And do not forget such unpleasant things as loss of connection with brokerage companies and requotes (if you are dealing on a real account).

By the way, on micro reals I often have situations when an order is never passed until the terminal is reloaded.

Even in manual mode. They are waiting for something, waiting...

That's why I have long given up systems based on pair orders.

It's too troublesome.

You probably meant to write TIC... but you just wrote order.

If your Expert Advisor is standing on EURUSD, you understand that it may enter by USDCHF.

it is enough to write

LevelOpenBUY = MarketInfo("USDCHF",MODE_ASK);

... = OrderSend ("USDCHF",Lot, LevelOpenBUY, ...

Piece of code that works

OpenLevel = MarketInfo( sSymbol, MODE_BID ); if ( TDARELOCK == 0 ) ticket=OrderSend ( sSymbol,OP_SELL,Lots,OpenLevel,3,0,0,0,sComment,mMagic,0,Red);

----

the TIC for USDCHF may not be enough to get a tick for any Pair

I hope that in MQL5 you won't need to receive ticks for the program to work

they promise to make events, which means any piece of code may be written upon an event

----

the second question concerning freezes in the terminal - this problem can be solved by rebooting - this is more likely to be addressed to the developers.

I've seen this too -

this is also treated and there's an example here on the forum

Ну вот и все - отлично работает процедруа программного реконнекта :)
НЕ ЗАБУДЬТЕ ВКЛЮЧИТЬ ГАЛОЧКУ "Разрешить импорт ДЛЛ" в настройках МТ
4.
//В начале советника подключаем необходимые ДЛЛ-ки и модули
#include <winuser32.mqh>
#import "user32.dll"
int GetParent(int hWnd);
#import

//Копируем процедуру в наш советник или библиотеку и вызываем ее там, где вам нравиться
//Лично я вызываю перед рассчетом данных - но можно перед установкой ордеров. Правда тогда
//возможно нужно будет делать задержку в пару секунд
//У меня все работает
int Reconnect()
{
int result;
int hwnd = WindowHandle(Symbol(), Period()); // получаем хендл окна графика
hwnd = GetParent(hwnd); // получаем хендл родительского окна
hwnd = GetParent(hwnd); // ...
hwnd = GetParent(hwnd); //добираемся до главного окна
result = SendMessageA(hwnd, WM_COMMAND, 37400, 0);
Print("SendMessageA = " + result); //посылаем сообщене
return;
}

---

so if you send an order but it does not open you can of course send a similar piece of code to work out

Rebooting of the terminal is great but what should you do with other Expert Advisors at this moment that are hanging on other windows

and their operating logic is naturally different and does not react well to frequent reloading because values of variables get lost,

that we have been accumulating for so long.

Even if the Expert Advisor is based on EURUSD, you realise that it may enter by USDCHF

It is enough to write

LevelOpenBUY = MarketInfo("USDCHF",MODE_ASK);

... = OrderSend ("USDCHF",Lot, LevelOpenBUY, ...

Of course I do. In a multi-currency EA this is exactly how the other pairs are controlled.

But if on the main pair the last tick of the previous hour came, for example, at 7.50, and the first tick of the hour came,

at 8.10, and on the secondary symbol the first tick of the hour came at 8.00,

then it's hard to expect that the advisor on the major currency pair will place an order on the minor one

at 8.00, at best at 8.10.

The case when the EA operates as a script, i.e. it does not give the system a break, it just flails and flails,

I don't consider it in spite of the ticks. It is better to write a script.

 
thecore:
YuraZ:
thecore:
YuraZ:
thecore:

YuraZ wrote (a):

frankly and it's not exactly pretty ... If the tick did not come for these pairs and you will miss them again

If the tick did not come, you cannot place an order immediately, unless you use a script,

And only if ticks come to brokerage companies and they don't transmit them to your terminal (in the daytime).

That's why, when I was implementing a multicurrency Expert Advisor, I was making a State Machine by Miles (or Moore),

which monitored order open states for the needed pairs. Of course it was not always possible

Naturally, I was not always able to open at the necessary price, but this approach guaranteed that the orders would ALWAYS be opened.

easy ! it is possible to place an order :-) if the tick did not come

think it over ! if you don't , i will give you a hint !

Usually with multicurrency EAs the situation is such that if there is no 100% guarantee of order arrival

then the logic of advisor's work will be destroyed.

By the way, do not forget that your EA is working on the ticks of the pair it is hovering on,

so, even if there was a tick on another pair, and there was not a tick on the pair with your EA attached,

then the synchronization will be broken.

Do not forget about such unpleasant things as loss of connection with brokerage companies and requotes (if you are dealing with a real account).

By the way, on micro reals I often have situations when an order is never passed until the terminal is reloaded.

Even in manual mode. They are waiting for something, waiting...

That's why I have long given up systems based on pair orders.

It's too troublesome.

You probably meant to write TIC... but you just wrote order.

If your Expert Advisor is standing on EURUSD, you understand that it may enter by USDCHF.

it is enough to write

LevelOpenBUY = MarketInfo("USDCHF",MODE_ASK);

... = OrderSend ("USDCHF",Lot, LevelOpenBUY, ...

Piece of code that works

OpenLevel = MarketInfo( sSymbol, MODE_BID ); if ( TDARELOCK == 0 ) ticket=OrderSend ( sSymbol,OP_SELL,Lots,OpenLevel,3,0,0,0,sComment,mMagic,0,Red);

----

the TIC for USDCHF may not be enough to get a tick for any Pair

I hope that in MQL5 you won't need to receive ticks for the program to work

they promise to make events, which means any piece of code may be written upon an event

----

the second question concerning freezes in the terminal - this problem can be solved by rebooting - this is more likely to be addressed to the developers.

I've seen this too -

this is also treated and there's an example here on the forum

Ну вот и все - отлично работает процедруа программного реконнекта :)
НЕ ЗАБУДЬТЕ ВКЛЮЧИТЬ ГАЛОЧКУ "Разрешить импорт ДЛЛ" в настройках МТ4.
//В начале советника подключаем необходимые ДЛЛ-ки и модули
#include <winuser32.mqh>
#import "user32.dll"
int GetParent(int hWnd);
#import
 
//Копируем процедуру в наш советник или библиотеку и вызываем ее там, где вам нравиться
//Лично я вызываю перед рассчетом данных - но можно перед установкой ордеров. Правда тогда
//возможно нужно будет делать задержку в пару секунд
//У меня все работает
int Reconnect()
{
int result;
int hwnd = WindowHandle(Symbol(), Period()); // получаем хендл окна графика
hwnd = GetParent(hwnd); // получаем хендл родительского окна
hwnd = GetParent(hwnd); // ...
hwnd = GetParent(hwnd); //добираемся до главного окна
result = SendMessageA(hwnd, WM_COMMAND, 37400, 0);
Print("SendMessageA = " + result); //посылаем сообщене
return;
}

---

so if you send an order but it does not open you can of course send a similar piece of code to work out

Rebooting of the terminal is great but what should you do with other Expert Advisors at this moment that are hanging on other windows

and their operating logic is naturally different and does not react well to frequent reloading because values of variables get lost,

that we have been accumulating for so long.

Even if the Expert Advisor is based on EURUSD, you realise that it may enter by USDCHF

It is enough to write

LevelOpenBUY = MarketInfo("USDCHF",MODE_ASK);

... = OrderSend ("USDCHF",Lot, LevelOpenBUY, ...

Of course I do. In a multi-currency EA this is exactly how the other pairs are controlled.

But if on the main pair the last tick of the previous hour came, for example, at 7.50, and the first tick of the hour came,

at 8.10, and on the secondary symbol the first tick of the hour came at 8.00,

then it's hard to expect that the EA hovering on the major currency pair will place an order on the minor one

at 8.00, at best at 8.10.

The case when the EA operates as a script, i.e. it does not give the system a break, it just flails and flails,

I don't consider it in spite of the ticks. It would be better to write a script.



1 and you think that Reconnect calls the Init () function ? and restarts the EA ?


You are wrong...


In addition, it is wise to save calculated and valuable variables


if i don't have complex code i store it in GLOBAL VARIABLE

if the code is complex I write it to disk and read it on restart - if restart was by mistake I just restore it

by the way it is easy to determine if it was or was not by mistake




---

2 If there is a new o'clock for some currency pair - no tick for other pairs - then no matter when there is a tick

A NEW BAR - or more precisely a new hour can be considered to have come.


and therefore it is possible to count the late pairs by CLOSE thinking they are covered too


the ticks there will come later and the bar will be time-shifted !!! but the real Hour has passed

---


it is OK to place an order at a currency pair without a tick - you know how

i am not saying it will be exhibited at 8:00 - ( conventional figure )


it may be set up as soon as a NEW TICK arrives at a new bar on any currency pair


---


>o if the last tick of the previous hour on the main pair came, for example, at 7.50, and the first tick of the hour came

>at 8.10, and on a secondary pair the first tick of the hour came in at 8.00,

>it is hard to expect that an EA hovering on the major currency pair will place an order on a secondary

>at 8.00, or at best at 8.10.


working in the multicurrency mode, you do not need to count the time of the main pair or not the main one

you need just catch a tick of the beginning of a new bar at any currency pair - and calculate the indicators by CLOSE, not by bar closing

and in - out.


because the entry will be on the tick of a new bar of any controlled pair because it will be a signal for a new hour! (in this case a new hour)





 
YuraZ:

if you work in multicurrency, you don't need to time the main bar or not the main bar

it is necessary to catch a tick of a new bar start - and to calculate the indicators by CLOSE, and not by bar close

and in - out


because the entry will be precisely on the tick of a new bar of any controlled pair because it will be a signal for a new hour! (in this case a new hour)

More like this.......

 
LeoV:
YuraZ:

you don't have to time the main currency pair or not the main one

you need to catch the tick of a new bar for any currency pair - and calculate the indicators by CLOSE and not by bar closing

and in - out


because the entry will be precisely on the tick of a new bar of any controlled pair because it will be a signal for a new hour! (in this case a new hour)

More like this.......

Rework the Expert Advisor by this logic, and the probability of the PROBLEM will be reduced many times

if you add catching of a new hour on ALL pairs which are in a window of the market review especially on yens then practically you should not have failures


1 Just don't catch the new bar in sync on all pairs !!!

2 Catch NEW BAR on any of the CONTROLLED pairs, start recalculation of all required pairs on current CLOSE ...

( by the way, you may need to redo some of YOUR indicators )


decide to go in - exit - or continue to hold

 
YuraZ:

Rework the Expert Advisor by this logic, the probability of a problem will be reduced at times

if you add catching of a new hour on ALL pairs which are in the market overview window, especially on yen pairs, you practically should not have failures

1 just do not catch a new bar in sync on all pairs !!!

2 Catch a NEW BAR on any of the CONTROLLED pairs, start recalculation of all needed pairs on the current CLOSE ...

( by the way some of YOUR indicators may need to be recalculated )

and make a decision to enter - exit - or to continue holding

Thank you veri Macha)))))))))))))

Reason: