Questions from Beginners MQL5 MT5 MetaTrader 5 - page 143

 
barabashkakvn:
I agree about the int(round). Thank you. An explicit type conversion wouldn't hurt. Although it worked without explicit type conversion.
Документация по MQL5: Основы языка / Типы данных / Приведение типов
Документация по MQL5: Основы языка / Типы данных / Приведение типов
  • www.mql5.com
Основы языка / Типы данных / Приведение типов - Документация по MQL5
 
Virty:
I agree about the int(round). Thank you. An explicit type conversion wouldn't hurt. But it worked well without explicit type conversion.
It worked, but the compiler's remarks... They are annoying.
 
barabashkakvn:

I don't have any errors. The build is the latest.

Thank you, MT5 update helped. The error is gone. the build was of 23 July 2013. in the old build, by the way, there were no type conversion warrants, that's why i didn't notice them.

Who would have expected such serious errors from the compiler.

Документация по MQL5: Основы языка / Типы данных / Приведение типов
Документация по MQL5: Основы языка / Типы данных / Приведение типов
  • www.mql5.com
Основы языка / Типы данных / Приведение типов - Документация по MQL5
 
Virty:

Thank you, MT5 update helped. The bug is gone. The build was of 23 July 2013. In the old build, by the way, there were no type conversion warrants, so I didn't notice them.

Who would have expected such serious errors from the compiler.

The main thing is that it worked :).
 

Need to find the minimum in the time interval. I have made the following code to find the minimum in the time interval:

datetime ts=st+StartTime*60;// начало временного диапазона в секундах от 01.01.1970
int tss=(int)ts;//преобразование в секунды
Alert( "tss",tss);
datetime tsp=st+StopTime*60;// конец временного диапазона в секундах от 01.01.1970
int tspp=(int)tsp;//преобразование в секунды

To find minima in this interval I use the function CopyLow:

double Low[];
CopyLow(_Symbol,_Period,tss,tspp,Low); 

Then, if I understand correctly, I get a one-dimensional arrayLow[],

I'm looking for the minimum in it with ArrayMinimum:

int start=0;
int count=WHOLE_ARRAY; 
double min=ArrayMinimum(Low,tss, tspp);  
Alert("min=",min);

I tried to set today a start time of 1 hour, a stop time of 2 hours and call Alert to check min=-1.

Question: for this problem, are the functions chosen correctly to solve this problem, or is there an error somewhere? I need to get the minimum price.

 
Hello. Dear traders, Please help me with the correct design of the program piece for 3 slides in a multi-currency EA.

I tried to look it up in the Handbook, but it's a class-based example, and I'm not ready for that yet.

I want to write an EA without using classes. I have excluded all extraneous things from consideration and for getting 3 slips for each

I have written the following program fragment:

input int Kurtz_Period=5; // fast-moving Kurtz period

input int Mittel_Period=8 ;

input int Long_Period=13;

int maHandle; //handle of Moving Average indicator

double ma_buf[]; // this is a buffer array for the moving average readings from the MA function

// and then it will be copied into the corresponding arrays

datetime Time_buf[]; // this is an array of bar open time

datetime Time_[6][150]; // array of bar open time

double Kurtz[6][70]; //this is an array for the fast moving Kurtz, the row numbers correspond to the numbers of currencies used, while the columns are the counts of the moving

double Mittel[6][70]; // this is array for the moving average Mittel

double Long[6][70]; // this is an array for a long-period sliding Long

string Name_symbol[6] = { "AUDUSD", "EURUSD", "GBPUSD", "USDCAD", "USDCHF", "USDJPY" } ; // this is a text array of currency names:

int nomer_instr; // this is an instrument (currency) number, only to organize cycles by currencies

int OnInit()

{

//-----

//-------

}

void OnDeinit(const int reason)

{

//---

ArrayFree(Time_buf);

ArrayFree( ma_buf); // zeroize the released array

//-------

}

void OnTick()

{

//---------------------

ArraySetAsSeries(time_buf, true); //set indexing for the time_array array as in timeseries

ArraySetAsSeries(ma_buf, true); //set indexing for array ma_buf as in timeseries

for( nomer_instr=0; nomer_instr<=5; nomer_instr++ ) // this is a loop on all used currencies

{

int digit = int( SymbolInfoInteger( Name_symbol[nomer_instr], SYMBOL_DIGITS)); // this is the number of digits in the currency quote

CopyTime( Name_symbol[nomer_instr], PERIOD_M1,0,160,Time_buf); // copy historical time data for each bar to the buffer

for( i=1; i<=145; i++ ) Time[nomer_instr][i]=Time_buf[i]; // time of the 1st bar open

//#############################################################################################

//Block generating counts of the first 3 sliding bars:Kurtz, Mittel, Long

manHandle = iMA( Name_symbol[nomer_instr],PERIOD_M1, Kurtz_Period , 0, MODE_SMMA, PRICE_CLOSE );

if( CopyBuffer(maHandle,0,0,155,ma_buf)<0 )

{

Alert("Error in copying indicator buffers ---PERIOD_M1,Kurtz_Period--- Moving Average - error number:",GetLastError());

return;

}

for( i=1; i<=45; i++ ) Kurtz[nomer_instr][ i ] = NormalizeDouble( ma_buf[i], digit);

/*

//===============================================================

// BLOCK checking for bar offset as in timeseries and accuracy of number normalization

// fast moving MA-5

if( Multi_Torgi == 0 && Optim_parametrov == nomer_instr ) // this is a key to select the mode of the Expert Advisor, now it is in the debug mode

{

for( i=1; i<=5; i++ )

{

if(i==1) Alert("====================");

if(i==1) Alert(" opening time of the 1st bar: Time[nomer_instr][1]=",Time[nomer_instr][1] );

Alert(" bar number: i=",i,", MA_buf[i]=",MA_buf[i],", Kurtz[nomer_instr][i]=",Kurtz[nomer_instr][i]);

}

}

//=================================================================

*/

//---------------------------------------------------------------------------------------------------------------------------

maHandle = iMA( Name_symbol[nomer_instr],PERIOD_M1, Mittel_Period, 0, MODE_SMMA, PRICE_CLOSE );

if(CopyBuffer(maHandle,0,0,155,ma_buf)<0)

{

Alert("Error in copying indicator buffers ===PERIOD_M1, Mittel_Period,=== Moving Average - error number:",GetLastError());

return;

}

for( i=1; i<=45; i++ ) Mittel[nomer_instr][ i ] = NormalizeDouble( ma_buf[i], digit);

//----------------------------------------------------------------------------------------------------------------------

maHandle = iMA( Name_symbol[nomer_instr],PERIOD_M1, Long_Period, 0, MODE_SMMA, PRICE_CLOSE );

if(CopyBuffer(maHandle,0,0,155,ma_buf)<0)

{

Alert("Error in copying indicator buffers ===PERIOD_M1, Long_Period,===Moving Average - error number:",GetLastError());

return;

}

for( i=1; i<=45; i++ ) Long[nomer_instr][ i ] = NormalizeDouble( ma_buf[i], digit);

// end of the block forming the counts of the first 3 slides: Kurtz, Mittel,Long

//#############################################################################################

} // end of loop by currencies in use

//============================================================

Other operators of the program

//============================================================

//-----------------------------------------

}// End of OnTick()

//+------------------------------------------------------------------+

No errors are detected on this program at compile time, but when tested in the Logbook for each slip, an

error message: 4806 is " requested data not found".

Please tell me where I have the error.

Thank you.

Документация по MQL5: Основы языка / Функции / Функции обработки событий
Документация по MQL5: Основы языка / Функции / Функции обработки событий
  • www.mql5.com
Основы языка / Функции / Функции обработки событий - Документация по MQL5
 
DC2008:

Don't you understand the principle of typecasting? It's so simple:

It seems clear now) It turns out that int st operand is of a minor type than datetime tp[].

That's why there is no conversion to seconds in the operation:

int st=tp[0];

I tried to find the minimum in the time interval. I'm not sure I'm doing it right. Can you see the previous post?

How can Alert or Comment be called without new ticks to do weekend checks?

 
forexman77:

Need to find the minimum in the time interval. I have made the following code to find the minimum in the time interval:

To find minima in this interval I use the function CopyLow:

Then, if I understand correctly, I get a one-dimensional arrayLow[],

I'm looking for the minimum in it with ArrayMinimum:

I tried to set today a start time of 1 hour, a stop time of 2 hours and call Alert to check min=-1.

Question: for this problem, are the functions chosen correctly to solve this problem, or is there an error somewhere? You need to get the minimum price.

Please read carefully:

Return value.

The function returns the index of the found item taking into account the array's seriality. If itfails, the function returns -1.

Therefore, it should be like this:

Alert("min=",Low[ArrayMinimum(Low)]);
 

Check and test on weekends and beyond, you have to script.

 
DC2008:

Check and test on weekends and beyond, you have to script.

Thank you!
Reason: