share utility code - page 3 123 New comment [Deleted] 2014.03.18 18:37 #21 TIMisthebest: hi; below code can use for " send email & send massage to mobile & send sound and alarm " .i write below and use it in all my indicator. example : https://www.mql5.com/en/code/1868/34272#!tab=codeThanks.example link Does not work. Mehrdad Shiri 2014.03.20 07:31 #22 how to check automatically for any suffixes added to symbols in market watch, so indicator work on all broker's account type's ? . . . int total_symbol=0; // Number of symbols name on the server string empty_symbol="EMPTY"; string SYMBOLS_NAMES[SYMBOLS_COUNT]; . . . //************************************************************************* void OnInit() { SYMBOLS_NAMES[0]="EMPTY"; InitSymbolNames(); . . . } //+------------------------------------------------------------------+ 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 &TickVolume[], const long &Volume[], const int &Spread[]) { . . . InitSymbolNames(); . . . //--- done return(rates_total); } //+------------------------------------------------------------------+ void InitSymbolNames() { AddSymbolToMarketWatch(SYMBOLS_NAMES[1],"EUR","eur","GBP","gbp"); } //+------------------------------------------------------------------+ string AddSymbolToMarketWatch(string &name,string PART_1,string part_1,string PART_2,string part_2) { name=empty_symbol; // Symbol name total_symbol=SymbolsTotal(false); //--- Total symbols on the server //--- Iterate over the entire list of symbols for(int i=0;i<total_symbol;i++) { if( (SymbolInfoString(SymbolName(i,false),SYMBOL_CURRENCY_BASE)==PART_1&&SymbolInfoString(SymbolName(i,false),SYMBOL_CURRENCY_PROFIT)==PART_2) || (SymbolInfoString(SymbolName(i,false),SYMBOL_CURRENCY_BASE)==part_1&&SymbolInfoString(SymbolName(i,false),SYMBOL_CURRENCY_PROFIT)==part_2) ) { name=SymbolName(i,false); //--- If this symbol is available, SymbolSelect(name,true); //--- add it to the Market Watch window and return(name); //--- return its name break; } } return(name); } //********************************************************************************************************************& thanks for help noorad sharafi 2014.11.28 10:40 #23 Close all open position void CloseAllPosition(int magic) { while (checkOpenPosition(magic)) { for (int i = PositionsTotal()-1; i >= 0; i--) { if (PositionGetInteger(POSITION_MAGIC) == magic) { CTrade trade; trade.SetExpertMagicNumber(magic); trade.PositionClose(PositionGetSymbol(i)); } } } } bool checkOpenPosition(int magic) { for(int i=PositionsTotal()-1;i>=0;i--) { PositionSelect(PositionGetSymbol(i)); if (PositionGetInteger(POSITION_MAGIC) == magic) return(true ); } return(false); } 123 New comment
hi;
below code can use for " send email & send massage to mobile & send sound and alarm " .i write below and use it in all my indicator.
example : https://www.mql5.com/en/code/1868/34272#!tab=code
Thanks.
example link Does not work.
& thanks for help