Can someone explain this to me? Code from Vladimir Karputov.

 
input ushort   InpSignalsFrequency  = 10;       // Search signals, in seconds (< "10" -> only on a new bar)           
datetime m_last_signal              = 0;        // "0" -> D'1970.01.01 00:00';

// search for trading signals no more than once every 10 seconds  
if(InpSignalsFrequency >= 10) { 
   datetime time_current = TimeCurrent();
   if(time_current - m_last_signal > InpSignalsFrequency)
      ClosePartial();
}

it's like TimeCurrent - 0 > 10, In this case, this condition is always true, so what am I missing?


thank you in advance for your insights 
Best Reguards,
ZeroCafeine.

Vladimir Karputov
Vladimir Karputov
  • 2023.11.22
  • www.mql5.com
Профиль трейдера
 

Please link the source of the original full code or provide all relevant code.

I suspect those lines alone do not convey the full functionality that would be necessary to explain it's logic.

There is probably a line somewhere in the original code that is possibly something like the following ...

m_last_signal=time_current;

Also, if this is from a CodeBase publication, then you should have posted on that publication's Discussion Topic instead.

 

tks you 


I edited the text several times because it wasn't presentable and I made a typing error., that is the link, As you can see I've also tried to chat on this page but I can't find the full editor to type my message correctly ? like on this photo : 
code

I haven't found a complete message editor like the photo : 



Position Close Partial
Position Close Partial
  • www.mql5.com
Советник - утилита: производится частичное закрытие позиций по текущему символу
 
ZeroCafeine #: As you can see I've also tried to chat on this page but I can't find the full editor to type my message correctly ? like on this photo : I haven't found a complete message editor like the photo :

You have to click on " Перейти к обсуждению на форуме трейдеров " which translates into " Go to discussion on the traders forum " in English.

Click on it and it takes you to the discussion thread and then you can post there as normally on the forum.

Also, given that it is on the Russian forum you should post in Russian by using the auto-translation tool.

ZeroCafeine #: I edited the text several times because it wasn't presentable and I made a typing error., that is the link,

In terms of your original question, it seems that the code has a bug or he used code remnants from another project and forgot to clean it up.

The reason I say this is because in searching the forum I found this code sample from another user's work which uses similar variable names and code ...

   if(InpSignalsFrequency>=10) // search for trading signals no more than once every 10 seconds
     {
      datetime time_current=TimeCurrent();
      if(time_current-m_last_signal>InpSignalsFrequency)
        {
         //--- search for trading signals
         if(!RefreshRates())
           {
            m_prev_bars=0;
            return;
           }
         if(!SearchTradingSignals())
           {
            m_prev_bars=0;
            return;
           }
         m_last_signal=time_current;
        }
     }
 
Fernando Carreiro #:

You have to click on " Перейти к обсуждению на форуме трейдеров " which translates into " Go to discussion on the traders forum " in English.

Click on it and it takes you to the discussion thread and then you can post there as normally on the forum.

Also, given that it is on the Russian forum you should post in Russian by using the auto-translation tool.

In terms of your original question, it seems that the code has a bug or he used code remnants from another project and forgot to clean it up.

The reason I say this is because in searching the forum I found this code sample from another user's work which uses similar variable names and code ...

Thank you again for your reply.😊

It's much more logical, I'll settle for your answer, which is more than enough for me with my low level, and I'll take a look at the code with the links you sent me. 😉

Reason: