Watch
1
0
Fork
You've already forked NeuroBook
0
forked from rosh/NeuroBook
NeuroBook/Scripts/initial_data/initial_data_rsi_pow.mq5

117 lines
9.9 KiB
MQL5

2025-05-30 16:12:30 +02:00
<EFBFBD><EFBFBD>//+------------------------------------------------------------------+
//| Initial_Data_RSI_Pow.mq5 |
//| Copyright 2021, MetaQuotes Ltd. |
//| https://www.mql5.com/en/users/dng |
//+------------------------------------------------------------------+
//| Script for calculating Pearson correlation coefficient between |
//| and a series of power values of the RSI indicator |
//+------------------------------------------------------------------+
#property copyright "Copyright 2021, MetaQuotes Ltd."
#property link "https://www.mql5.com/en/users/dng"
#property version "1.00"
//+------------------------------------------------------------------+
//| Connect libraries |
//+------------------------------------------------------------------+
#include <Math\Stat\Math.mqh>
//+------------------------------------------------------------------+
//| External parameters |
//+------------------------------------------------------------------+
input datetime Start = D'2015.01.01 00:00:00'; // Period beginning
input datetime End = D'2020.12.31 23:59:00'; // Period end
//+------------------------------------------------------------------+
//| Script program |
//+------------------------------------------------------------------+
void OnStart(void)
{
//--- Connect indicators
int h_ZZ = iCustom(_Symbol, PERIOD_M5, "Examples\\ZigZag.ex5", 48, 1, 47);
int h_RSI = iRSI(_Symbol, PERIOD_M5, 12, PRICE_TYPICAL);
double close[];
if(CopyClose(_Symbol, PERIOD_M5, Start, End, close) <= 0)
return;
//--- Loading indicator data
double zz[], rsi[];
datetime end_zz = End + PeriodSeconds(PERIOD_M5) * (12 * 24 * 5);
if(CopyBuffer(h_ZZ, 0, Start, end_zz, zz) <= 0 ||
CopyBuffer(h_RSI, 0, Start, End, rsi) <= 0)
{
return;
}
int total = ArraySize(close);
double rsi_pow[];
double target1[], target2[];
if(ArrayResize(target1, total) <= 0 || ArrayResize(target2, total) <= 0 || ArrayResize(rsi_pow, total*15) <= 0)
{
return;
}
//--- Prepare data
double extremum = -1;
double min=DBL_MAX;
for(int i = ArraySize(zz) - 2; i > 0; i--)
{
if(zz[i + 1] > 0 && zz[i + 1] != EMPTY_VALUE)
extremum = zz[i + 1];
if(i >= total)
continue;
target2[i] = extremum - close[i];
target1[i] = (target2[i] >= 0);
for(int p = 0; p < 15; p++)
{