#define SYMBOL_NAME "GBPHKD"
//+------------------------------------------------------------------+
//| Script program start function |
//+------------------------------------------------------------------+
void OnStart()
{
//--- listelerde sembolün olup olmadığını kontrol et, bulunamazsa raporla ve çalışmayı tamamla
bool custom = false;
if(!SymbolExist(SYMBOL_NAME, custom))
{
PrintFormat("'%s' symbol not found in the lists", SYMBOL_NAME);
return;
}
//--- Piyasa Gözlemi penceresine sembol ekle
ResetLastError();
if(!SymbolSelect(SYMBOL_NAME, true))
{
Print("SymbolSelect() failed. Error ", GetLastError());
return;
}
//--- sembol listeye başarıyla eklenirse, Piyasa Gözlemi penceresinden indeksini al ve sonucu günlüğe gönder
int index = SymbolIndex(SYMBOL_NAME);
PrintFormat("The '%s' symbol has been added to the MarketWatch list. Symbol index in the list: %d", SYMBOL_NAME, index);
//--- şimdi sembolü Piyasa Gözlemi penceresinden kaldır
ResetLastError();
if(!SymbolSelect(SYMBOL_NAME, false))
{
Print("SymbolSelect() failed. Error ", GetLastError());
return;
}
//--- sembol listeden başarıyla çıkarılırsa, Piyasa Gözlemi penceresindeki indeksi -1 olur, silme sonucunu günlüğe gönder
index = SymbolIndex(SYMBOL_NAME);
PrintFormat("The '%s' symbol has been removed from the MarketWatch list. Symbol index in the list: %d", SYMBOL_NAME, index);
/*
sonuç:
The 'GBPHKD' symbol has been added to the MarketWatch list. Symbol index in the list: 12
The 'GBPHKD' symbol has been removed from the MarketWatch list. Symbol index in the list: -1
*/
}
//+------------------------------------------------------------------+
//| Piyasa Gözlemi sembol listesindeki sembol indeksini geri döndür |
//+------------------------------------------------------------------+
int SymbolIndex(const string symbol)
{
int total = SymbolsTotal(true);
for(int i=0; i<total; i++)
{
string name = SymbolName(i, true);
if(name == symbol)
return i;
}
return(WRONG_VALUE);
}
|