40 lines
1.5 KiB
MQL5
40 lines
1.5 KiB
MQL5
//+------------------------------------------------------------------+
|
|
//| vol1.mq5 |
|
|
//| Copyright 2000-2026, MetaQuotes Ltd. |
|
|
//| www.mql5.com |
|
|
//+------------------------------------------------------------------+
|
|
#property copyright "Copyright 2000-2026, MetaQuotes Ltd."
|
|
#property link "https://www.mql5.com"
|
|
//---
|
|
#property script_show_inputs
|
|
//---
|
|
input string symbol = "EURCHF"; // Market symbol for analysis
|
|
input datetime from_t = D'2024.09.20'; // Start of analysis time interval
|
|
input datetime to_t = D'2026.09.20'; // End of analysis time interval
|
|
input ulong pmax = 5; // Maximal p for fitting
|
|
input ulong qmax = 5; // Maximal q for fitting
|
|
//---
|
|
#include "EconometricsM.mqh"
|
|
//---
|
|
void OnStart()
|
|
{
|
|
//--- quotes downloading
|
|
MqlRates rates[];
|
|
int n_rates = CopyRates(symbol, PERIOD_D1, from_t, to_t, rates);
|
|
PrintFormat("Number of downloaded quotes for market symbol %s: %d", symbol, n_rates);
|
|
if(n_rates < 2)
|
|
return;
|
|
//--- y calculation
|
|
ulong n=(ulong)n_rates;
|
|
vector y(n);
|
|
for(ulong i=0;i<n;++i)
|
|
y[i]=MathLog(rates[i].high/rates[i].low);
|
|
//--- p and q fitting
|
|
//--- Visual check
|
|
acf_plot(y,pmax+qmax);
|
|
pacf_plot(y,pmax+qmax);
|
|
//--- Automatic fitting
|
|
ARMA(y,pmax,qmax);
|
|
ARMA(y,pmax,qmax,false);
|
|
}
|
|
//+------------------------------------------------------------------+
|