O[shift ] = iOpen(symboll, timeFrame, shift);
On MT4: Unless the current chart is that specific symbol(s)/TF(s) referenced, you must handle 4066/4073 errors before accessing candle/indicator values.
Download history in MQL4 EA - MQL4 programming forum - Page 3 #26.4 (2019)
No MT4: A menos que o gráfico atual seja aquele(s) símbolo(s)/TF(s) específico(s) referenciado(s), você deve lidar com erros 4066/4073 antes de acessar os valores da vela/indicador. Histórico de downloads no MQL4 EA - Fórum de programação MQL4 - Página 3 #26.4 (20 19 )
Mt4 is full of defects...
Mt5 the prices don't match, you can get an mt4 and another mt5 account from the same broker, the values don't match...
We are lost, it seems purposeful to lose our money...
I'm trying to understand what you sent me, I'm learning English and using Google Translate, thank you for trying to help me.
On MT4: Unless the current chart is that specific symbol(s)/TF(s) referenced, you must handle 4066/4073 errors before accessing candle/indicator values.
Download history in MQL4 EA - MQL4 programming forum - Page 3 #26.4 (2019)
I'm learning, I hope it's what you explained in the link you sent, I'm learning to program, learning English, and trying to be a trader, it's not easy hahaha.
double O[4], H[4], L[4], C[4]; datetime T[4]; double askPrice, bidPrice, point = 0; // Tentar carregar os dados das velas for (int shift = 0; shift <= 3; shift++) { if (!LoadHistoricalData(symboll, timeFrame, shift)) { Print("Erro ao carregar dados históricos para ", symboll, " no timeframe ", timeFrame); return; // Se não for possível carregar os dados, saia da função } O[shift] = iOpen(symboll, timeFrame, shift); H[shift] = iHigh(symboll, timeFrame, shift); L[shift] = iLow(symboll, timeFrame, shift); C[shift] = iClose(symboll, timeFrame, shift); T[shift] = iTime(symboll, timeFrame, shift); } askPrice = MarketInfo(symboll, MODE_ASK); bidPrice = MarketInfo(symboll, MODE_BID); if (MarketInfo(symboll, MODE_DIGITS) == 3 || MarketInfo(symboll, MODE_DIGITS) == 5) { pipMultiplier = 10; } else { pipMultiplier = 1; } point = MarketInfo(symboll, MODE_POINT) * pipMultiplier; // Verificar padrão AN02 A if ((O[1] < C[1]) && (C[2] < O[2]) && (C[3] > O[3])) { //---------------------------------------------------------------------------------------------------- bool LoadHistoricalData(string symbol, int timeframe, int shift) { // Tentar carregar os dados históricos int tryCount = 0; while (tryCount < 10) { double openPrice = iOpen(symbol, timeframe, shift); if (openPrice != 0) { return true; // Dados carregados com sucesso } int error = GetLastError(); if (error == 4066 || error == 4073) { Sleep(500); // Esperar meio segundo antes de tentar novamente RefreshRates(); // Atualizar as taxas tryCount++; } else { Print("Erro ao acessar dados históricos: ", error); return false; // Outro erro, sair } } return false; // Não foi possível carregar os dados após várias tentativas }
Download history in MQL4 EA - MQL4 programming forum - Page 3 #26.4 (2019)
I tried to use this before doing the analyzes I need, but the platform is working, here's what I tried to do to get the correct data:
void ValidatePattern(string symboll, int timeFrame) { // Switch to the desired chart ChartSetSymbolPeriod(0, symboll, timeFrame); Sleep(1000); // Wait a while to ensure the graph is updated // Converting the time frame number to a readable string string timeFrameName; switch (timeFrame) { case 1: timeFrameName = "M1"; break; case 5: timeFrameName = "M5"; break; case 15: timeFrameName = "M15"; break; case 30: timeFrameName = "M30"; break; case 60: timeFrameName = "H1"; break; case 240: timeFrameName = "H4"; break; case 1440: timeFrameName = "D1"; break; case 10080:timeFrameName = "W1"; break; case 43200:timeFrameName = "MN"; break; default: timeFrameName = "Unknown"; break; } // Try to load candle data for (int shift = 1; shift <= 3; shift++) { if (!LoadHistoricalData(symboll, timeFrame, shift)) { Print("Error loading historical data for ", symboll, " in timeframe ", timeFrame); return; // If the data cannot be loaded, exit the function } O[shift] = iOpen(symboll, timeFrame, shift); H[shift] = iHigh(symboll, timeFrame, shift); L[shift] = iLow(symboll, timeFrame, shift); C[shift] = iClose(symboll, timeFrame, shift); T[shift] = iTime(symboll, timeFrame, shift); // Store candle opening time }
On MT4: Unless the current chart is that specific symbol(s)/TF(s) referenced, you must handle 4066/4073 errors before accessing candle/indicator values.
Download history in MQL4 EA - MQL4 programming forum - Page 3 #26.4 (2019)
I added the .mql4 code so that I could run it and check for errors when filling in the data for the O[0] candlestick. The first time it runs, it passes all the pairs correctly, but then the errors start, and it doesn't work in the strategy tester.
Thank you for your attention Roeder .
ChartSetSymbolPeriod(0, symboll, timeFrame); Sleep(1000); // Wait a while to ensure the graph is updated
Perhaps you should read the manual. That does nothing until you return.
How To Ask Questions The Smart Way. (2004)
How To Interpret Answers.
RTFM and STFW: How To Tell You've Seriously Screwed Up.
ChartSetSymbolPeriod - Chart Operations - MQL4 Reference

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Please consider which section is most appropriate — https://www.mql5.com/en/forum/172166/page6#comment_49114893
Moved to MT4.
I have a comparison specify (O[1] < C[1]) and I want that when opening the zero candle it makes the comparison and giving ok in the same opening, in the same candle that confirmed the desired pattern it executes the alert and the order , however, he is waiting for the ZERO candle that confirmed the pattern (O[1] < C[1]) to close and only after the opening of a new candle will he issue the alert and execute the order. I need help.