Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 6

 

Comrades, I've never done any history fitting, so I don't know the intricacies of reading the graph after optimisation.

There is such a graph after annual pass 2014-2015, where to look and what does it mean? Interested in the colour and location of the cubes, why are some in the centre, others lower/higher, and two/three in the same square?

Thanks for the clarification!

 
strongflex:
It does not open trade in the tester. What could be the problem here?)

Well... First, you are trying to open a Sell at Ask price. Whereas you are opening a sale at Bid and a buy at Ask.

I have put the RSI data search and its level crossing into a function. It also has a price check. It returns signals: to buy, to sell, or nothing (-1)

//+------------------------------------------------------------------+
//|                                               exTestValueRSI.mq4 |
//|              Copyright 2016, Artem A. Trishkin, Skype artmedia70 |
//|                       https://login.mql5.com/ru/users/artmedia70 |
//+------------------------------------------------------------------+
#property copyright "Copyright 2016, Artem A. Trishkin, Skype artmedia70"
#property link      "https://login.mql5.com/ru/users/artmedia70"
#property version   "1.00"
#property strict
//--- input parameters
input ENUM_TIMEFRAMES      TimeframeRSI   = PERIOD_M15;  // Таймфрейм RSI
input int                  PeriodRSI      = 14;          // Период расчёта RSI
input ENUM_APPLIED_PRICE   PriceRSI       = PRICE_CLOSE; // Цена расчёта RSI
input int                  UpperRSIlevel  = 70;          // Верхний уровень RSI
input int                  LowerRSIlevel  = 30;          // Нижний уровень RSI
input int                  MinutesBefore  =20;           // Количество минут назад
//--- global variables
int      minutesBefore;    // Количество минут назад
int      periodRSI;        // Период расчёта RSI
int upperRSIlevel;         // Верхний уровень RSI
int lowerRSIlevel;         // Нижний уровень RSI
//---
double   prevRSIvalue0;    // Значение RSI для заданного тф xxx минут назад
double   prevRSIvalue1;    // Значение RSI для заданного тф xxx минут назад-x минут
//---
double   prevClose_0;      // Значение Close для заданного тф xxx минут назад
double   prevClose_1;      // Значение Close для заданного тф xxx минут назад-x минут
//---
datetime timeBefore;       // Время ххх минут назад
datetime timePrevBefore;   // Время ххх минут назад-x минут
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
   minutesBefore=(MinutesBefore<1?1:MinutesBefore);  // Количество минут назад
   periodRSI=(PeriodRSI<1?1:PeriodRSI);
   upperRSIlevel=(UpperRSIlevel<1?1:UpperRSIlevel>100?100:UpperRSIlevel);
   lowerRSIlevel=(LowerRSIlevel<0?0:lowerRSIlevel>99?99:LowerRSIlevel);
   if(upperRSIlevel<=lowerRSIlevel) upperRSIlevel=lowerRSIlevel+1;
   if(lowerRSIlevel>=upperRSIlevel) lowerRSIlevel=upperRSIlevel-1;
   /*

   */
  
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
  
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---
   MqlDateTime server_time;
   TimeToStruct(TimeCurrent(),server_time);
   //--- если значение минут серверного времени кратно заданному значению, в частности 20-ти минутам или равно 0
   if(server_time.min%minutesBefore==0 || server_time.min==0) {
      if(SignalByRSI(Symbol(),TimeframeRSI,minutesBefore)==OP_BUY) {
         //--- получили сигнал на покупку
         Print("Сигнал на покупку ",TimeCurrent());   // Проверочное сообщение в журнал
         //--- проверка наличия уже открытой позиции на покупку
         //--- вызов функции открытия позиции на покупку
         }
      if(SignalByRSI(Symbol(),TimeframeRSI,minutesBefore)==OP_SELL) {
         //--- получили сигнал на продажу
         Print("Сигнал на продажу ",TimeCurrent());   // Проверочное сообщение в журнал
         //--- проверка наличия уже открытой позиции на продажу
         //--- вызов функции открытия позиции на продажу
         }
      }
  }
//+------------------------------------------------------------------+
double GetLastDataRSI(string symbol_name, ENUM_TIMEFRAMES timeframe, int shift, int period_rsi=14, ENUM_APPLIED_PRICE price_rsi=PRICE_CLOSE) {
   return(iRSI(symbol_name,timeframe,period_rsi,price_rsi,shift));
}
//+------------------------------------------------------------------+
double GetPriceClose(string symbol_name,ENUM_TIMEFRAMES timeframe, int shift){
   double array[1];
   if(CopyClose(symbol_name,timeframe,shift,1,array)==1) return(array[0]);
   return(-1);
}
//+------------------------------------------------------------------+
int GetBarShift(string symbol_name,ENUM_TIMEFRAMES timeframe,datetime time) {
   if(time<0) return(-1);
   //---
   datetime array[], time0;
   if(CopyTime(symbol_name,timeframe,0,1,array)<0) return(-1);
   time0=array[0];
   if(CopyTime(symbol_name,timeframe,time0,time,array)<0) return(-1);
   datetime temptime=GetTime(symbol_name,timeframe,ArraySize(array)-1);
   if(array[0]==temptime && temptime<=time) return(ArraySize(array)-1);
   else return(ArraySize(array));
}
//+------------------------------------------------------------------+
datetime GetTime(string symbol_name,ENUM_TIMEFRAMES timeframe,int bar) {
   if(bar<0) return(-1);
   datetime array[];
   if(CopyTime(symbol_name,timeframe,bar,1,array)>0) return(array[0]);
   return(-1);
}
//+------------------------------------------------------------------+
int SignalByRSI(string symbol_name, ENUM_TIMEFRAMES timeframe, int minutes_before, int upper_lev_rsi=70, int lower_lev_rsi=30) {
   //--- время 1x и 2x минут назад
   datetime time_before_0=TimeCurrent()-minutes_before*PeriodSeconds(PERIOD_M1);
   datetime time_before_1=TimeCurrent()-2*minutes_before*PeriodSeconds(PERIOD_M1);
   //--- смещение в барах времени 1х и 2х для заданного таймфрейма RSI (тф М15)
   int shift_0=GetBarShift(symbol_name,timeframe,time_before_0);
   int shift_1=GetBarShift(symbol_name,timeframe,time_before_1);
   //--- значения RSI на барах 1х и 2х минут назад для заданного таймфрейма RSI (тф М15)
   double prev_rsi_value_0=GetLastDataRSI(symbol_name,timeframe,shift_0);
   double prev_rsi_value_1=GetLastDataRSI(symbol_name,timeframe,shift_1);
   //--- значения цен закрытия баров 1х и 2х минут назад
   double prev_close_0=GetPriceClose(symbol_name,timeframe,shift_0);
   double prev_close_1=GetPriceClose(symbol_name,timeframe,shift_1);
   //--- отладочные сообщения
   string tf=EnumToString(TimeframeRSI);
   MqlDateTime server_time;
   TimeToStruct(TimeCurrent(),server_time);
   Comment(
          "\nВремя проверки RSI: ",TimeCurrent(),", минуты времени проверки: ",server_time.min,
          "\nВремя ",minutes_before," минут назад: ",time_before_0,", бар ",tf," : ",shift_0,
          "\nВремя ",minutes_before*2," минут назад: ",time_before_1,", бар ",tf," : ",shift_1,
          "\nЗначение RSI ",minutes_before," минут назад на ",tf," : ",DoubleToString(prev_rsi_value_0,4),
          "\nЗначение RSI ",minutes_before*2," минут назад на ",tf," : ",DoubleToString(prev_rsi_value_1,4),
          //---
          "\nЗначение Close ",minutes_before," минут назад > ",tf," : ",DoubleToString(prev_close_0,Digits()),
          "\nЗначение Close ",minutes_before*2," минут назад > ",tf," : ",DoubleToString(prev_close_1,Digits())
          );
   //--- проверка наличия данных RSI
   if(prev_rsi_value_1>0 && prev_rsi_value_0>0) {
      //--- проверка условия на продажу
      if(prev_rsi_value_1<upper_lev_rsi && prev_rsi_value_0>upper_lev_rsi) {
         if(prev_close_0>SymbolInfoDouble(symbol_name,SYMBOL_BID)) return(OP_SELL);
         }
      //--- проверка условия на покупку
      if(prev_rsi_value_1>lower_lev_rsi && prev_rsi_value_0<lower_lev_rsi) {
         if(prev_close_0<SymbolInfoDouble(symbol_name,SYMBOL_ASK)) return(OP_BUY);
         }
      }
   return(-1);
}
//+------------------------------------------------------------------+
 
Vitaly Muzichenko:

Comrades, I've never done any history fitting, so I don't know the intricacies of reading the graph after optimisation.

There is such a graph after annual pass 2014-2015, where to look and what does it mean? Interested in the colour and location of the cubes, why are some in the centre, others below/above, and two/three in the same square?

Thanks for the clarification!

