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

 
Alexey Viktorov:

Indeed not all keyboards have what I wrote about... Maybe you should change your keyboard.



There's too many "experts" here :) So I thought I'd make fun of you. Instead of answering questions, they start lecturing.

 
Luchezar Shalomaev:

There are too many "experts" here :) So I decided to make fun of them. Instead of answering questions, start lecturing.

Then do not expect normal answers from people who are busy doing their own thing and are distracted from helping you, if you put yourself in a position to make fun of the giver.

This is not a circus.

 
Artyom Trishkin:

Then do not expect in the future from people who are busy with their business, and distracted to help you, normal responses, if you put yourself in a position to make fun of the giver.

This is not a circus.



Dear moderator, if this is not a circus, would you kindly take the clowns who answered my questions backstage? Thank you.

 
Luchezar Shalomaev:


Dear moderator, if this isn't a circus, would you be so kind as to take the clowns who answered my questions backstage? Thank you.

Is this the way to send you behind the scenes?

You:

Forum on trading, automated trading systems & strategy testing

Any questions from beginners on MQL4, help and discussion on algorithms and codes

Luchezar Shalomaev, 2017.09.20 22:25

Hello. Downloaded EUR USD 1 minute quote file from Ducascopy, trying to import into MT4 Alpari, nothing happens. Just a blank conversion window. Same on Instaforex. What can it be?

Answer:

You:

Answer:

You:

Response:

You:

You:

You:

Forum on trading, automated trading systems and trading strategy testing

Any questions newbies have on MQL4, help and discussion on algorithms and codes

Luchezar Shalomaev, 2017.09.21 21:10


There are too many "experts" here :) So decided to make fun of them. Instead of answering your questions, they start preaching.


Your question has been answered - press F2, which brings up the quote download window.

But you started bantering and got the banter in reply.

What did you want? What you came with, as they say...

 
Artyom Trishkin:

So should I send you backstage?

You:

Answer:

You:

Response:

You:

Response:

You:

You:

You:


You have been answered your question - press F2, which brings up the quote download window.

But you started to banter, to which you received a banter in response.

What do you want? What you came with, as they say...













Well, you say it is not a circus.

 
Aleksey Vyazmikin:
The easiest way to write the logic is to make it clearer - I don't understand what the logic is... can you describe it in words?

Found a fault in the logic. Fixed it and it works.

int Doji()
{

//Параметры Дожи
   double Open1 = NormalizeDouble (iOpen(Symbol(), PERIOD_H4,1),Digits);
   double Close1 = NormalizeDouble (iClose(Symbol(), PERIOD_H4,1),Digits);
   double High1 = NormalizeDouble (iHigh(Symbol(), PERIOD_H4,1),Digits);
   double Low1 = NormalizeDouble (iLow(Symbol(), PERIOD_H4,1),Digits);
   
//Параметры предыдущей свечи
   double Open2 = NormalizeDouble (iOpen(Symbol(), PERIOD_H4,2),Digits);
   double Close2 = NormalizeDouble (iClose(Symbol(), PERIOD_H4,2),Digits);
   double High2 = NormalizeDouble (iHigh(Symbol(), PERIOD_H4,2),Digits);
   double Low2 = NormalizeDouble (iLow(Symbol(), PERIOD_H4,2),Digits);
   
//Параметры индикатора волотильности ATR для нахожденя относительно большой свечи перед Доджи
   double ATR = iATR(Symbol(),PERIOD_H4,21,1);
   
   
//Математическое описание патерна Дожи
   if(Close1 < High1 -0.3*(High1-Low1) && 
      Open1 < High1 -0.3*(High1-Low1) && 
      Close1 > High1 -0.7*(High1-Low1) && 
      Open1 > High1 -0.7*(High1-Low1) && 
      MathAbs(Close1-Open1) < 0.2*(High1-Low1)&&
      MathAbs(Close2-Open2) > 0.7*ATR)
      {
         if((Close2 - Open2) > 0 && New_Bar == true)
         { 
            Print ("Down"); return(-1);// Условие для продаж
         }
         if((Close2 - Open2) < 0 && New_Bar == true)
         {
            Print ("Up"); return(1);// Условие для покупок
         }
      }
      return(0);
}
The error was in the mathematical description of the Doji pattern.
 

