Errors, bugs, questions - page 952

 

In the indicator, static variables are initialised when the TF is switched.

Is this the way it should be?

//+------------------------------------------------------------------+
//|                                                         Test.mq5 |
//+------------------------------------------------------------------+
#property indicator_chart_window
#property indicator_buffers 0
#property indicator_plots   0
static bool flag=true;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
   Print(flag);
   flag=false;
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const int begin,
                const double &price[])
  {
   return(rates_total);
  }
Документация по MQL5: Основы языка / Переменные / Статические переменные
Документация по MQL5: Основы языка / Переменные / Статические переменные
  • www.mql5.com
Основы языка / Переменные / Статические переменные - Документация по MQL5
 
Swan:

In the indicator, static variables are initialised when the TF is switched.

Is it supposed to be like this?

Yes, because according to the section Running Programs, indicators are always re-created when the symbol / timeframe is changed:

Loading and Unloading of Indicators

Indicators are loaded in the following cases

  • attaching the indicator to the chart;
  • start of the terminal (if an indicator was attached to a chart before the terminal was closed previously)
  • loading of a template (if an indicator is attached to a chart)
  • Profile change (if the indicator is attached to one of the profile charts);
  • change of the symbol and/or period of the chart, to which the indicator is attached;
  • after the successful recompilation of an indicator, if this indicator has been attached to a chart.
  • change of indicator input parameters.
 

While I'm waiting for an answer in SD(#693859) and not idle, maybe the MCs will respond here.

Will they enableSendFTP sending in indicators ?

There are alternative solutions, but this would be easier.

 
Karlson:

While I'm waiting for an answer in SD(#693859) and not idle, maybe the MCs will respond here.

Will they enable SendFTP sending in indicators ?

It is unlikely. Because the SendFTP function can inhibit the indicator runtime (one for all operations with the chart, in fact, it is an interface) for an indefinite time. We have said it many times before.
Документация по MQL5: Общие функции / SendFTP
Документация по MQL5: Общие функции / SendFTP
  • www.mql5.com
Общие функции / SendFTP - Документация по MQL5
 
Thank you for your reply.
 
Is it possible (and if so, how, because I couldn't find it) to remove an indicator placed in the market on a paid basis (which no one has bought yet) from the paid part of the market and publish it in the free part?
 
Question on CPositionInfo class. In MT5, only 1 position can be opened for a single instrument, which is the sum of all trades/positions taken. Can this class find the properties of (1) only this one final position or (2) can it find the properties of the individual trades/positions that make up this final position? If the answer to 2 is no, then tell me how the properties of the individual trades/positions can be found.
 
paladin800:
Question on CPositionInfo class. In MT5, only 1 position can be opened for a single instrument, which is the sum of all trades/positions taken. Can this class find the properties of (1) only this one final position or (2) can it find the properties of the individual trades/positions that make up this final position? If the answer to 2 is no, then tell me how to find the properties of the individual trades/positions.
This can be implemented by analysing the history of trades.
 
tol64:
This can be implemented by analysing the history of transactions.
I also thought about CDealInfo. I read the article How to Use the Standard Library Trade Classes when Writing an Expert Advisor, section 1.5, but somehow I don't understand how I can distinguish in the history the deals that have already closed from those that are still in the market (and which make up the current position). Or by its nature this class works only with unclosed trades?
 
paladin800:
I also thought about CDealInfo. I read the article How to Use the Standard Library Trade Classes When Writing an Expert Advisor, section 1.5, but somehow I don't understand how I can distinguish in the history trades that have already closed from those that are still in the market (and from which the current position consists). Or this class by its nature works only with deals that are not closed yet?
There are no "unclosed" deals. As soon as the trade is executed, it enters the history. We need to determine the time of the position opening and get the history from the time of the position opening, and then work only with deals that made this position. An article about this subject with many examples will be published soon.