running sum cummulative sum

 
hello can someone assist me in telling me  how to do a running(cummulative) sum that refreshes after a certain time period ,,,, for example a daily running sum or monthly running sum
 
1432189:
hello can someone assist me in telling me  how to do a running(cummulative) sum that refreshes after a certain time period ,,,, for example a daily running sum or monthly running sum
Sum of what? Price? Please provide more context or share a code attempt so help can be provided. 
 
1432189:
hello can someone assist me in telling me  how to do a running(cummulative) sum that refreshes after a certain time period ,,,, for example a daily running sum or monthly running sum

A simple example which adds every 10 secs - you can change it as needed

//+------------------------------------------------------------------+
//|                                      458207-CummulativeAdder.mq5 |
//|                                  Copyright 2023, MetaQuotes Ltd. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2023, MetaQuotes Ltd."
#property link      "https://www.mql5.com"
#property version   "1.00"
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+

long     count = 0, cummSum = 0;
int      secsInterval = 10;
datetime nextUpdateTime = TimeCurrent() + secsInterval;

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void OnTick()
  {
   PrintFormat("   count = %d", count++);

   if(TimeCurrent() >= nextUpdateTime)
     {
      nextUpdateTime = TimeCurrent() + secsInterval;
      cummSum += count;
      PrintFormat("%s [Next update: %s] - count = %d cummSum = %d",
                  TimeToString(TimeCurrent(), TIME_DATE | TIME_SECONDS),
                  TimeToString(nextUpdateTime, TIME_DATE | TIME_SECONDS),
                  count, cummSum
                 );
     }

  }
//+------------------------------------------------------------------+
 
Navdeep Singh #:
Sum of what? Price? Please provide more context or share a code attempt so help can be provided. 
Navdeep Singh #:
Sum of what? Price? Please provide more context or share a code attempt so help can be provided. 
it adds indicator data but it refreshes after a specific time...take for example  a daily cumulative volume delta it adds its indicator data cumulatively  each day and refreshes after 24hrs ...something like that...the input of the data could be an indicator handle or an array with a set of data
 
1432189 #:
it adds indicator data but it refreshes after a specific time...take for example  a daily cumulative volume delta it adds its indicator data cumulatively  each day and refreshes after 24hrs ...something like that...the input of the data could be an indicator handle or an array with a set of data

Look for "VWAP" examples in the code base

MQL5 Code Base
MQL5 Code Base
  • www.mql5.com
MQL5 Source Code Library for MetaTrader 5