Now the task is as follows. We need to draw a rectangle instead of an arrow, which will be plotted by max and min Doji and by the opening time of Doji and the opening time of a new bar after Doji. And this is all on a 4 hour chart. At the same time I need to be on a 5 minute chart. What can you advise? How to implement?

I do not know how to do it. Thank you.

 
voron_026:

Found a fault in the logic. Fixed it and it's working.

The error was in the mathematical description of the Doji pattern.

Good for you. Have you programmed before? Your style is not typical.

voron_026:

Now the task is as follows. Instead of arrows, we have to draw a rectangle, which will be drawn by max and min Doji and by opening time of Doji and opening time of a new bar after Doji. And all this on a 4-hour chart. At the same time I need to be on a 5 minute chart. What can you advise? How to implement?

Thank you.


Make declaration of common (global) variables which will be calculated in function and return from it void(){} . Can you define the time... Anyway, I haven't understood the exact question yet.

By the way, I didn't know about global variable approach before and was returning all values from function via string variable...

 
voron_026:

Now the task is as follows. We need to draw a rectangle instead of an arrow, which will be plotted by max and min Doji and by the opening time of Doji and the opening time of a new bar after Doji. And this is all on a 4 hour chart. At the same time I need to be on a 5 minute chart. What can you advise? How to implement?

Thank you.

You have to use OBJ_RECTANGLE. You know how to get price and time data from H4 chart.

Документация по MQL5: Стандартные константы, перечисления и структуры / Константы объектов / Типы объектов / OBJ_RECTANGLE
Документация по MQL5: Стандартные константы, перечисления и структуры / Константы объектов / Типы объектов / OBJ_RECTANGLE
  • www.mql5.com
Стандартные константы, перечисления и структуры / Константы объектов / Типы объектов / OBJ_RECTANGLE - справочник по языку алгоритмического/автоматического трейдинга для MetaTrader 5
 
Aleksey Vyazmikin:

Good for you. Have you programmed before? Your style is not typical.


Declare general (global) variables to be computed in the function and return from it void(){} . Can you determine the time... Anyway, I don't understand what exactly the question is.

By the way, I didn't know about global variable approach before and returned all values from function through string variable...


HelloAleksey Vyazmikin I am programming not so long ago. I am slowly getting into the subject.

I have tried it this way:

//+------------------------------------------------------------------+
//|                                                          111.mq4 |
//|                                       Copyright 2017,UriyGlushko |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2017,UriyGlushko"
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict

extern string Rodot           = "Параметры робота";
extern double Lots            = 0.2;
extern int    StopLoss        = 20;
extern int    TakeProfit      = 80;
extern int    Magic           = 999999;
extern int    Slippage        = 3; // Проскальзывание

extern bool UseDojiCandles = true; // Использование патерна Доджи
int DojiCandle = 0;
bool New_Bar = false;