I've never trusted optimisers in so many years either - I think it's a fit. But it's kinda like the richer the colour, the better. And also - the more blocks with saturated colours, the better. But what to do further with this mess - I can not think. I've always tried to build adaptive systems, and not with stupid selection of values for a tester's story.

Perhaps there is someone who can explain all this to us

 
Artyom Trishkin:

I've never trusted optimisers in so many years either - I think of them as tinkering. But the more saturated the colour, the better. And also - the more blocks with saturated colours, the better. But what to do further with this mess - I can not think. I've always tried to build adaptive systems, and not with stupid selection of values for a tester's story.

Perhaps there is someone who can explain all this to us

Most likely no one will. There are 10-12 people left on the forum, some of them got banned and many of them will not come back. Now if you look at the forum, about 5-7 people appear, half of them do not answer questions. My question about the schedule remains unanswered.
 
Vitaly Muzichenko:
Yes, it's likely that no one will explain. There are 10-12 people left on the forum, some of them have been banned and many of them will not come back. Now if you look at the forum, there are about 5-7 people, half of them do not answer questions. My question about the schedule has not been answered.
Have to look on the fourth forum - I saw an explanation of the optimizer there once a long time ago, but I don't remember what it was about or where it was...
 
Artyom Trishkin:
You need to look on the fourth forum - I saw an explanation of the optimizer there some time ago, but I don't remember quite what it's about and where it is...
Here it is, only it doesn't match what I got during testing, that's why I asked a question to the connoisseurs.
 

Hello.

Can you please tell me why it's impossible to select a date from the drop-down calendar if I do so in the external settings:
extern datetime CloseTime        = D'2016.09.11 15:50';  //

Is there any way to change so that you can select a date instead of typing it in from the keyboard?

 
Vitaly Muzichenko:

Comrades, I've never done any history fitting, so I don't know the intricacies of reading the graph after optimisation.

There is such a graph after annual pass 2014-2015, where to look and what does it mean? Interested in the colour and location of the cubes, why are some in the centre, others lower/higher, and two/three in the same square?

Thanks for the clarification!

Vitaly Muzichenko:
Yes most likely no one will explain. There are only 10-12 people left on the forum, some of them have been banned, and many have never come back. Now, if you look at the forum, about 5-7 people appear, half of them do not answer questions. My question about the schedule remained unanswered.

There is nothing much to explain and nobody is answering. The graph you showed is meaningless and how it was obtained is a mystery.

And the "Two-dimensional surface" option in the "Optimization graph" tab of the tester makes sense (imho) when we want to optimize 2 input parameters of an EA or to clearly see, at which values of 2 parameters the results were good on the history and whether these parameters are interdependent, and whether they make sense at all.

Here is an example of the optimization of 2 input parameters (maybe not the best, but I can't find a better example right now):


The horizontal axis is the value of the 1st parameter in 16 increments, and the vertical axis is the value of the 2nd parameter, also in 16 increments. The darker the green square, the greater the profit (if optimization by profit) was at the corresponding values of the parameters, the paler the less. The best result (by history profit) was in the centre. Dark green "heap" seems to be around it which suggests some dependence and regularity between these 2 parameters and the parameters are not meaningless, while the optimization result is not accidental. So it is worth paying attention to the values of these 2x parameters from the best result (in the centre).

In general, everything is very simple. As for how to use it, well, it's a matter of imagination. I don't look at these green squares for a long time ))

Your graph has only 0 on both axes for some reason, and vertically these 0's are also divided into 3 intermediate steps, hence the "cubes one in the centre, two below/above, and two/three in the same square". And the results look random - white and green "cubes" are scattered randomly. So the graph is meaningless and seems to mean nothing.

 
Hello.
I'm writing my own dll to work with sqlite3 database from indicator. The codeblockes development environment works, but not correctly and occasionally crashes with an access violation.
Initial questions:
1. Is it possible to build dlls in codeblockes correctly at all or only in Visual Studio? Simple examples ( working with Int, double) are built and work. Stacks and work with files doesn't - the program crashes.
2. I was unable to start and work with __stdcall, only with __cdecl. Distorted function names , and def file in codeblockes does not work normally.
I am seeking help from knowledgeable users.
If there is already a topic, please ask the Admin to post it in the appropriate branch.
 
mila.com:

Hello.

Can you please tell me why it's impossible to select a date from the drop-down calendar if I do so in the external settings:
extern datetime CloseTime        = D'2016.09.11 15:50';  //

Is there any way to change so that the date can be selected instead of entering it from the keyboard?

input datetime CloseTime        = D'2016.09.11 15:50';
Reason: