SymbolSelect

마켓 워치(Market Watch) 창에서 심볼을 선택하거나, 창에서 심볼을 제거합니다.

bool  SymbolSelect(
   string  name,       // 심볼 이름
   bool    select      // 추가 또는 제거
   );

매개변수

이름

[in] 심볼 이름.

선택

[in] 스위치. 값이 false이면 MarketWatch에서 심볼을 제거하고, 그렇지 않으면 이 창에서 심볼을 선택해야 합니다. 심볼 차트가 열려 있거나 이 심볼에 대한 열린 위치가 있는 경우 심볼을 제거할 수 없습니다.

값 반환

실패 시 false를 반환.

예:

#define SYMBOL_NAME "GBPHKD"
 
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
  {
//--- 목록에 심볼이 있는지 확인하고 없으면 보고하고 작업을 완료합니다.
   bool custom = false;
   if(!SymbolExist(SYMBOL_NAMEcustom))
     {
      PrintFormat("'%s' symbol not found in the lists"SYMBOL_NAME);
      return;
     }
     
//--- 종합시세 창에 심볼 추가
   ResetLastError();
   if(!SymbolSelect(SYMBOL_NAMEtrue))
     {
      Print("SymbolSelect() failed. Error "GetLastError());
      return;
     }
//--- 목록에 심볼이 성공적으로 추가되면 종합시세 창에서 해당 심볼의 색인을 가져오고 결과를 저널에 보냅니다.
   int index = SymbolIndex(SYMBOL_NAME);
   PrintFormat("The '%s' symbol has been added to the MarketWatch list. Symbol index in the list: %d"SYMBOL_NAMEindex);
     
//--- 이제 종합시세 창에서 심볼을 제거합니다.
   ResetLastError();
   if(!SymbolSelect(SYMBOL_NAMEfalse))
     {
      Print("SymbolSelect() failed. Error "GetLastError());
      return;
     }
//--- 심볼이 목록에서 성공적으로 제거되면 Market Watch 창의 해당 심볼 인덱스는 -1이고 삭제 결과를 저널에 보냅니다.
   index = SymbolIndex(SYMBOL_NAME);
   PrintFormat("The '%s' symbol has been removed from the MarketWatch list. Symbol index in the list: %d"SYMBOL_NAMEindex);
   
   /*
  결과:
   The 'GBPHKDsymbol has been added to the MarketWatch listSymbol index in the list12
   The 'GBPHKDsymbol has been removed from the MarketWatch listSymbol index in the list: -1
   */
  }
//+------------------------------------------------------------------+
//| 종합시세 심볼 목록의 심볼 인덱스 반환                                        |
//+------------------------------------------------------------------+
int SymbolIndex(const string symbol)
  {
   int total = SymbolsTotal(true);
   for(int i=0i<totali++)
     {
      string name = SymbolName(itrue);
      if(name == symbol)
         return i;
     }
   return(WRONG_VALUE);
  }