Questions from Beginners MQL5 MT5 MetaTrader 5 - page 1364

 

Can you please tell me how to declare an array in a class in order to pull it out in an EA?

m_pr_hl2[b]=MathAbs((iHigh(this.m_symbol,this.m_timeframe,b) + iLow(this.m_symbol,this.m_timeframe,b))/2);
class CNewBar : public CObject
  {
private:
   string            m_symbol;
   ENUM_TIMEFRAMES   m_timeframe;
   datetime          m_time;
   double            m_pr_hl2[];
   datetime          Time(void);
   string            Symbol(void)         { return this.m_symbol;    }
public:
   ENUM_TIMEFRAMES   Timeframe(void)      { return this.m_timeframe; }
   datetime          GetTime(void)        { return this.m_time;      } //  Возвращает время последнего обращения
   int               PriceHL2(void);      
   bool              IsNewBar(void);                                   //  Основная функция класса
                     CNewBar(const string symbol,const ENUM_TIMEFRAMES timeframe);
                    ~CNewBar(void) {;}
  };
//+------------------------------------------------------------------+
//| Конструктор                                                      |
//+------------------------------------------------------------------+
CNewBar::CNewBar(const string symbol,const ENUM_TIMEFRAMES timeframe) : m_time(0)
  {
   this.m_symbol = symbol;
   this.m_timeframe = (timeframe == PERIOD_CURRENT ? Period() : timeframe);
   m_rt=this.RatesTotal();
   m_pc=0;
   PriceHL2();
  }
//+------------------------------------------------------------------+
//| CNewBar Time Возвращает время нулевого бара                      |SERIES_LASTBAR_DATE
//+------------------------------------------------------------------+
datetime CNewBar::Time(void)
  {
   datetime array[1], ret;
   ret = CopyTime(this.m_symbol, this.m_timeframe, 0, 1, array) == 1 ? array[0] : 0;
   return(array[0]);
  }

//+------------------------------------------------------------------+
//| Расчет цены                                                      |
//+------------------------------------------------------------------+
int CNewBar::PriceHL2(void)
  {
   int res=ArrayResize(this.m_pr_hl2,this.m_rt);
   for(int b=this.m_pc; b<this.m_rt; b++)
      m_pr_hl2[b]=MathAbs((iHigh(this.m_symbol,this.m_timeframe,b) + iLow(this.m_symbol,this.m_timeframe,b))/2);
   return(res);
  }
//+------------------------------------------------------------------+
//| CNewBar IsNewBar Основная функция класса                         |
//+------------------------------------------------------------------+
bool CNewBar::IsNewBar(void)
  {
   datetime tm=this.Time();
   if(tm==0)
      return false;
   if(tm!=this.m_time)
     {
      //--- определяем время
      this.m_time=tm;
      this.PriceHL2();
      return true;
     }
   return false;
  }
 
When you create an array for"intermediate calculations" of an indicator, you can just create it and everything works, or you can specify the INDICATOR_CALCULATION property.
What for? What are the possibilities?
 
Evgeny Dyuka #:
When you create an array for"intermediate calculations" of an indicator, you may create it and make everything work, or you may specify the INDICATOR_CALCULATION property.
What for? What are the possibilities?

If you have connected a dynamic array with an indicator buffer, the terminal will allocate memory for this array and the size of this array will be equal to the number of bars in a chart

this applies to both indicator buffers INDICATOR_DATA used for drawing and INDICATOR_CALCULATIONS - auxiliary buffers for calculations

 
Igor Makanu #:

If you have connected a dynamic array with an indicator buffer, the terminal will allocate memory for this array and the size of this array will be equal to the number of bars in a chart

this applies to both indicator buffers INDICATOR_DATA used for drawing and INDICATOR_CALCULATIONS - auxiliary buffers for calculations

Got it, thanks
 
Can you tell me if it is possible to magnetize graphical objects (trend lines, fibo grids) to indicators in the MT5 platform? For example, if the value of the fibo grid "0" is magnetised to the moving average. It just goes right into the moving average in pips.
 
A graphical object has to be fixed at a specific location on the graph window. For example a square in the bottom left corner. There is CHART_PRICE_MIN to define coordinate by Y, but how to define minimal time by X?
I didn't find anything suitable in ENUM_CHART_PROPERTY_INTEGER

or I will ask a wider question. How to correctly fix the position of an object in the chart window (e.g. "centered") without linking it to the chart itself?


 
There is a CHART_SCALEFIX_11 "1:1 scale mode" graph property and it is not disclosed what it is for and how to use it.
Is it to bind the sizes of graphical objects to the scale?
If yes, in what units and how to specify the object sizes.

In general, how to link drawing objects to the scale of the graphic?
 
Evgeny Dyuka #:
A graphical object has to be fixed at a specific location on the graph window. For example a square in the bottom left corner. There is CHART_PRICE_MIN to define coordinate by Y, but how to define minimal time by X?
I didn't find anything suitable in ENUM_CHART_PROPERTY_INTEGER

or I will ask a wider question. How to correctly fix the position of an object in the chart window (e.g. "centered") without linking it to the chart itself?


I really need this secret knowledge
 
Evgeny Dyuka #:
There is a CHART_SCALEFIX_11 "1:1 scale mode" graph property and it is not disclosed what it is for and how to use it.
Is it to bind the sizes of graphical objects to the scale?
If yes, in what units and how to specify the object sizes.

In general, how to associate drawing objects with the map scale correctly?
... and that too.
 
Evgeny Dyuka #:
It is necessary to fix the graphical object in a certain place of the chart window. For example, a square in the lower left corner. There is CHART_PRICE_MIN for Y coordinate but how can I know the minimum time by X?
I didn't find anything suitable in ENUM_CHART_PROPERTY_INTEGER

or I will ask a wider question. How to correctly fix the position of an object in the chart window (e.g. "centered") without linking it to the chart itself?


CHART_FIRST_VISIBLE_BAR

Number of the first visible bar on the chart. The indexing of the bars corresponds to the time series.

int r/o


But not all objects can be bound in this way.

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