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

MQL5 지표 전문가 Text writing

작업 종료됨

실행 시간 1 일
고객의 피드백
Alles TipTop
피고용인의 피드백
Всё прошло успешно! Я рад сотрудничеству!

명시

Мне нужно передавать из одного терминала МТ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;
}
//+------------------------------------------------------------------+


응답함

1
개발자 1
등급
(68)
프로젝트
78
27%
중재
13
31% / 62%
기한 초과
15
19%
무료
게재됨: 4 코드
2
개발자 2
등급
(32)
프로젝트
53
36%
중재
0
기한 초과
0
무료
3
개발자 3
등급
(568)
프로젝트
642
40%
중재
2
100% / 0%
기한 초과
1
0%
무료
게재됨: 9 코드
4
개발자 4
등급
(83)
프로젝트
154
29%
중재
1
100% / 0%
기한 초과
27
18%
무료
5
개발자 5
등급
(176)
프로젝트
228
19%
중재
20
40% / 20%
기한 초과
0
바쁜
6
개발자 6
등급
(1)
프로젝트
1
0%
중재
0
기한 초과
0
무료
7
개발자 7
등급
프로젝트
0
0%
중재
0
기한 초과
0
무료
8
개발자 8
등급
(361)
프로젝트
643
26%
중재
92
72% / 14%
기한 초과
12
2%
작업중
게재됨: 1 코드

프로젝트 정보

예산
34+ USD
기한
 8 일