A bug in the OrderSend() function ? - page 5

 
Sepulca:

The static works 100%. Here's the test:

And the results:


Well, it works for me just like it did before... No change! I even have the function to open a new bar:

bool isNewBar()
   {
      static datetime lastBar;                                   // Задаём переменную для времени открытия последнего бара
      datetime currBar;                                                  // Задаём переменную для времени открытия текущего бара
      currBar = iTime(Symbol(),PERIOD_M1,0);          // Находим время открытия текущего бара
      if(lastBar!=currBar)                                               // Если время открытия последнего бара не равно времени открытия текущего бара, то...
         {
            lastBar=currBar;
            return(true);
         }
      return(false);
   }

which also works properly. That's why my code is being picked on without grounds. And the question was generally correct. Apparently the tester is glitchy, so the readings are all wrong. On M5 it is somehow cleaner, on M15 also the H1 is already alike.

 
hoz:


Well, it's working the same as it did before... There's no change! I even have a new bar opening function:

which also works fine. That's why my code is being criticized without grounds. But the question was correct in general. Apparently the tester is glitchy and the readings are off. On M5 it is somehow clearer, and on M15 also H1 is already abysmal.


I would advise to write if(lastBar<currBar) right away, although it will hardly change anything. I'll go through your posts further, maybe I'll say something else.
 
hoz:


Well, it's working the same as it did before... There's no change! I even have a new bar opening function:

which also works fine. That's why my code is being criticized without grounds. But the question was correct in general. Apparently the tester is glitchy and the readings are off. On M5 it is somehow cleaner, on M15 also H1 is already abysmal.



It may help. Your start() function is a bit reworked. Didn't get into it deeply, but still:

int start()
{
   fastMa = iMA(NULL,i_TF,i_fastMaPeriod,0,MODE_EMA,MODE_CLOSE,1);
   slowMa = iMA(NULL,i_TF,i_slowMaPeriod,0,MODE_EMA,MODE_CLOSE,1);
   
 /*  Print("Bid = ", Bid);
   Print("Ask = ", Ask);
   Print("fastMa = ", fastMa);
   Print("i_thresholdFromMa * pt = ", i_thresholdFromMa * pt);
   */
// Отслеживание открытия нового бара
   static datetime lastBarTime = iTime(NULL, 0, 1));    // Время проведения последних рассчётов, изначально принимаем предыдущий бар
   
   if (lastBarTime < iTime(NULL, 0, 0))         // Если случился новый бар
 // Рассчёт сигнала 
    {
     if("На этом баре случилось что-то, что вынуждает ждать следуещего бара")
      {
       ..........// Выполняем действия открытия/закрытия или что-то там ещё...
       lastBarTime = iTime(NULL, 0, 0);              // На текущем баре все необходимые действия выполнены, ждём следуещего бара..
      }
     else
      {
       "Ничего не случилось, ждем до следуещего тика"
      }
    }
                                       // .. успешно выполнены
  return (0);
}
 
Sepulca:



It might help. Your start() function is a bit reworked. Didn't get into it deeply, but still:


Well here the calculation time is taken from the previous bar. It does not seem logical. We need the current bar.
 
PapaYozh:

Personally, I've never encountered a statik that didn't work.

Here is an example of an expert, if you want to check it on a graph:

1. Start the Expert Advisor.

2. Change the TF.

3. Make sure that cc does not become 20 again.

 
hoz:


Well, it's working the same as it did before... There's no change! I've even got a function to open a new bar:

which also works fine. That's why my code is being criticized without grounds. But the question was correct in general. Apparently the tester is glitchy and the readings are off. On M5 it is somehow cleaner, on M15 also H1 is already abysmal.

With respect to your situation:

The time was initialized once - when you start the EA, it will not be initialized again, so when you switch from M1 to D1 you will have to wait about a day for chart refresh :(

 
tara:

Applies to your situation:

The time was initialised once - when you start the EA, it will not be initialised again, so when you switch from M1 to D1 you will have to wait about a day for the chart to refresh :(



The Expert Advisor works on a specific TF. Why would I need to switch it?
 
tara:

3. Make sure that cc has not become 20 again.

This is a documented feature of EAs.
 
TheXpert:
This is a documented feature of EAs.


What's Static then? It's more of a Fatalic...


By the way, where is it documented?

 
hoz:

The Expert Advisor works on a specific TF. Why would I suddenly need to switch it?

You can simply change some parameter. The reaction will occur only after the first tick of a new bar on the set TF.

But you yourself have wondered why the EA is unexplainable on a higher TF:)

Reason: