35 lines
1.3 KiB
MQL5
//+------------------------------------------------------------------+
| |||
//| vol.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"; // Financial instrument for testing
| |||
input datetime from_t = D'2024.09.20'; // Evaluation interval start date
| |||
input datetime to_t = D'2026.09.20'; // Evaluation interval end date
| |||
//---
| |||
#include "ADF.mqh" // Statistical test core framework
| |||
//---
| |||
void OnStart()
| |||
{
| |||
//--- Getting historical data
| |||
MqlRates rates[];
| |||
int n_rates = CopyRates(symbol, PERIOD_D1, from_t, to_t, rates);
| |||
PrintFormat("History for %s. Total bars: %d", symbol, n_rates);
| |||
if(n_rates < 2)
| |||
return;
| |||
| |||
//--- Target vector (y) construction
| |||
ulong n=(ulong)n_rates;
| |||
vector y(n);
| |||
for(ulong i=0;i<n;++i)
| |||
y[i]=MathLog(rates[i].high/rates[i].low);
| |||
| |||
//--- Single ADF-test
| |||
ADF_Test(y,ADF_TYPE_DRIFT);
| |||
}
| |||
//+------------------------------------------------------------------+
|