[ARCHIVE]Any rookie question, so as not to clutter up the forum. Professionals, don't pass it by. Can't go anywhere without you - 5. - page 404

 
hoz:
1. Well, if new data arrived, this is what we need, isn't it?
2. Well, yes, we need data from bar 0, of course. MarketInfo() pulls data from the zero bar, that's it. Then why compare it with something else?

3. even if there is a hole in history, it will not affect the current calculations. It would have had an impact at the time when the hole was there. I.e., if we obtain the current Ask, we do not really care what prices were several bars ago (I mean not formally, but concerning the current moment regarding a certain market variable, because function RefreshRates() will do the trick regarding the current moment in time on the 0-th bar!

Of course, I dug deep, but I want to understand how to behave better.

4. You, Vadim, told me that I wrote the function incorrectly above:

double fGet_TradePrice(int fi_price,       // Цена: 0 - Bid; 1 - Ask
                       string fs_symbol)   // валютная пара
{
 double ld_price = 0.0;
   
switch (fi_price)
 {
  case 0:
   {
    if (fs_symbol == Symbol())
     {
      RefreshRates(); // Зачем этот тормоз без обработки возвращаемого значения?
      ld_price = Bid;
     }
    else ld_price = MarketInfo(fs_symbol, MODE_BID); // <-- Этого достаточно.
   } 
  case 1:
   {
    if (fs_symbol == Symbol())
     {
      RefreshRates(); // Зачем этот тормоз без обработки возвращаемого значения?
      ld_price = Ask;
     }
    else ld_price = MarketInfo(fs_symbol, MODE_ASK); // <-- Этого достаточно.
   }
 }
if (ld_price != 0) return(ld_price); // Некорректно! Что функция будет возвращать, если цена равна нулю?
}

In your opinion, what is wrong about it?

1. If there is no data, but we know nothing about it? It returns FALSE. How should this be evaluated? No data or an error, or is there still data?
2. You have to reconcile to solve the problem of the 1st item.
3. You don't consider the dynamics of the process. Turn on the computer, the terminal. All the data seems to have come in. Everything converged on the zero bar. Signals are found. The deal is done. Turns out not all the data came in. Five minutes later we got the missing bars with numbers 1,2,3,4,5. The signal disappeared. What to do?

4. I marked it in red. A possible error of choosing a wrong identifier in the switch is not handled yet. I wrote above how it should be done.

It is useless to call RefreshRates() without waiting for the result. It may fail for a long time.

 
Hello everyone. I have such a question. I trade on several accounts (two in one brokerage company and one in another), so I use Best copier, it's very convenient. It is installed on one account (the exporter) on any chart and copied into other accounts (importers), where this EA is also installed on the same chart (if you put it, in the importer, on several charts, it will open as many orders). Once when I wanted to check work with it on one of brokerage companies and set a demo account), at one wonderful moment it was spontaneously set on several charts and of course it opened as many orders. Then I didn't pay much attention to it and thought it was a glitch of this brokerage company terminal. Then I traded for a long time on the accounts mentioned above and nothing like that happened. But yesterday just during the news release such situation happened again on one of the accounts (for another brokerage company, not the one with installed exporter). At 6 charts advisors were automatically placed and the most interesting thing was that 16 orders were opened at one symbol. Why does this happen and what is the reason? Is it a disadvantage of the Expert Advisor itself or some other reason? Is there any way to fix it? Thanks in advance.
 
// Зачем этот тормоз без обработки возвращаемого значения?

Who asks such a question?
 
hoz:

What is wrong with it in your opinion?


It's not wrong, it's just muddy.

Ending:

 if (ld_price != 0)
return (ld_price); 

If ld_price = 0, the function will return 0 by itself. Therefore we don't need a check.

This one is a breakdown:

 if (fs_symbol == Symbol())
         {
             RefreshRates();
             ld_price = Bid;
         }
         else
             ld_price = MarketInfo(fs_symbol, MODE_BID);

Also unnecessary. You can use MraketInfo() in all cases.

In the end, the function turns into MarketInfo() function in its pure form (if you remove all unnecessary things).

 

In principle, theoretically, these are the right places:

RefreshRates();
ld_price = Bid;
RefreshRates();
ld_price = Ask;

We don't care what RefreshRates() returns, it is important that the Ask and Bid variables have the latest values known to the terminal.

 

Hello!

What is the reason for the different results of the tester for the same EA?

The tested period, currency pair and timeframe are the same, but the results obtained today are very different from previous ones, the EA has stopped opening long positions.

Whether the terminal quotes are to blame or it is the weekend, I do not know. Maybe the knowledgeable people can open my eyes to the obvious reason?

 
skyjet:

Hello!

What is the reason for the different results of the tester for the same EA?

The tested period, currency pair and timeframe are the same, but the results obtained today are very different from previous ones, the EA has stopped opening long positions.

Whether the terminal quotes are to blame or it is the weekend, I do not know. Maybe the knowledgeable people can open my eyes to the obvious reason?


Even two tests done in a row one after the other can be different, and very noticeably so. The broker changes the spread and testing is done with a different spread. A change of one point is enough.

If there was a previous test a long time ago, maybe the settings have loosened.

 
Zhunko:

1. If there is no data and at the same time there is all this data, but we know nothing about it? It returns FALSE. How should this be interpreted? Is there no data or an error, or is there data?

I do not understand you. Let's go in order... We call RefreshRates(), no data came in... But there is data. What we have here is a mess. If the data didn't come, the data won't be available or the data have not been updated because the market variable has not changed... There are only two options.

If it returns TRU after callingRefreshRates(), then the data has been updated. And if it returns FELS, then either they haven't updated, because there is an error or they haven't updated, because data is fresh and doesn't need to be updated.

Therefore, I understand that this can be seen as follows:RefreshRates() checks data, if data is not new, it does not update those data which are not new, i.e. have not changed, and if new, it updates. So you can only rely on the flag returned byRefreshRates(). Do you have any other options?

Zhunko:

2. You need to reconcile to solve the problem of the 1st item.

You said that:

I reconcile data from server (MarketInfo()) with zero bar. Waiting for them to be the same.

Well MarketInfo() is pulling from zero bar as it is... What do YOU mean by the above?

Zhunko:

3. You don't consider the dynamics of the process. Turned on the computer, the terminal. All the data seems to have come in. Everything converged on zero bar. Signals are found. The deal is done. Turns out not all the data came in. 5 minutes later we got the missing bars with numbers 1,2,3,4,5. The signal disappeared. What to do?

I decided to update it again. But what if we call RefreshRates() and it updates data slowly? I.e. some of the calculations will be performed with some market data, and some with other data... What then?

Zhunko:

4. Red marked. Also, a possible error of selecting the wrong identifier in the switch is not handled. I've written above how it should be handled.

It is useless to call RefreshRates() without waiting for the result. It may fail for a long time.

Hm. Well, if we wait for it, the quote may change... Is there a two-way street here?

RefreshRates(); // Why this brake without return value processing?

You mention it several times, but there's still no specifics. I mean, as much as I see this function usually used, it's just before the code where the market data variables are used and that's it. They don't really think about it. But I thought about it, and decided to figure out how to get it right. To know for sure that such and such approach is indeed correct and will work under all normal conditions.

So Vadim, what do you mean by this expression:

"

Why this brake without processing the return value?"

How can they be processed? I wrote my logic above, but got no answer. I described it quite accurately and without any variants.

 
Integer:


It's not wrong, it's just muddy.

Ending:

if (ld_price != 0)
    return (ld_price); 

If ld_price = 0, the function will return 0 by itself. Therefore, no check is needed.

Why would I do that? You just need to add else, so that the function returns some other value, which would mean "No price". Seems logical. When I threw the function, I was thinking more about previous logic, then I didn't pay attention to its end. And I don't understand why the 0 function returns 0 by itself...
Integer:


That's the breakdown:

if (fs_symbol == Symbol())
{
    RefreshRates();
    ld_price = Bid;
}
else
    ld_price = MarketInfo(fs_symbol, MODE_BID);

It is also not necessary. You can use MraketInfo() in all cases.

In the end, the function turns into a pure MarketInfo() function (if you remove all unnecessary things).


And then why Ask at all (if we're talking about purchase price specifically), if we can always use MarketInfo(fs_symbol, MODE_ASK) ? After all, if you look at it this way, by referring to Ask, you can't be sure that it's accurate at this moment in time?
 
Integer:

It doesn't matter what the RefreshRates() function returns, it is important that the Ask and Bid variables have the latest values known to the terminal.


Practically, we need something else, as far as I understand it. And we need last Ask and Bid server and not local terminal ones. Right?

That's why I started a discussion here, to understand once and for all how to organize it more logically and correctly. For in theory this is correct, but in practice...