Hi all, I'm trying to copy only 2 years of history to my indicator buffer (I want to conduct some study on the 2 years of history of values)
My problem is that when I run below code and check size of copied array it returns over 100'000 of 1 hour bars which is probably almost entire available history. Do I need to copy it manually to another array if I only want to have 2 years of data to analyse?
inputdatetime inpFrom = D'2020.01.01';
inputdatetime inpTo = D'2022.05.18';
intOnInit()
{
SetIndexBuffer(0, BufEMA, INDICATOR_DATA);
ArraySetAsSeries(BufEMA, true);
HandleEMA = iCustom( _Symbol, PERIOD_CURRENT, "MyIndicators\\EMA_S\\EMA_S.ex5" );
if( HandleEMA == INVALID_HANDLE ) {
PrintFormat( "Failed to create HandleEMA for the symbol %s/%s, error code %d",
_Symbol,
EnumToString( PERIOD_CURRENT ),
GetLastError() );
return ( INIT_FAILED );
}
return(INIT_SUCCEEDED);
}
intOnCalculate(constint rates_total,
constint prev_calculated,
constint begin,
constdouble &price[])
{
ResetLastError();
if( CopyBuffer( HandleEMA, 0, inpTo, inpFrom, BufEMA) <= 0) {
PrintFormat( "1.Failed to copy data from the EMA S indicator, error code %d", GetLastError() );
return ( 0 );
}
Print( ArraySize( BufEMA)); // on EURSD 1H chart console says: 100403
return (prev_calculated);
}
I'm trying to use this function (by the way I don't think they made it clear what is the start and end date - which should be earliest and which latest - so I tried both ways with the same result).
intCopyBuffer(
int indicator_handle, // indicator handle int buffer_num, // indicator buffer number datetime start_time, // start date and time datetime stop_time, // end date and time double buffer[] // target array to copy
);
This article is about traditional and unusual algorithms of averaging packed in simplest and single-type classes. They are intended for universal usage in almost all developments of indicators. I hope that the suggested classes will be a good alternative to 'bulky' calls of custom and technical indicators.
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
Hi all, I'm trying to copy only 2 years of history to my indicator buffer (I want to conduct some study on the 2 years of history of values)
My problem is that when I run below code and check size of copied array it returns over 100'000 of 1 hour bars which is probably almost entire available history. Do I need to copy it manually to another array if I only want to have 2 years of data to analyse?
I'm trying to use this function (by the way I don't think they made it clear what is the start and end date - which should be earliest and which latest - so I tried both ways with the same result).