Мне нужно передавать из одного терминала МТ5 в другой, количество открытых позиций. На пример, из первого при помощи индикаторa.

MQL5 Indicateurs Experts Text writing

Tâche terminée

Temps d'exécution 1 jour
Commentaires du client
Alles TipTop
Commentaires de l'employé
Всё прошло успешно! Я рад сотрудничеству!

Spécifications

Мне нужно передавать из одного терминала МТ5 в другой, количество открытых позиций.
На пример, из первого при помощи индикаторы, через файл, и потом во втором терминале, функцией блоком в советнике, читать эти данные.

Привожу пример индикатора. Задача или исправить этот индикатор, или предлагать другой и другие решения. Спасибо.

#property indicator_chart_window
#property indicator_buffers 1
#property indicator_plots 1
//----- Indicator Parameters
//+------------------------------------------------------------------+
input string SubFolder = "MetaTrader 5";
//+------------------------------------------------------------------+
int Handle;
//---
int BearPositions;
int BullPositions;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit() {return(0);}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
  Comment("");
  Handle=FileOpen(SubFolder+"\\MQL5\\Files\\"+Symbol()+".csv",FILE_WRITE);
  Print(Symbol()+".csv"+" File Created: ",(bool)FileIsExist(SubFolder+"\\MQL5\\Files\\"+Symbol()+".csv"));
  FileClose(Handle);
  Print(Symbol()+".csv"+" File Deleted: ",(bool) FileDelete(SubFolder+"\\MQL5\\Files\\"+Symbol()+".csv"));
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,    // number of bars in history at the current tick
                const int prev_calculated,// number of bars calculated at previous call
                const datetime &time[],
                const double &open[],
                const double& high[],     // price array of maximums of price for the indicator calculation
                const double& low[],      // price array of minimums of price for the indicator calculation
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
{
//-----
  TotalPositions();
//-----
  Handle=FileOpen(SubFolder+"\\MQL5\\Files\\"+Symbol()+".csv",FILE_WRITE|FILE_SHARE_READ|FILE_ANSI,';');
  if(Handle!=INVALID_HANDLE)
  {
    FileWrite(Handle,BullPositions,BearPositions);
    FileClose(Handle);
    Comment("\n","\n","\n","\n","\n","\n","\n","\n","\n","\n",Symbol(),": ","Bull: ",(string)BullPositions,", Bear: ",(string)BearPositions);  
    //"\n","Ask: ",NormalizeDouble(SymbolInfoDouble(Symbol(),SYMBOL_ASK),_Digits),
    //"\n","Bid : ",NormalizeDouble(SymbolInfoDouble(Symbol(),SYMBOL_BID),_Digits));
  }
//-----
  else Print("File open Failed: "+SubFolder+"\\"+Symbol()+".csv, error",GetLastError());
//----- Done 
  return(rates_total);
}
//+------------------------------------------------------------------+
//| Bear Positions Counter                                           |
//+------------------------------------------------------------------+
void TotalPositions()
{
//-----
  int Cnt=0;
//-----
  BearPositions=0; BullPositions = 0;
//-----
  for(Cnt=PositionsTotal()-1;Cnt>=0;Cnt--)
  {
    if(PositionGetSymbol(Cnt)==_Symbol)
    {
       if(PositionGetInteger(POSITION_TYPE)==POSITION_TYPE_SELL && PositionGetDouble(POSITION_SL) == NULL)  BearPositions++;
       if(PositionGetInteger(POSITION_TYPE)==POSITION_TYPE_BUY  && PositionGetDouble(POSITION_SL) == NULL)  BullPositions++;
    }
  }
  return;
}
//+------------------------------------------------------------------+


Répondu

1
Développeur 1
Évaluation
(68)
Projets
78
27%
Arbitrage
13
31% / 62%
En retard
15
19%
Gratuit
Publié : 4 codes
2
Développeur 2
Évaluation
(32)
Projets
53
36%
Arbitrage
0
En retard
0
Gratuit
3
Développeur 3
Évaluation
(568)
Projets
642
40%
Arbitrage
2
100% / 0%
En retard
1
0%
Gratuit
Publié : 9 codes
4
Développeur 4
Évaluation
(83)
Projets
154
29%
Arbitrage
1
100% / 0%
En retard
27
18%
Gratuit
5
Développeur 5
Évaluation
(176)
Projets
228
19%
Arbitrage
20
40% / 20%
En retard
0
Occupé
6
Développeur 6
Évaluation
(1)
Projets
1
0%
Arbitrage
0
En retard
0
Gratuit
7
Développeur 7
Évaluation
Projets
0
0%
Arbitrage
0
En retard
0
Gratuit
8
Développeur 8
Évaluation
(361)
Projets
643
26%
Arbitrage
92
72% / 14%
En retard
12
2%
Travail
Publié : 1 code

Informations sur le projet

Budget
34+ USD
Délais
à 8 jour(s)