스크립트: 노출

 

노출:

스크립트는 모든 오픈 포지션을 읽고 각 통화에 대한 총 자산 규모를 계산합니다.

Author: Ivan Ivanov

 
Automated-Trading:

노출:

저자: IvanBG

그리고 터미널에 모든 자산이 표시되는 준비 탭이 있을 때 이러한 스크립트가 필요한 이유입니다.

 
sergey1294:

그리고 모든 자산이 표시되는 터미널에 기성품 탭이있을 때 그러한 스크립트가 필요한 이유입니다.

저자의 생각을 모르겠습니다,

하지만 질문에 대한 답변으로 스크립트 코드를 사용하여 프로그래밍 방식으로이 정보를 얻을 수 있습니다,

탭에서 읽을 수 없습니다.

 
Urain:

작성자의 의도는 모르겠습니다,

하지만 질문에 대한 답변으로 스크립트 코드를 사용하여 프로그래밍 방식으로 이 정보를 얻을 수 있습니다,

탭에서 계산할 수 없습니다.

글쎄요,이 점에서 예제는 나쁘지 않습니다. 개발자가 이 탭에 대한 프로그래밍 액세스 권한을 부여하면 좋을 것 같습니다.
 
Urain:

작성자의 의도는 모르겠습니다,

하지만 질문에 대한 답변으로 스크립트 코드를 사용하여 프로그래밍 방식으로 이 정보를 얻을 수 있습니다,

탭에서 계산할 수 없습니다.

이 코드를 사용하여 다른 프로그램에 넣으면 됩니다.

그리고 터미널은 동일한 정보를 제공하지만 화면에서만 사용할 수 있지만 (프로그래밍 방식으로 읽을 수있는) 데이터로는 사용할 수 없습니다.

사실 제 프로그램에도 이 코드가 있습니다. 그리고 건너 뛰기는 아이디어를 전파하기 위해 만들어졌습니다.

 
IvanBG:

이 코드를 사용하여 다른 프로그램에 넣는다는 아이디어는 정확히 동일합니다.

그리고 터미널은 동일한 정보를 제공하지만 화면에서만 사용할 수 있지만 (프로그래밍 방식으로 읽을 수 있는) 데이터로는 사용할 수 없습니다.

사실 제 프로그램에도 이 코드가 있습니다. 그리고 스킵은 아이디어를 전파하기 위해서만 만들었습니다.

명확성을 위해 차트에 그래프가있는 표를 표시하면 더 예쁘게 보일 것입니다.
[삭제]  
sergey1294:
글쎄요,이 점에서 예제는 나쁘지 않습니다. 예, 개발자가 이 탭에 대한 프로그램 액세스 권한을 부여한다면 나쁘지 않을 것입니다.
+1
 

노출을 시작할 수 없습니다. MT5용 인디케이터의 가장 간단한 버전에서 매도 및 매수 횟수를 확인해야 합니다. 터미널과 사이트에서 별도로 다운로드하여 실행하려고 했는데 작업 필드에 표시되지 않습니다.

 

안녕하세요, 이 스크립트가 작동하지 않는 것 같습니다.


차트에 배치하면 즉시 제거되고 전문가 탭 아래에 다음과 같이 표시됩니다.

"2019.08.14 19:19:31.762 노출 (GBPUSD,H2) 배열 'exposure.mq5'(63,34)에서 범위를 벗어남 "


 
MT5 플랫폼과 호환되지 않음
 

오늘 이걸 발견했습니다. 누군가 Mt5로 변환했습니다. 그것을 만든 사람 감사합니다.

Mt5에서 작동합니다. 그리고 나는 그것을 수정하고 있습니다 . 완료되면 추가하겠습니다.

스크립트 : 아이익스포저 MT5.mq5

//+------------------------------------------------------------------+
//|iExposure.mq4 |
//| 저작권 2007-2014, MetaQuotes Software Corp. |
//| http://www.mql4.com |
//+------------------------------------------------------------------+
#property copyright "2007-2014, MetaQuotes Software Corp."
#property link      "http://www.mql4.com"
#property strict

