Multicurrency advisor. Preferably the opinion of the developers.

 
There is a multi-currency advisor. In a nutshell, the point is this. All calculations are performed for one symbol, while trading is performed for another symbol. The Expert Advisor works with the explicit control of opening of a new bar. This way the next unpleasant thing happens. The Expert Advisor may not open (skip) a trade on a real account, but when checked in the Strategy Tester, this trade is present. Or, the Expert Advisor may open a real trade a bar later than necessary but, again, when checked in the Strategy Tester, the trade is there. What can it be related to?
 
LeoV:
There is a multi-currency EA. The brief idea is as follows. For one symbol all of the calculations are performed, and the trading is performed for another symbol. The Expert Advisor works with the explicit control of opening a new bar. This way the next unpleasant thing happens. The Expert Advisor may not open (skip) a trade on a real account, but when checked in the Strategy Tester, this trade is present. Or, the Expert Advisor may open a real trade a bar later than necessary but, again, when checked in the Strategy Tester, the trade is there. What can it be related to?

A position may not open if new quotes come in and you open with old ones...

 
kharko:

A position might not open if new quotes come in and you open with old ones...

I see what you mean, but the EA handles this situation. Just by looking at the log, there is no signal at all. It means that the EA has not triggered itself (does not give request to open position). Or it worked only on the next bar. And this happens not always. But only sometimes. And what is related to it is not clear at all...... Although in the tester - everything is fine and everything is opened and closed correctly

 
on which chart does the EA analyse or trade? Is the iBarShift() function used, with what flag, or not used at all?
 
LeoV:
There is a multicurrency EA. In brief, the meaning is as follows. All calculations are performed for one symbol, while trading is performed for another symbol. The Expert Advisor works with the explicit control of opening a new bar. This way the next unpleasant thing happens. The Expert Advisor may not open (skip) a trade on a real account, but when checked in the Strategy Tester, this trade is present. Or, the Expert Advisor may open a real trade a bar later than necessary but, again, when checked in the Strategy Tester, the trade is there. What can it be related to?

Try printout...

Print(.



before signal, after signal, on opening, after opening

print explicit conditions

like



// Print( " wait for MyOPEN == 1 " + MyOPEN );


if ( MyOPEN == 1 )

{

Print( " entered by MyOPEN == 1 " );
.


...


}



---

Oh, and more about opening new BARs !!!

Note that there are skipped bars! And the Tester does not generate missed bars

don't just look for a bar, just look for a new bar

---

right now in my real time

on the chart EURUSD M5 from the beginning of the day 140 bars formed, but in the CHF 137 bars, ie 3 bars lost :-)

if you simply look for the bar corresponding to the EUR in the CHF, you may miss a bar

---


and then there are requotes



If you had a SIGNAL and you can't miss it, just use condition to enter or exit the market!

and check if your signal is FILLED!

and until it is done - run the code to execute - so as not to get into a loop, make a counter

after leaving the counter - check to see if you need to go in - go out

and if it needs to go in - run it again



----

moreover, the trading code

moreover, this code cannot be simple!


( there is a code which is responsible for mechanics work - opening of trawl lossless closing i.e. work with orders after receiving signals )

 
LeoV:
There is a multi-currency Expert Advisor. The brief idea is the following. All calculations are performed for one symbol while trading is performed for another symbol. The Expert Advisor works with explicit control of opening a new bar. This way the next unpleasant thing happens. The Expert Advisor may not open (skip) a trade on a real account, but when checked in the Strategy Tester, this trade is present. Or, the Expert Advisor may open a real trade a bar later than necessary but, again, when checked in the Strategy Tester, the trade is there. What can it be related to?

These are called requotes. In the tester, trades are not requotes. Therefore, if the ticket of the opened trade is negative, we must reset the flag of the formed bar.




static int prevtime = 0; // Bar start time



...


int start() {


if (Time[0] == prevtime) return(0); // bar is the same, therefore exit

prevtime = Time[0]; // fresh bar, keep the time


...


int ticket = -1;


...


ticket = OrderSend(...); // try to open position

if (ticket < 0) { // position was not opened for some reason.

Sleep(30000);

// Here we reset the flag of the bar formed, so that we repeat the operation on the next tick, not on the next bar

prevtime = Time[1];

}


}

 

The EA works on hourly bars. It's not about requotes - the EA monitors this and will send a new request if necessary. I wrote about the fact that the EA does not even trigger in order for it to at least try to start opening an order. That is, 2-3 orders, it opens well (as it should be), and the fourth (or third) may not even start to open it or open an hour later. Although, if you check this moment in the tester, this order will be in the right place.

