Code cumulative returns

 

   I want to create a robot that calculates the daily returns of a specific day.

I´m stucked with cumulative part.

//+------------------------------------------------------------------+
//|                                                 PruebaTiempo.mq5 |
//|                                  Copyright 2022, MetaQuotes Ltd. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2022, MetaQuotes Ltd."
#property link      "https://www.mql5.com"
#property version   "1.00"

//+------------------------------------------------------------------+
//|LISTADO DE ENUMS
//+------------------------------------------------------------------+
enum MENU
{
   LUNES = 1,
   MARTES = 2,
   MIERCOLES = 3,
   JUEVES = 4,
   VIERNES = 5,   
};

double PrecioApertura;
double PrecioCierre;

//+------------------------------------------------------------------+
//|DECLARACIÓN DE VARIABLES INPUT
//+------------------------------------------------------------------+
input MENU Opcion = LUNES;                      //Día que se quiere operar:
input int HoraApertura = 0;                     //Hora de apertura:
input int MinutoApertura = 00;                   //Minuto de apertura:
input int SegundosApertura = 00;                 //Segundos de apertura:
input int HoraCierre = 23;                      //Hora de cierre:
input int MinutoCierre = 00;                     //Minuto de cierre:
input int SegundosCierre = 00;                   //Segundos de cierre:
bool EjecutadaUnaVez;

//+------------------------------------------------------------------+
//|MANEJADOR DE EVENTO OnTick
//+------------------------------------------------------------------+
void OnTick()
{   
   MqlDateTime tiempo;
   TimeLocal(tiempo);

   //----Apertura
   if(tiempo.day_of_week == Opcion && tiempo.hour == HoraApertura && tiempo.min == MinutoApertura && tiempo.sec == SegundosApertura)
   {
      PrecioApertura = SymbolInfoDouble(_Symbol,SYMBOL_ASK);
      Print("El precio de apertura es: " + (string)PrecioApertura);
   }
   
   //----Cierre
   if(tiempo.day_of_week == Opcion && tiempo.hour == HoraCierre && tiempo.min == MinutoCierre && tiempo.sec == SegundosCierre)
   {
      PrecioCierre = SymbolInfoDouble(_Symbol,SYMBOL_ASK);
      Print("El precio de cierre es: " + (string)PrecioCierre);
      
      
      //----Resultado diario
      double Resultado = ((PrecioCierre - PrecioApertura) / PrecioApertura) * 100;
      Print("El resultado es: " + (string)Resultado); 
   }
}
//+------------------------------------------------------------------+

Thanks.