datetime time0 = iTime(Symbol(),PERIOD_H4,0);
datetime time1 = iTime(Symbol(),PERIOD_H4,1);
double open0 = iOpen(Symbol(), PERIOD_H4,0);
double open1 = iOpen(Symbol(), PERIOD_H4,1);
double close1 = iClose(Symbol(), PERIOD_H4,1);
double high1 = iHigh(Symbol(), PERIOD_H4,1);
double low1 = iLow(Symbol(), PERIOD_H4,1);
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
{
  if (Digits == 3 || Digits ==5 )
  {
   TakeProfit *= 10;
   StopLoss   *= 10;
   Slippage   *= 10;
  }
 return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
  
   
}
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
{
Fun_New_Bar();

   if(UseDojiCandles = true && Doji() == 1 && New_Bar == true)
     {
      if(!ObjectCreate(ChartID(),"Doji_"+IntegerToString(DojiCandle),OBJ_RECTANGLE,0,time1,open1,time0,open0))
         {
         Print("Не удалось создать метку вверх");
         }
         ObjectSetInteger(ChartID(),"Doji_"+IntegerToString(DojiCandle),OBJPROP_COLOR,clrRed);//--- установим цвет прямоугольника 
         ObjectSetInteger(ChartID(),"Doji_"+IntegerToString(DojiCandle),OBJPROP_STYLE,STYLE_SOLID);//--- установим стиль линий прямоугольника 
         ObjectSetInteger(ChartID(),"Doji_"+IntegerToString(DojiCandle),OBJPROP_WIDTH,1);//--- установим толщину линий прямоугольника 
         ObjectSetInteger(ChartID(),"Doji_"+IntegerToString(DojiCandle),OBJPROP_BACK,false);//--- отобразим на переднем (false) или заднем (true) плане 
         
         DojiCandle ++;
     }
   

   
   if(UseDojiCandles = true && Doji() == -1 && New_Bar == true)
     {
      if(!ObjectCreate(ChartID(),"Doji_"+IntegerToString(DojiCandle),OBJ_RECTANGLE,0,time1,open1,time0,open0))
         {
         Print("Не удалось создать метку вниз");
         }
         ObjectSetInteger(ChartID(),"Doji_"+IntegerToString(DojiCandle),OBJPROP_COLOR,clrRed);//--- установим цвет прямоугольника 
         ObjectSetInteger(ChartID(),"Doji_"+IntegerToString(DojiCandle),OBJPROP_STYLE,STYLE_SOLID);//--- установим стиль линий прямоугольника 
         ObjectSetInteger(ChartID(),"Doji_"+IntegerToString(DojiCandle),OBJPROP_WIDTH,1);//--- установим толщину линий прямоугольника 
         ObjectSetInteger(ChartID(),"Doji_"+IntegerToString(DojiCandle),OBJPROP_BACK,false);//--- отобразим на переднем (false) или заднем (true) плане 

         DojiCandle ++;
     }
     

   
}
//+------------------------------------------------------------------+
//    Поиск всех объектов
//+------------------------------------------------------------------+


 




//+------------------------------------------------------------------+
//    Функция паттерна Доджи
//+------------------------------------------------------------------+
int Doji()
{

//Параметры Дожи
   double Open1 = NormalizeDouble (iOpen(Symbol(), PERIOD_H4,1),Digits);
   double Close1 = NormalizeDouble (iClose(Symbol(), PERIOD_H4,1),Digits);
   double High1 = NormalizeDouble (iHigh(Symbol(), PERIOD_H4,1),Digits);
   double Low1 = NormalizeDouble (iLow(Symbol(), PERIOD_H4,1),Digits);
   
//Параметры предыдущей свечи
   double Open2 = NormalizeDouble (iOpen(Symbol(), PERIOD_H4,2),Digits);
   double Close2 = NormalizeDouble (iClose(Symbol(), PERIOD_H4,2),Digits);
   double High2 = NormalizeDouble (iHigh(Symbol(), PERIOD_H4,2),Digits);
   double Low2 = NormalizeDouble (iLow(Symbol(), PERIOD_H4,2),Digits);
   
//Параметры индикатора волотильности ATR для нахожденя относительно большой свечи перед Доджи
   double ATR = iATR(Symbol(),PERIOD_H4,21,1);
   
   
//Математическое описание патерна Дожи
   if(Close1 < High1 -0.3*(High1-Low1) && 
      Open1 < High1 -0.3*(High1-Low1) && 
      Close1 > High1 -0.7*(High1-Low1) && 
      Open1 > High1 -0.7*(High1-Low1) && 
      MathAbs(Close1-Open1) < 0.2*(High1-Low1)&&
      MathAbs(Close2-Open2) > 0.7*ATR)
      {
         if((Close2 - Open2) > 0 && New_Bar == true)
         { 
            Print ("Down"); return(-1);// Условие для продаж
         }
         if((Close2 - Open2) < 0 && New_Bar == true)
         {
            Print ("Up"); return(1);// Условие для покупок
         }
      }
      return(0);
}
//+------------------------------------------------------------------+
//    Функция определения нового бара
//+------------------------------------------------------------------+
void Fun_New_Bar()                              // Ф-ия обнаружения нового бара 
  {                                             
  datetime TimeBar0 = iTime(Symbol(),PERIOD_H4,0);
   static datetime New_Time=0;                  // Время текущего бара 
   New_Bar=false;                               // Нового бара нет 
   if(New_Time != TimeBar0)                        // Сравниваем время 
     { 
      New_Time = TimeBar0;                         // Теперь время такое 
      New_Bar = true;                             // Поймался новый бар 
     } 
  }  

The first rectangle is drawn. The rest are not drawn. I am still trying to figure out how to do it. Thank you for the tips and what do you mean by a non-typical style?

Reason: