MQL5/3_MQL5_EA_Tools/011_Event_R2.mq5

55 lines
1.4 KiB
MQL5
Raw Permalink Normal View History

2025-03-13 11:57:31 -04:00
//+------------------------------------------------------------------+
//| 011_Event_R2.mq5 |
2025-04-16 11:59:03 -04:00
//| Author: Santiago Cruz |
2025-03-13 11:57:31 -04:00
//| https://www.mql5.com/en/users/algo-trader/ |
//+------------------------------------------------------------------+
2025-04-16 11:59:03 -04:00
#property copyright "Santiago Cruz"
2025-03-13 11:57:31 -04:00
#property link "https://www.mql5.com/en/users/algo-trader/"
#property version "1.00"
#include <Trade/Trade.mqh>
int OnInit()
2025-03-17 22:46:51 -04:00
{
currenciesCount = 0;
ArrayResize(currencies, 0);
2025-03-15 21:02:44 -04:00
2025-03-17 22:46:51 -04:00
if(!StartUp(true)) return INIT_PARAMETERS_INCORRECT;
const bool barwise = UnityPriceType == PRICE_CLOSE && UnityPricePeriod == 1;
controller = new UnityController(UnitySymbols, barwise,
UnityBarLimit, UnityPriceType, UnityPriceMethod, UnityPricePeriod);
// waiting for messages from the indicator on currencies in buffers
return INIT_SUCCEEDED;
}
2025-03-16 18:08:03 -04:00
bool isNewTime() const
{
return lastRead != lastTime();
}
bool getOuterIndices(int &min, int &max)
{
if(isNewTime())
{
if(!read()) return false;
}
max = ArrayMaximum(data);
min = ArrayMinimum(data);
return true;
}
double operator[](const int buffer)
{
if(isNewTime())
{
if(!read())
{
return EMPTY_VALUE;
}
}
return data[buffer];
}
2025-03-17 22:46:51 -04:00
};