[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 401

 

hoz:

1. Если эксперт снять с графика тоже поступит команда ТРУ от IsStopped() ?

2. i.e. more often only when taking owls or scripts off the chart, is there any other reason for this function to be triggered?

3. Where can I read about it?

4. And in the body of the function already create a condition, when the condition is met, then IsStopped() = true, right?

1. Yes.

2. I know only about taking the chart off.

3. Don't know.

4. Yes, it can and it will work.

 
4. ?
 
tara:
4. ?

?
 
tara:
4. ?

I must have misunderstood the question. If you make IsStopped()=true yourself, it's not possible.
 
hoz:

?

Show me the implementation, because I can't even imagine it as a quadratic trinomial.
 
Integer:

I must have misunderstood the question. If you make IsStopped()=true yourself, it is not possible.

That's all. The question is removed.
 
Integer:

I must have misunderstood the question. If you make IsStopped()=true yourself, it's impossible.


That's understandable. I didn't mean to do it myself. In fact, if something is executed in the loop, it is executed until the Expert Advisor or script is removed from the chart, and, accordingly, at that point a command is sent to the server:

IsStoped() = true;

I've opened functions written by TarasBy (I write mine myself, but I periodically look into it, as he has an interesting approach). So there he has such a function:

//IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII+
//|  Автор : TarasBY, taras_bulba@tut.by                                              |
//+-----------------------------------------------------------------------------------+
//|        Запускаем в цикл получение рыночной цены.                                  |
//IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII+
double fGet_TradePrice (int fi_Price,           // Цена: 0 - Bid; 1 - Ask
                        bool fb_RealTrade,      // реальная торговля или оптимизация\тестирование
                        string fs_Symbol = "")  // валютная пара
{
    double ld_Price = 0.0;
//----
    if (fs_Symbol == "")
    {
       fs_Symbol = Symbol();
    }
    //RefreshRates();
    switch (fi_Price)
    {
       case 0:
          if (fb_RealTrade)
          {
             while (ld_Price == 0.0)
             {
                if (fs_Symbol == Symbol())
                {
                   ld_Price = Bid;
                }
                else
                {
                   ld_Price = MarketInfo (fs_Symbol, MODE_BID);
                }
                if (!IsExpertEnabled() || IsStopped())
                {
                   break;
                }
                Sleep (50);
                RefreshRates();
             }
          }
          else
          {
             if (fs_Symbol == Symbol())
             {
                return (Bid);
             }
             else
             {
                return (MarketInfo (fs_Symbol, MODE_BID));
             }
          }
          break;
       case 1:
          if (fb_RealTrade)
          {
             while (ld_Price == 0.0)
             {
                if (fs_Symbol == Symbol())
                {
                   ld_Price = Ask;
                }
                else
                {
                   ld_Price = MarketInfo (fs_Symbol, MODE_ASK);
                }
                if (!IsExpertEnabled() || IsStopped())
                {
                   break;
                }
                Sleep (50);
                RefreshRates();
             }
          }
          else
          {
             if (fs_Symbol == Symbol())
             {
                return (Ask);
             }
             else
             {
                return (MarketInfo (fs_Symbol, MODE_ASK));
             }
          }
          break;
   }
//----
   return (ld_Price);
}

I wonder why there is a condition?

if (!IsExpertEnabled() || IsStopped())

We get BID at once and then the IsStopped( ) and IsExpertEnabled() function flags are checked. Where is the logic? In my opinion, it's easier to check it at once, and if something is wrong, to exit the function.

Then we have the RefreshRates() command. In the beginning the market data was not refreshed, and in the end, when we have already received the BID data, it is refreshed. Either I'm thinking incorrectly or the author has a specific way of thinking that doesn't fit in with mine. What is the point?

 
hoz:

I've discovered functions written by TarasBy (I write my own, but I check them from time to time, as he has an interesting approach). So he has such a function there:

I wonder why there is a condition?

We get BID at once and then the IsStopped( ) and IsExpertEnabled() function flags are checked. Where is the logic? In my opinion, it's easier to check it at once, and if something is wrong, to exit the function.

Then we have the RefreshRates() command. In the beginning the market data was not refreshed, and in the end, when we have already received the BID variables data, they are refreshed. Either I'm thinking incorrectly or the author has a specific way of thinking that doesn't fit in with mine. What is the point?

Maybe Igor will answer tomorrow...

I would have done so:

switch (fi_Price)
 {
  case 0: return(MarketInfo(fs_Symbol, MODE_BID));
  case 1: return(MarketInfo(fs_Symbol, MODE_ASK));
 }

Everything else is superfluous, in my opinion.
 

Greetings all!

Can you tell me if it is possible to teach an EA to refer to the last triggered alert?

 
Zhunko:

Maybe Igor will answer tomorrow...

I would do so:

Everything else is superfluous, in my opinion.


Vadim, I would have done exactly as you wrote! That's why I asked the question. I thought, maybe I missed something. I'm still observing my own logic and the logic of other programmers. Because in addition to the basic logic, I see that I need to consider a number of factors.
Reason: