2. What value is contained in this array under the index, e.g. 19?
I think it's easier to do this, I wrote the function as a separate expert, you can run it and see for yourself.
If you have time and desire help. (The error is the same).
Duplicate code:
int m_handle = 0;
int m_count_symbols = 0;
string m_name_symbols[1000];
string m_strategy_symbol;
int m_period;
double m_valuesa[];
voidOnInit()
{
ENUM_TIMEFRAMES PERIOD_INDEX [22] = {PERIOD_CURRENT,
PERIOD_M1, PERIOD_M2,PERIOD_M3,PERIOD_M4,PERIOD_M5,PERIOD_M6,PERIOD_M10,PERIOD_M12,PERIOD_M15,PERIOD_M20,
PERIOD_M30,PERIOD_H1,PERIOD_H2,PERIOD_H3,PERIOD_H4,PERIOD_H6,PERIOD_H8, PERIOD_H12,PERIOD_D1, PERIOD_W1,
PERIOD_MN1};
m_count_symbols = 1;
m_name_symbols[0] = _Symbol;
// Проверка всех вариантов в циклахfor(int isymb=1; isymb<=m_count_symbols; isymb++)
{
for(int iperiod=5; iperiod<=19; iperiod++)
{
for(int iperiodma=1; iperiodma<=100; iperiodma++)
{
// Выбор символа (m_strategy_symbol) из масива используемых символов (m_name_symbols[]) количаством (m_count_symbols)
m_strategy_symbol = m_name_symbols[isymb];
// Выбор периода из масива по индексу (от PERIOD_M5 (индекс - 5) до PERIOD_D1 (индекс - 19))
m_period = PERIOD_INDEX[iperiod];
// Освобождаю дескриптор загруженого ранее индикатораIndicatorRelease(m_handle);
// Создаю новый индикатор с периодом - (int)(MathRound(Colony[3][chromos]*100)+1) = от 1 до 100
m_handle=iMA(m_strategy_symbol,(ENUM_TIMEFRAMES)m_period,iperiodma,0,MODE_EMA,PRICE_CLOSE);
// Без использования Sleep(1000); - генерируется последующа ошибка при использовании в коде ф-ции: CopyBuffer// "ошибка доступа к историческим даным", хоть дескриптор и создан!?!?!?Sleep(1000);
if(m_handle<0)
{
Alert("Ошибка при создании индикатора MA - номер ошибки: ",GetLastError()," ",m_strategy_symbol," ",m_period);
} else
{
// Аналитический процес// В место процесса, обычныое чтение даных индикатораCopyBuffer(m_handle,0,0,1,m_valuesa);
ArraySetAsSeries(m_valuesa,true);
}
}
}
}
}
File is attached. Parameters of the tester (just in case)
to solve this error, I will uncommentSleep(1000); it will disappear and data from the buffer will be copied normally.
question: why? is it possible to do withoutSleep(1000), to avoid additional time wasting?
int m_handle = 0;
int m_count_symbols = 0;
string m_name_symbols[1000];
string m_strategy_symbol;
int m_period;
double m_valuesa[];
MqlRates m_rates[];
voidOnInit()
{
ENUM_TIMEFRAMES PERIOD_INDEX [22] = {PERIOD_CURRENT,
PERIOD_M1, PERIOD_M2,PERIOD_M3,PERIOD_M4,PERIOD_M5,PERIOD_M6,PERIOD_M10,PERIOD_M12,PERIOD_M15,PERIOD_M20,
PERIOD_M30,PERIOD_H1,PERIOD_H2,PERIOD_H3,PERIOD_H4,PERIOD_H6,PERIOD_H8, PERIOD_H12,PERIOD_D1, PERIOD_W1,
PERIOD_MN1};
m_count_symbols = 1;
m_name_symbols[0] = _Symbol;
// Проверка всех вариантов в циклахfor(int isymb=1; isymb<=m_count_symbols; isymb++)
{
for(int iperiod=5; iperiod<=19; iperiod++)
{
for(int iperiodma=1; iperiodma<=100; iperiodma++)
{
// Выбор символа (m_strategy_symbol) из масива используемых символов (m_name_symbols[]) количаством (m_count_symbols)
m_strategy_symbol = m_name_symbols[isymb];
// Выбор периода из масива по индексу (от PERIOD_M5 (индекс - 5) до PERIOD_D1 (индекс - 19))
m_period = PERIOD_INDEX[iperiod];
// Освобождаю дескриптор загруженого ранее индикатораIndicatorRelease(m_handle);
// Создаю новый индикатор с периодом - (int)(MathRound(Colony[3][chromos]*100)+1) = от 1 до 100
m_handle=iMA(m_strategy_symbol,(ENUM_TIMEFRAMES)m_period,iperiodma,0,MODE_EMA,PRICE_CLOSE);
// Без использования Sleep(1000); - генерируется последующа ошибка при использовании в коде ф-ции: CopyBuffer// "ошибка доступа к историческим даным", хоть дескриптор и создан!?!?!?//Sleep(1000);if(m_handle<0)
{
Alert("Ошибка при создании индикатора MA - номер ошибки: ",GetLastError()," ",m_strategy_symbol," ",m_period);
} else
{
// Аналитический процес// В место процесса, обычныое чтение даных индикатораdouble p_close;
if (CopyRates(m_strategy_symbol,(ENUM_TIMEFRAMES)m_period,0,1,m_rates) < 0)
{
Alert("Ошибка CopyRates - номер ошибки: ",GetLastError());
}
p_close=m_rates[0].close; // цена закрытия предыдущего бара if (CopyBuffer(m_handle,0,0,1,m_valuesa) < 0)
{
Alert("Ошибка CopyBuffer - номер ошибки: ",GetLastError());
}
ArraySetAsSeries(m_valuesa,true);
bool buy_condition_1=(p_close>m_valuesa[0]);
bool sell_condition_1=(p_close<m_valuesa[0]);
}
}
}
}
}
A bit of trivia. On the left side of the line you have
m_period = PERIOD_INDEX[iperiod];
there is a variable of the int type on the left and a value of the ENUM_TIMEFRAMES type on the right. Why don't you declare 'ENUM_TIMEFRAMES m_period;' right in the fifth line?
2. You have a triple nested loop where one and the same indicator is called in a rather short time. Only for one symbol about 1400 calls occur. Used indicators just don't have time to free memory. Search the forum threads about the IndicatorRelease() function. It was once said that the use of this function in code is already an error.
A quick change of indicators in the code also explains the appearance of error 4806. The new indicator simply has no time to load the required data.
I have changed the code taking into account your comments:
(corrected m_period = PERIOD_INDEX[iperiod];, error is not significant in this case - but thanks, I fixed it)
int m_handle = 0;
int m_count_symbols = 0;
string m_name_symbols[1000];
string m_strategy_symbol;
ENUM_TIMEFRAMES m_period;
double m_valuesa[];
MqlRates m_rates[];
voidOnInit()
{
ENUM_TIMEFRAMES PERIOD_INDEX [22] = {PERIOD_CURRENT,
PERIOD_M1, PERIOD_M2,PERIOD_M3,PERIOD_M4,PERIOD_M5,PERIOD_M6,PERIOD_M10,PERIOD_M12,PERIOD_M15,PERIOD_M20,
PERIOD_M30,PERIOD_H1,PERIOD_H2,PERIOD_H3,PERIOD_H4,PERIOD_H6,PERIOD_H8, PERIOD_H12,PERIOD_D1, PERIOD_W1,
PERIOD_MN1};
m_count_symbols = 1;
m_name_symbols[0] = _Symbol;
// Проверка всех вариантов в циклахfor(int isymb=1; isymb<=m_count_symbols; isymb++)
{
for(int iperiod=5; iperiod<=19; iperiod++)
{
for(int iperiodma=1; iperiodma<=100; iperiodma++)
{
// Выбор символа по индексу isymb
m_strategy_symbol = m_name_symbols[isymb];
// Выбор периода из масива по индексу iperiod
m_period = PERIOD_INDEX[iperiod];
// Освобождаю дескриптор загруженого ранее индикатораIndicatorRelease(m_handle);
// Создаю новый индикатор с периодом - iperiodma
m_handle=iMA(m_strategy_symbol,m_period,iperiodma,0,MODE_EMA,PRICE_CLOSE);
// Задержка, для того чтобы индикатор успел создатся, иначе ошибка 4806 при последующем использовании CopyBuffer Sleep(1000);
if(m_handle<0)
{
Alert("Ошибка при создании индикатора MA - номер ошибки: ",GetLastError()," ",m_strategy_symbol," ",m_period);
} else
{
// Аналитический процес// В место процесса, обычныое чтение даных индикатораdouble p_close;
if (CopyRates(m_strategy_symbol,m_period,0,1,m_rates) < 0)
{
Alert("Ошибка CopyRates - номер ошибки: ",GetLastError());
}
p_close=m_rates[0].close; // цена закрытия предыдущего бара if (CopyBuffer(m_handle,0,0,1,m_valuesa) < 0)
{
Alert("Ошибка CopyBuffer - номер ошибки: ",GetLastError());
}
ArraySetAsSeries(m_valuesa,true);
bool buy_condition_1=(p_close>m_valuesa[0]);
bool sell_condition_1=(p_close<m_valuesa[0]);
}
}
}
}
}
issue with error (Error CopyBuffer - error number: 4806) - removed, I cured it by Sleep(1000); - I put it down to not having enough time to create indicator.
The issue with the error (4194304 bytes not available) remains.
The remark about IndicatorRelease() - taken into account in the processing.
I understood that I used the new description - the old ones
are not in the description, but are still highlighted by the editorWhen using this function there is an error "2012.11.28 09:58:32 4194304 bytes not available", help to understand, increased swap file to 10GBt.
Yedelkin:
А лог-файл случайно алёртами не забивается?
Checked it, the log is 10 kBt, there have been more,
MemoryException 09:36:12 4194304 bytes not available" error, it repeats often.
Noticed (by previous code):
// Selection of period from array by index (from PERIOD_M5 (index - 5) to PERIOD_D1 (index - 19))
If less periods (e.g. PERIOD_M5 to PERIOD_M6) are taken for the enumeration, no error will occur.
// Selection of a period from an array by index (from PERIOD_M5 (index - 5) to PERIOD_D1 (index - 19))
1. which type of array are we talking about?
2. What value is contained in this array under index - e.g. 19?
1. what type of array are we talking about?
2. What value is contained in this array under the index, e.g. 19?
I think it's easier to do this, I wrote the function as a separate expert, you can run it and see for yourself.
If you have time and desire help. (The error is the same).
Duplicate code:
File is attached. Parameters of the tester (just in case)
EURUSD.e
H1
OHLC
2012.1.1 - 2012.4.1
Updating a question, I am interested in two errors:
1. 2012.11.28 11:45:18 4194304 bytes not available
I can't solve them yet, but if instead of enumerating periods m_period = PERIOD_INDEX[iperiod], set for examplePERIOD_H1, there will be no error,
but I need all periods.
2. 2012.11.28 11:45:49 2012.01.01 00:00:00 Alert: Error CopyBuffer - error number: 4806
to solve this error, I will uncommentSleep(1000); it will disappear and data from the buffer will be copied normally.
question: why? is it possible to do withoutSleep(1000), to avoid additional time wasting?
Unfortunately, I don't have a tester handy.
A bit of trivia. On the left side of the line you have
there is a variable of the int type on the left and a value of the ENUM_TIMEFRAMES type on the right. Why don't you declare 'ENUM_TIMEFRAMES m_period;' right in the fifth line?
2. You have a triple nested loop where one and the same indicator is called in a rather short time. Only for one symbol about 1400 calls occur. Used indicators just don't have time to free memory. Search the forum threads about the IndicatorRelease() function. It was once said that the use of this function in code is already an error.
A quick change of indicators in the code also explains the appearance of error 4806. The new indicator simply has no time to load the required data.
Can you tell me how to get rid of Abnormal termination?
The EA stops working and this can only be seen in the log, it is green on the chart.
I have changed the code taking into account your comments:
(corrected m_period = PERIOD_INDEX[iperiod];, error is not significant in this case - but thanks, I fixed it)
issue with error (Error CopyBuffer - error number: 4806) - removed, I cured it by Sleep(1000); - I put it down to not having enough time to create indicator.
The issue with the error (4194304 bytes not available) remains.
The remark about IndicatorRelease() - taken into account in the processing.
If anyone have thoughts, please share, thank you.