88 lines
		
	
	
		
			No EOL
		
	
	
		
			4 KiB
		
	
	
	
		
			MQL5
		
	
	
	
	
	
			
		
		
	
	
			88 lines
		
	
	
		
			No EOL
		
	
	
		
			4 KiB
		
	
	
	
		
			MQL5
		
	
	
	
	
	
#property strict
 | 
						|
 | 
						|
#include "String.mqh"
 | 
						|
 | 
						|
// https://www.mql5.com/ru/forum/317893/page3#comment_55114508
 | 
						|
struct SYMBOL_BASE // pack(4)
 | 
						|
{
 | 
						|
  static const int DigitsCurrency;
 | 
						|
 | 
						|
  int SymbolID;
 | 
						|
 | 
						|
  STRING Symbol;
 | 
						|
 | 
						|
  double Point;
 | 
						|
  int Digits;
 | 
						|
 | 
						|
  double TickValue;
 | 
						|
 | 
						|
  double TickSize;
 | 
						|
/*
 | 
						|
  double SwapLong;
 | 
						|
  double SwapShort;
 | 
						|
 | 
						|
  double CommissionKoef;
 | 
						|
*/
 | 
						|
  void SetSymbol( string sSymb = NULL )
 | 
						|
  {
 | 
						|
    if (sSymb == NULL)
 | 
						|
      sSymb = _Symbol;
 | 
						|
 | 
						|
    this.SymbolID = 0;
 | 
						|
    this.Symbol = sSymb;
 | 
						|
 | 
						|
    this.Point = ::SymbolInfoDouble(sSymb, SYMBOL_POINT);
 | 
						|
    this.Digits = (int)::SymbolInfoInteger(sSymb, SYMBOL_DIGITS);
 | 
						|
 | 
						|
    if (false) // Режим прибыли в валюте.
 | 
						|
    {
 | 
						|
      this.TickSize = ::SymbolInfoDouble(sSymb, SYMBOL_TRADE_TICK_SIZE);
 | 
						|
      this.TickValue = ::SymbolInfoDouble(sSymb, SYMBOL_TRADE_TICK_VALUE);
 | 
						|
    }
 | 
						|
    else // Режим прибыли в пипсах.
 | 
						|
    {
 | 
						|
      this.TickSize = this.Point;
 | 
						|
      this.TickValue = 1;
 | 
						|
    }
 | 
						|
 | 
						|
    // https://www.mql5.com/ru/forum/282062/page80#comment_57515249
 | 
						|
    if (!this.TickSize)
 | 
						|
      this.TickSize = 1;
 | 
						|
 | 
						|
    this.TickValue /= this.TickSize;
 | 
						|
/*
 | 
						|
    this.SwapLong = ::SymbolInfoDouble(sSymb, SYMBOL_SWAP_LONG);
 | 
						|
    this.SwapShort = ::SymbolInfoDouble(sSymb, SYMBOL_SWAP_SHORT);
 | 
						|
 | 
						|
    this.CommissionKoef = 0;
 | 
						|
*/
 | 
						|
    return;
 | 
						|
  }
 | 
						|
 | 
						|
  void operator =( string sSymb )
 | 
						|
  {
 | 
						|
    this.SetSymbol(sSymb);
 | 
						|
 | 
						|
    return;
 | 
						|
  }
 | 
						|
 | 
						|
  string GetSymbol( void ) const
 | 
						|
  {
 | 
						|
    return(this.Symbol.Get());
 | 
						|
  }
 | 
						|
 | 
						|
  bool IsCorrect( void ) const
 | 
						|
  {
 | 
						|
    return((this.Point > 0) && (this.TickValue > 0) && (this.TickSize > 0));
 | 
						|
  }
 | 
						|
};
 | 
						|
 | 
						|
#ifdef ORDER_CURRENCY_DIGITS
 | 
						|
  static const int SYMBOL_BASE::DigitsCurrency = ORDER_CURRENCY_DIGITS;
 | 
						|
#else // #ifdef ORDER_CURRENCY_DIGITS
 | 
						|
  #ifdef __MQL5__
 | 
						|
    static const int SYMBOL_BASE::DigitsCurrency = (int)::AccountInfoInteger(ACCOUNT_CURRENCY_DIGITS);
 | 
						|
  #else // #ifdef __MQL5__
 | 
						|
    static const int SYMBOL_BASE::DigitsCurrency = 2;
 | 
						|
  #endif // #ifdef __MQL5__ #else
 | 
						|
#endif // #ifdef ORDER_CURRENCY_DIGITS #else |