//+------------------------------------------------------------------+
#include <Graphics\Graphic.mqh>
//+------------------------------------------------------------------+
input datetime t_rates = D'2026.03.20 00:00';
input int n_rates = 200;
input ENUM_TIMEFRAMES tf_rates = PERIOD_D1;
//+------------------------------------------------------------------+
void OnStart()
{ // download quotes
  MqlRates rates[];
  int nres = CopyRates(Symbol(), tf_rates, t_rates, n_rates, rates);
  if (nres < n_rates)
  { Print("Insufficient quotes");
    return;
  }
// find log returns and divide them into two parts
  double lr0[], lr1[];
  int nr = n_rates / 2;
  ArrayResize(lr0, nr);
  ArrayResize(lr1, nr);
  for (int i = 0; i < nr; ++i)
  { lr0[i] = MathLog(rates[2 * i].close / rates[2 * i].open);
    lr1[i] = MathLog(rates[2 * i + 1].close / rates[2 * i + 1].open);
  }
// Scatter plot
  ChartSetInteger(0, CHART_SHOW, false);
  CGraphic graphic;
  graphic.Create(0, "G", 0, 0, 0, 750, 400);
  graphic.CurveAdd(lr0, lr1, CURVE_POINTS, "scatter plot");
  graphic.CurvePlotAll();
  graphic.Update();
  MessageBox("Press OK to close Scatter plot", "Close graph");
  ChartSetInteger(0, CHART_SHOW, true);
  graphic.Destroy();
}
//+------------------------------------------------------------------+
