MetaTrader 5 Platform Update Build 5320: Services in CodeBase and improved input operations in MQL5 - page 2

 
And I thought that oncalculate was called every tick
but apparently, some passages are made without a new tick

 //+------------------------------------------------------------------+
 //|                                                     New Tick.mq5 |
 //|                                       Copyright 2025, William210 |
 //|                         https://www.mql5.com/fr/users/william210 |
 //+------------------------------------------------------------------+
 #property copyright "Copyright 2025, William210"
 #property link        "https://www.mql5.com/fr/users/william210"
 #property version    "1.00"
 #property indicator_chart_window
 //+------------------------------------------------------------------+
 //| Custom indicator initialization function                         |
 //+------------------------------------------------------------------+
 int OnInit ()
  {
 //--- indicator buffers mapping 
   
//--- 
   return ( INIT_SUCCEEDED );
  }
 //+------------------------------------------------------------------+
 //| Custom indicator iteration function                              |
 //+------------------------------------------------------------------+
 int OnCalculate ( const int rates_total,
                 const int prev_calculated,
                 const datetime &time[],
                 const double &open[],
                 const double &high[],
                 const double &low[],
                 const double &close[],
                 const long &tick_volume[],
                 const long &volume[],
                 const int &spread[]) {

   static long Last_Tick_Volume = - 1 ;
   static int   Call_Counter = 0 ;

   long Current_Tick_Volume = tick_volume[ rates_total - 1 ];

   // Test: tick unchanged but OnCalculate called 
   if ( Current_Tick_Volume == Last_Tick_Volume ) {
    Call_Counter ++;
     Print ( "Passage without new tick: call #" , Call_Counter,
           " | Time = " , TimeToString ( time[ rates_total - 1 ], TIME_DATE | TIME_MINUTES ),
           " | TickVolume = " , Current_Tick_Volume );
  } else {
    Call_Counter = 0 ;
    Last_Tick_Volume = Current_Tick_Volume;
     printf ( "New tick detected | TickVolume =" , Current_Tick_Volume );
  }

   return ( rates_total );
}
 //+------------------------------------------------------------------+
 
Gerard William G J B M Dinh Sy #:
And I thought that oncalculate was called every tick
but apparently, some passages are made without a new tick

Nope.

Please see this thread for all details on ticks and OnCalculate:


 

Dear MetaTrader team,

would you please add Adding alarm(s) via context menu?

E.g.: Mouse pointer on 65.480. Context menu shows "Alarm for 65.480" with available sub menu with four items: Bid >, Bid <, Ask >, Ask<.


Thank you very much for your attention!!

 
Stefan P. #:


like this?


 

Detached charts still do not remember toolbar setting. If you disable toolbar, it will come back upon terminal restart. This has been the case since dark mode was added


 
Michael Charles Schefe #:

like this?


Thank you very much! I didn´t knew that (I use a Trade Pad for Pending/Market Orders).