ICTLibraryExamples/Benchmark/OtherCode/Code2.mq5
174 lines
12 KiB
MQL5
Nique_372
2026-01-14 07:05:58 -05:00
<EFBFBD><EFBFBD>//+------------------------------------------------------------------+
//| Fair Value Gap Indicator |
//| Copyright 2024, Hieu Hoang |
//+------------------------------------------------------------------+
#property copyright "Copyright 2024, hieuhoangcntt@gmail.com"
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
#include "..\\Utils\\MetricSaver.mqh"
// https://www.mql5.com/en/code/51977 (convertido a EA)
double _low, _high;
string object_names[];
datetime pre_time = 0;
const int bull = 5;
const int bear = 5;
int c_bull;
int c_bear;
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
bool isGreenCandle(double open, double close)
{
return open < close;
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
bool isRedCandle(double open, double close)
{
return !isGreenCandle(open, close);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
bool isBullFVG(int index,
const double &open[],
const double &high[],
const double &low[],
const double &close[])
{
if(isGreenCandle(open[index-1], close[index-1]) &&
high[index-2] < low[index] && high[index-2] < _low
)
return true;
return false;
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
bool isBearFVG(int index,
const double &open[],
const double &high[],
const double &low[],
const double &close[])
{
if(isRedCandle(open[index-1], close[index-1]) &&
low[index-2] > high[index] && low[index-2] > _high
)
return true;
return false;
}
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
CMetricsSave::Start(FILE_CODE2);
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void create_object(string name, color clrColor, const datetime time1, const datetime time2, const double low, const double high)
{
ArrayResize(object_names, ArraySize(object_names) + 1);
object_names[ArraySize(object_names) - 1] = name;