Questions from Beginners MQL5 MT5 MetaTrader 5 - page 1303

 
afsmerinostra:

Good time,

Please help me to find a bug... I copy bar values (BarsCount) from the indicator buffer in the script, then I loop around values, detect a signal and print them to Print(); it seems to be simple, but it's not so easy... I get all signals as I wanted except for crossing zero line.

Maybe this is not allowed in the script? I attached the code and a screenshot of the log... Thank you very much!

The crossing can only be defined by comparing the value of the previous array index with zero and the value of the current array index with zero. That is, it was above zero and became below zero. Or vice versa, it was lower and became higher.

And be sure to read through the documentation how if tlse if works.

If your code contains one condition, all following ones will not be processed.

 
Alexey Viktorov:

An intersection can only be defined by comparing the previous array index to zero and the current one to zero. I.e. it was above zero and became below zero. Or vice versa, it was lower and became higher.

And be sure to read through the documentation how if tlse if works.

If your code contains one condition, all following ones will not be processed.

I was right about checking the level against zero. I moved the crossing conditions to the beginning of the code and it all worked. Thank you!
 
afsmerinostra:
Everything was right about checking the level relative to zero. I moved the intersection conditions to the beginning of the code, and everything works. Thank you!

Generally, you need to clean up else, they are only needed when the conditions are mutually exclusive and the overlap is separate conditions.

 
Hi all!!! Can you tell me what's wrong?
//+------------------------------------------------------------------+
//|                                                 Signal_Line.mqh |
//|                                  Copyright 2021, MetaQuotes Ltd. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2021, MetaQuotes Ltd."
#property link      "https://www.mql5.com"
#property version   "1.00"
class Signal_Line
  {
private:

public:
                     Signal_Line();
                    ~Signal_Line();
   bool              Signal_Short(double &Trend_Line_UP[][], int UP);
  };
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
Signal_Line::Signal_Line()
  {
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
Signal_Line::~Signal_Line()
  {
  }
//+------------------------------------------------------------------+

//+------------------------------------------------------------------+
//|     Метод проверки флагов событий цены относительно линий тренда                                                             |
//+------------------------------------------------------------------+
bool Signal_Line::Signal_Short(double &Trend_Line_UP[][], int UP)
  {
   if(Trend_Line_UP[UP][3]<iClose(_Symbol,0,0))
      return(true);
  }
//+------------------------------------------------------------------+
 

It says: Why didn't you deign to return the value?

bool Signal_Line::Signal_Short(double &Trend_Line_UP[][], int UP)
  {
   if(Trend_Line_UP[UP][3]<iClose(_Symbol,0,0))
      return(true);
//---
   return(false);
  }
 
Vladimir Karputov:

It says: Why didn't you deign to return the value?

Exactly!!! Oh my gosh)))

 
Vladimir Karputov:

It says: why didn't you deign to return the value?

Thank you!!!

 
In mql4 there are functions

OrderCloseTime();

and datetimeOrderOpenTime(); How can I get this data programmatically in mql5 for already closed positions? That is, the time of opening and closing of a closed position?

 
bahtiyar:
In mql4 there are functions

OrderCloseTime();

and datetimeOrderOpenTime(); How can I get this data programmatically in mql5 for already closed positions? That is, the time of opening and closing of closed positions

Select in the history of trade by position ID and in the properties of trades there is opening and closing. Not only time, but also price and reason for closing and something else.
 

Can you give me a hint? This entry:

var1=(var<10)?1:0;

What it means, how to interpret it, options for use. Parameters.

Reason: