and when using the function in the Expert Advisor, it stops working in the tester, please tell me the reason, the code is taken from the article https://www.mql5.com/ru/articles/22
//+------------------------------------------------------------------+//| CheckLastBar.mq5 |//| Copyright 2010, MetaQuotes Software Corp. |//| http://www.mql5.com |//+------------------------------------------------------------------+#property copyright "Copyright 2010, MetaQuotes Software Corp."#property link "http://www.mql5.com"#property version "1.00"//+------------------------------------------------------------------+//| Expert tick function |//+------------------------------------------------------------------+voidOnTick()
{
//---if(isNewBar())
{
PrintFormat("Новый бар: %s",TimeToString(TimeCurrent(),TIME_SECONDS));
}
}
//+------------------------------------------------------------------+//| Возвращает true, если появился новый бар для пары символ/период |//+------------------------------------------------------------------+bool isNewBar()
{
//--- в статической переменной будем помнить время открытия последнего бараstaticdatetime last_time=0;
//--- текущее времяdatetime lastbar_time=SeriesInfoInteger(Symbol(),Period(),SERIES_LASTBAR_DATE);
//--- если это первый вызов функцииif(last_time==0)
{
//--- установим время и выйдем
last_time=lastbar_time;
return(false);
}
//--- если время отличаетсяif(last_time!=lastbar_time)
{
//--- запомним время и вернем true
last_time=lastbar_time;
return(true);
}
//--- дошли до этого места - значит бар не новый, вернем falsereturn(false);
}
//+------------------------------------------------------------------+
Можно ли торговать этим инструментом в понедельник? Хватит ли денег на открытие позиции? Какой размер убытка мы получим, если сработает Stop Loss? Как ограничить количество отложенных ордеров? Была ли выполнена торговая операция на этом баре или это было на предыдущем? Если торговый робот не может сделать подобные проверки, то любая прибыльная торговая система может превратиться в проигрышную. В этой статье показаны примеры проверок, которые пригодятся в любом эксперте.
When compiling the code, a message appears: possible loss of data due to type conversion on the line
and when using the function in the Expert Advisor, it stops working in the tester, please tell me the reason, the code is taken from the articlehttps://www.mql5.com/ru/articles/22
I am not sure about the tester. About "... type conversion":
Interesting, but I have a similar one too.Filling a double array with double data.It gives the same warning on this line.
Maybe it's the ambiguous interpretation of the constants (0,0,13). The CopyBuffer has three variants of call. Try to substitute variables of needed type as parameters or use explicit type conversion for constants.
Thanks, I'll try it. I've already tried the conversion, the explicit conversion goes through, if I translate a mask handle with (int), but that doesn't suit me of course :-)
Karlson: Thanks, I'll give it a try. I've already tried the conversion, the explicit conversion goes through, if I translate a mask handle via (int), but that doesn't suit me of course :-)
intiMA(
string symbol, // имя символаENUM_TIMEFRAMES period, // периодint ma_period, // период усредненияint ma_shift, // смещение индикатора по горизонталиENUM_MA_METHOD ma_method, // тип сглаживанияENUM_APPLIED_PRICE applied_price // тип цены или handle
);
I have a few questions too. Where are the moving average crossover signal modules? Where are the alligatora signals? One more thing. Each indicator has several types of signals. How to make MACD accept only zero crossing signals?
Alex, can you tell me how to compare m_rates[1].low with m_rates[0].close?
m_rates[1].low=m_rates[0].close will it be correct and in general, m_rates[0].close is the last price of the bar which is not yet closed?
and in general, what is the correct way to deal with the last bar without using indicators?(CopyRates, CopyHigh)
Alex, how can I compare m_rates[1].low with m_rates[0].close?
m_rates[1].low=m_rates[0].close will it be correct and in general m_rates[0].close is the last price of the bar which is not yet closed?
and in general, what is the correct way to deal with the last bar without using indicators? (CopyRates, CopyHigh)
you correctly wrote that you should use CopyRates or CopyHigh/Low/Close, etc. to work with price data outside of indicators.
You can find examples in the help or in the code base.
When compiling the code, a message appears: possible loss of data due to type conversion on the line
and when using the function in the Expert Advisor, it stops working in the tester, please tell me the reason, the code is taken from the article https://www.mql5.com/ru/articles/22
When compiling the code, a message appears: possible loss of data due to type conversion on the line
and when using the function in the Expert Advisor, it stops working in the tester, please tell me the reason, the code is taken from the articlehttps://www.mql5.com/ru/articles/22
Interesting, but I have a similar one too.Filling a doublearray with double data. It gives the same warning on this line.
Interesting, but I have a similar one too.Filling a double array with double data.It gives the same warning on this line.
Thanks, I'll give it a try. I've already tried the conversion, the explicit conversion goes through, if I translate a mask handle via (int), but that doesn't suit me of course :-)
Got it wrong. Need an int.
Thank you.