#property indicator_separate_window
#property indicator_plots 0
#property indicator_buffers 1
#property indicator_minimum 0.0
#property indicator_maximum 0.1

#define  SYMBOLS_MAX 1024
#define  DEALS          0
#define  BUY_LOTS       1
#define  BUY_PRICE      2
#define  SELL_LOTS      3
#define  SELL_PRICE     4
#define  NET_LOTS       5
#define  PROFIT         6

input color InpColor=LightSeaGreen;  // 텍스트 색상

string ExtName="Exposure";
string ExtSymbols[SYMBOLS_MAX];
int    ExtSymbolsTotal=0;
double ExtSymbolsSummaries[SYMBOLS_MAX][7];
int    ExtLines=-1;
string ExtCols[8]= {"Symbol",
                     "Deals",
                     "Buy lots",
                     "Buy price",
                     "Sell lots",
                     "Sell price",
                     "Net lots",
                     "Profit",
                    };
int    ExtShifts[8]= { 10, 80, 130, 180, 260, 310, 390, 460 };
int    ExtVertShift=14;
double ExtMapBuffer[];
long chartid = 0;
//+------------------------------------------------------------------+
//| 사용자 지정 표시기 초기화 기능 |
//+------------------------------------------------------------------+
void OnInit()
  {
   IndicatorSetString(INDICATOR_SHORTNAME,ExtName);
   SetIndexBuffer(0,ExtMapBuffer,INDICATOR_CALCULATIONS);
   PlotIndexSetInteger(0,PLOT_DRAW_TYPE,DRAW_NONE);
   IndicatorSetInteger(INDICATOR_DIGITS,0);
   PlotIndexSetDouble(0,PLOT_EMPTY_VALUE,0.0);
  }
//+------------------------------------------------------------------+
//||
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
   int windex=ChartWindowFind(chartid,ExtName);
   if(windex>0)
      ObjectsDeleteAll(windex);

  }
//+------------------------------------------------------------------+
//| 사용자 지정 인디케이터 반복 함수|
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long& tick_volume[],
                const long& volume[],
                const int& spread[])
  {
   string name;
   int    i,col,line,windex=ChartWindowFind(chartid,ExtName);
//----
   if(windex<0)
      return(rates_total);
//---- 헤더 라인
   if(ExtLines<0)
     {
      for(col=0; col<8; col++)
        {
         name="Head_"+string(col);
         if(ObjectCreate(chartid,name,OBJ_LABEL,windex,0,0))
           {
            ObjectSetInteger(chartid,name,OBJPROP_XDISTANCE,ExtShifts[col]);
            ObjectSetInteger(chartid,name,OBJPROP_YDISTANCE,ExtVertShift);
            ObjectSetString(chartid,name,OBJPROP_TEXT,ExtCols[col]);
            ObjectSetString(chartid,name,OBJPROP_FONT,"Arial");
            ObjectSetInteger(chartid,name,OBJPROP_FONTSIZE,9);
            ObjectSetInteger(chartid,name,OBJPROP_COLOR,InpColor);
           }
        }
      ExtLines=0;
     }
//----
   ArrayInitialize(ExtSymbolsSummaries,0.0);
   int total=Analyze();
   if(total>0)
     {
      line=0;
      for(i=0; i<ExtSymbolsTotal; i++)
        {
         if(ExtSymbolsSummaries[i][DEALS]<=0)
            continue;
         line++;
         //---- 줄 추가
         if(line>ExtLines)
           {
            int y_dist=ExtVertShift*(line+1)+1;
            for(col=0; col<8; col++)
              {
               name="Line_"+string(line)+"_"+string(col);
               if(ObjectCreate(chartid,name,OBJ_LABEL,windex,0,0))
                 {
                  ObjectSetInteger(chartid,name,OBJPROP_XDISTANCE,ExtShifts[col]);
                  ObjectSetInteger(chartid,name,OBJPROP_YDISTANCE,y_dist);
                 }
              }
            ExtLines++;
           }
         //---- 설정 라인
         int    digits=(int)SymbolInfoInteger(ExtSymbols[i],SYMBOL_DIGITS);
         double buy_lots=ExtSymbolsSummaries[i][BUY_LOTS];
         double sell_lots=ExtSymbolsSummaries[i][SELL_LOTS];
         double buy_price=0.0;
         double sell_price=0.0;
         if(buy_lots!=0)
            buy_price=ExtSymbolsSummaries[i][BUY_PRICE]/buy_lots;
         if(sell_lots!=0)
            sell_price=ExtSymbolsSummaries[i][SELL_PRICE]/sell_lots;
         name="Line_"+string(line)+"_0";
           {
            ObjectSetString(chartid,name,OBJPROP_TEXT,ExtSymbols[i]);
            ObjectSetString(chartid,name,OBJPROP_FONT,"Arial");
            ObjectSetInteger(chartid,name,OBJPROP_FONTSIZE,9);
            ObjectSetInteger(chartid,name,OBJPROP_COLOR,InpColor);
           }
         name="Line_"+string(line)+"_1";
           {
            ObjectSetString(chartid,name,OBJPROP_TEXT,DoubleToString(ExtSymbolsSummaries[i][DEALS],0));
            ObjectSetString(chartid,name,OBJPROP_FONT,"Arial");
            ObjectSetInteger(chartid,name,OBJPROP_FONTSIZE,9);
            ObjectSetInteger(chartid,name,OBJPROP_COLOR,InpColor);
           }
         name="Line_"+string(line)+"_2";
           {
            ObjectSetString(chartid,name,OBJPROP_TEXT,DoubleToString(buy_lots,2));
            ObjectSetString(chartid,name,OBJPROP_FONT,"Arial");
            ObjectSetInteger(chartid,name,OBJPROP_FONTSIZE,9);
            ObjectSetInteger(chartid,name,OBJPROP_COLOR,InpColor);
           }
         name="Line_"+string(line)+"_3";
           {
            ObjectSetString(chartid,name,OBJPROP_TEXT,DoubleToString(buy_price,digits));
            ObjectSetString(chartid,name,OBJPROP_FONT,"Arial");
            ObjectSetInteger(chartid,name,OBJPROP_FONTSIZE,9);
            ObjectSetInteger(chartid,name,OBJPROP_COLOR,InpColor);
           }
         name="Line_"+string(line)+"_4";
           {
            ObjectSetString(chartid,name,OBJPROP_TEXT,DoubleToString(sell_lots,2));
            ObjectSetString(chartid,name,OBJPROP_FONT,"Arial");
            ObjectSetInteger(chartid,name,OBJPROP_FONTSIZE,9);
            ObjectSetInteger(chartid,name,OBJPROP_COLOR,InpColor);
           }
         name="Line_"+string(line)+"_5";
           {
            ObjectSetString(chartid,name,OBJPROP_TEXT,DoubleToString(sell_price,digits));
            ObjectSetString(chartid,name,OBJPROP_FONT,"Arial");
            ObjectSetInteger(chartid,name,OBJPROP_FONTSIZE,9);
            ObjectSetInteger(chartid,name,OBJPROP_COLOR,InpColor);
           }
         name="Line_"+string(line)+"_6";
           {
            ObjectSetString(chartid,name,OBJPROP_TEXT,DoubleToString(buy_lots-sell_lots,2));
            ObjectSetString(chartid,name,OBJPROP_FONT,"Arial");
            ObjectSetInteger(chartid,name,OBJPROP_FONTSIZE,9);
            ObjectSetInteger(chartid,name,OBJPROP_COLOR,InpColor);
           }
         name="Line_"+string(line)+"_7";
           {
            ObjectSetString(chartid,name,OBJPROP_TEXT,DoubleToString(ExtSymbolsSummaries[i][PROFIT],2));
            ObjectSetString(chartid,name,OBJPROP_FONT,"Arial");
            ObjectSetInteger(chartid,name,OBJPROP_FONTSIZE,9);
            ObjectSetInteger(chartid,name,OBJPROP_COLOR,InpColor);
           }
        }
     }
//---- 줄 제거
   if(total<ExtLines)
     {
      for(line=ExtLines; line>total; line--)
        {
         name="Line_"+string(line)+"_0";
         ObjectSetString(chartid,name,OBJPROP_TEXT," ");
         name="Line_"+string(line)+"_1";
         ObjectSetString(chartid,name,OBJPROP_TEXT," ");
         name="Line_"+string(line)+"_2";
         ObjectSetString(chartid,name,OBJPROP_TEXT," ");
         name="Line_"+string(line)+"_3";
         ObjectSetString(chartid,name,OBJPROP_TEXT," ");
         name="Line_"+string(line)+"_4";
         ObjectSetString(chartid,name,OBJPROP_TEXT," ");
         name="Line_"+string(line)+"_5";
         ObjectSetString(chartid,name,OBJPROP_TEXT," ");
         name="Line_"+string(line)+"_6";
         ObjectSetString(chartid,name,OBJPROP_TEXT," ");
         name="Line_"+string(line)+"_7";
         ObjectSetString(chartid,name,OBJPROP_TEXT," ");
        }
     }
//---- 최소값==최대값을 피하려면
   int bars=iBars(_Symbol,_Period);
   ExtMapBuffer[bars-1]=-1;
//----
   return(rates_total);
  }
//+------------------------------------------------------------------+
//||
//+------------------------------------------------------------------+
int Analyze()
  {
   double profit;
   int    i,index,total=PositionsTotal();
//----
   for(i=0; i<total; i++)
     {
      if(!PositionGetTicket(i))
         continue;
      if(PositionGetInteger(POSITION_TYPE)!=POSITION_TYPE_BUY && PositionGetInteger(POSITION_TYPE)!=POSITION_TYPE_SELL)
         continue;
      index=SymbolsIndex(PositionGetString(POSITION_SYMBOL));
      if(index<0 || index>=SYMBOLS_MAX)
         continue;
      //----
      ExtSymbolsSummaries[index][DEALS]++;
      profit=PositionGetDouble(POSITION_PROFIT)+PositionGetDouble(POSITION_SWAP)+AccountInfoDouble(ACCOUNT_COMMISSION_BLOCKED);
      ExtSymbolsSummaries[index][PROFIT]+=profit;
      if(PositionGetInteger(POSITION_TYPE)==POSITION_TYPE_BUY)
        {
         ExtSymbolsSummaries[index][BUY_LOTS]+=PositionGetDouble(POSITION_VOLUME);
         ExtSymbolsSummaries[index][BUY_PRICE]+=PositionGetDouble(POSITION_PRICE_OPEN)*PositionGetDouble(POSITION_VOLUME);
        }
      else
        {
         ExtSymbolsSummaries[index][SELL_LOTS]+=PositionGetDouble(POSITION_VOLUME);
         ExtSymbolsSummaries[index][SELL_PRICE]+=PositionGetDouble(POSITION_PRICE_OPEN)*PositionGetDouble(POSITION_VOLUME);
        }

     }
//----
   total=0;
   for(i=0; i<ExtSymbolsTotal; i++)
     {
      if(ExtSymbolsSummaries[i][DEALS]>0)
         total++;
     }
//----
   return(total);
  }
//+------------------------------------------------------------------+
//||
//+------------------------------------------------------------------+
int SymbolsIndex(string SymbolName)
  {
   bool found=false;
   int  i;
//----
   for(i=0; i<ExtSymbolsTotal; i++)
     {
      if(SymbolName==ExtSymbols[i])
        {
         found=true;
         break;
        }
     }
//----
   if(found)
      return(i);
   if(ExtSymbolsTotal>=SYMBOLS_MAX)
      return(-1);
//----
   i=ExtSymbolsTotal;
   ExtSymbolsTotal++;
   ExtSymbols[i]=SymbolName;
   ExtSymbolsSummaries[i][DEALS]=0;
   ExtSymbolsSummaries[i][BUY_LOTS]=0;
   ExtSymbolsSummaries[i][BUY_PRICE]=0;
   ExtSymbolsSummaries[i][SELL_LOTS]=0;
   ExtSymbolsSummaries[i][SELL_PRICE]=0;
   ExtSymbolsSummaries[i][NET_LOTS]=0;
   ExtSymbolsSummaries[i][PROFIT]=0;
//----
   return(i);
  }
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+