The matter, as I understand, is that ticks for instruments do not come evenly. And the tick for opening a new bar for the symbol at which the calculation is done may come much later than for the symbol at which we trade. Or vice versa. And here a discrepancy can occur. But how can this be avoided?

 
Your Expert Advisor assumes that hourly candles on different instruments open synchronously. In other words, when a new hourly candlestick appears on EURUSD, the Expert Advisor starts, which checks values on hourly timeframe of GBPUSD. But if at that moment the new hourly on the pound has not started - everything goes into tatters. In general, we need to rearrange the EA logic a bit.
 
Rosh:
Your Expert Advisor implies that Hour candles on different symbols open synchronously. That is, when a new 1-hour candlestick appears on EURUSD, the Expert Advisor will start that checks values on the hourly timeframe of GBPUSD. But if at that moment the new hourly on the pound has not started - everything goes into tatters. In general, we need to rearrange the EA logic a bit.

Thanks for the reply, I thought that was the reason. Please, can you tell me how? Because this is a big problem. Here's a screenshot, from the real one. We can see that in the Strategy Tester the pose was opened at 15.00 and in real account it was opened only at 16.00. Although we have the same parameters in the Strategy Tester and on the real account.

 
LeoV:

The EA works on hourly bars. It's not about requotes - the EA monitors this and will send a new request if necessary. I wrote about the fact that the EA does not even trigger in order for it to at least try to start opening an order. That is, 2-3 orders, it opens well (as it should be), and the fourth (or third) may not even start to open it or open an hour later. Although, if you check this moment in the tester, this order will be in the right place.

The matter, as I understand, is that ticks for instruments do not come evenly. And the tick for opening a new bar for the symbol at which the calculation is done may come much later than for the symbol at which we trade. Or vice versa. And here a discrepancy can occur. But how to avoid it?

Consider that a new tick of ANY hour bar (for any instrument) is the beginning of the hour

---

correct the logic in this vein...

as soon as the hour bar opens on any instrument

re-calculate the other instrument, assuming the bar has already closed even though it has not formed a new bar

because in a couple of ticks or a few seconds it will appear there


---

let's say you count 2 or 3 instruments

you can catch the beginning of the hour on at least 20 symbols - preferably the yen instruments since they are very fast



 
// ---  практически гарантия ловли начала часа двумя БОДРЫМИ парами
   if ( TimeSaveBehchH1 == iTime("GBJJPY",PERIOD_H1,0) )
   {
       TimeSaveBehchH1 = iTime("GBJJPY",PERIOD_H1,0); // новый бар  
   }
   if ( TimeSaveBehchH1 == iTime("USDJPY",PERIOD_H1,0) )
   {
       TimeSaveBehchH1 = iTime("USDJPY",PERIOD_H1,0); // новый бар  
   }
//---
   if ( TimeSaveBehchH1 == iTime("EURUSD",PERIOD_H1,0) ) // в довершении ловим на своей рабоче паре
   {
       TimeSaveBehchH1 = iTime("EURUSD",PERIOD_H1,0); // новый бар  
   }
   if ( TimeSaveBehchH1 == iTime("USDCHF",PERIOD_H1,0) ) // ловим на второй паре 
   {
       TimeSaveBehchH1 = iTime("USDCHF",PERIOD_H1,0); // новый бар 
   }


to be honest and that's not very nice ... the tick did not come at these pairs and you will fly by again

if you show a piece of code that generates an input - you may be able to find the error in the logic faster

 
LeoV:
Rosh:
Your Expert Advisor assumes that the hour candlesticks on different symbols open synchronously. That is, when a new 1-hour candlestick appears on EURUSD, the Expert Advisor will start that checks values on hourly timeframe of GBPUSD. But if at that moment the new hourly on the pound has not started - everything goes into tatters. In general, we need to rearrange the EA logic a bit.

Thanks for the reply, I thought that was the reason. Please, can you tell me how? Because this is a big problem. Here's a screenshot, from the real one. We can see that in the Strategy Tester the pose was opened at 15.00 and in real account it was opened only at 16.00. Although in the tester and on the real parameters are the same.

...

For the traded symbol the tick of the new bar came earlier that is why the old bars of the analyzed symbol took part in the analysis, the start has worked off and is waiting for the next hour. It's fun to guess without seeing a piece of code.

Reason: