MT5 e trans2quik.dll - pagina 14

 
prostotrader:

Allora aspetta che io entri nelle opzioni...

In questo momento li sto scambiando solo con le mani (aspettando le novità).

Ok, grazie.

 

Modificato SetTickers() per farlo funzionare più velocemente

//+------------------------------------------------------------------+
//| Set Tickers  function                                            |
//+------------------------------------------------------------------+
bool SetTickers()
{
  int s_total = SymbolsTotal(false);
  if(s_total > 0)
  {
    ArrayResize(qfs_data, s_total);
    int s_cnt = 0;
    ulong fut_exp;
    string fut_name, t_name, spot_name;
    ulong cur_time = ulong(TimeTradeServer());
    for(int i = 0; i < s_total;i++)
    {
      fut_name = SymbolName(i, false);
      fut_exp = GetExpiration(fut_name);
      if(fut_exp > ulong(cur_time))
      {
        for(int j = 0; j < ArraySize(enum_tikers);j++)
        {
          t_name = EnumToString(enum_tikers[j]);
          if(t_name != "")
          {
            if(StringFind(fut_name, t_name) > -1)
            {
              spot_name = GetSpot(t_name);
              if(spot_name != "")
              {
                s_cnt++;
                qfs_data[s_cnt - 1].tiker = fut_name;
                qfs_data[s_cnt - 1].base_tiker = spot_name;
                if(SymbolSelect(fut_name, true) != true) return(false);
                if(SymbolSelect(spot_name, true) != true) return(false);
                break;
              }  
            }
          }
        }
      }
    }
    if(s_cnt > 0)
    {
      ArrayResize(qfs_data, s_cnt);
      return(true);
    }  
  }
  return(false);
}
 

Mentre non c'è la possibilità di fare altre cose, ho deciso di

Per continuare il mio lavoro su MT5 --> Quik

Ho trovato una soluzione per scrivere un robot su MT5 e dare ordini di trading a Quik.

Il robot in MT5 funzionerà con futures o azioni.

E anche futures di lavoro congiunto - azioni.

Per lavorare abbiamo bisogno di un conto reale FORTS (MT5) e l'EBS con Quick in qualsiasi broker.

Approssimazione del "pesce" dell'Expert Advisor

//+------------------------------------------------------------------+
//|                                                     MT5_quik.mq5 |
//|                                      Copyright 2020 prostotrader |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2020 prostotrader"
#property link      "https://www.mql5.com"
#property version   "1.00"
//---
#define  RET_ERROR  -1
//---
struct INIT_QUIK
{
  uchar tr2q_path[100];
  uchar fut_class_code[20];
  uchar fut_symb_code[20];
  uchar fut_account[20];
  uchar spot_class_code[20];
  uchar spot_symb_code[20];
  uchar spot_account[20];
};
struct BOOK_DATA
{
  double price;
  long   volume;
};
struct MARKET_DATA
{
  BOOK_DATA fut_sell;
  BOOK_DATA fut_buy;
  BOOK_DATA spot_sell;
  BOOK_DATA spot_buy;
};
//---
input string QDll    = "D:\\Program Files\\QUIK-Junior"; //Путь к rtans2quik.dll
input string FClCode = "SPBFUT";                         //Код класса фьючерса
input string FSCode  = "SRU0";                           //Код символа фьючерса
input string FAcc    = "SPBFUT00064";                    //Номер счета фьючерса;
input string SClCode = "TQBR";                           //Код класса СПОТа
input string SSCode  = "SBER";                           //Код символа СПОТа
input string SAcc    = "NL0011100043";                   //Номер счета СПОТа;
//---
#import "MT5_to_Quik.dll"
  int InitQuik(INIT_QUIK &a_str);                                                              
  int SetFutOrder(const double price, const long volume, const int ord_type, ulong &ticket);    
  int SetSpotOrder(const double price, const long volume, const int ord_type, ulong &ticket);
  int RemoveFutOrder(const ulong ticket);
  int RemoveSpotOrder(const ulong ticket);
  int ModifyFutOrder(const double price, const long volume, ulong &ticket);
  int ModifySpotOrder(const double price, const long volume, ulong &ticket);
#import
//---
INIT_QUIK init_quik;
MARKET_DATA m_data;
bool fut_book, spot_book;
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
{
  int result = StringToCharArray(QDll, init_quik.tr2q_path);
  if(result > 0)
  {
    result = StringToCharArray(FClCode, init_quik.fut_class_code);
    if(result > 0)
    {
      result = StringToCharArray(FSCode, init_quik.fut_symb_code);
      if(result > 0)
      {
        result = StringToCharArray(FAcc, init_quik.fut_account);
        if(result > 0)
        {
          result = StringToCharArray(SClCode, init_quik.spot_class_code);
          if(result > 0)
          {
            result = StringToCharArray(SSCode, init_quik.spot_symb_code);
            if(result > 0)
            {
              result = StringToCharArray(SAcc, init_quik.spot_account);
            }
          }
        }
      }
    }
  }
  result = InitQuik(init_quik);
  if(result == RET_ERROR) return(INIT_FAILED);
//---
  fut_book = MarketBookAdd(Symbol());
  if(SymbolSelect(SSCode, true) == true)
  {
    spot_book = MarketBookAdd(SSCode);
  }
  else
  {
    Print("SPOT not selected!");
    return(INIT_FAILED);
  }  
  return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
  if(fut_book == true) MarketBookRelease(Symbol());
  if(spot_book == true) MarketBookRelease(SSCode); 
}
//+------------------------------------------------------------------+
//| Expert Get Book function                                         |
//+------------------------------------------------------------------+
bool GetBook(const string a_symbol)
{
  MqlBookInfo book_data[];
  bool is_found = false;
  if(MarketBookGet(a_symbol, book_data) == true)//getBook )
  {
    int size = ArraySize(book_data);
    if(size > 2)                                //Sell price exists
    {
      for(int i = 0; i < size; i++)
      {
        if(book_data[i].type == BOOK_TYPE_BUY) 
        {
          if(a_symbol == Symbol())
          {
            m_data.fut_buy.price = book_data[i].price;
            m_data.fut_sell.price = book_data[i-1].price;
            m_data.fut_buy.volume = book_data[i].volume;
            m_data.fut_sell.volume = book_data[i-1].volume;
          }
          else
          if(a_symbol == SSCode)
          {
            m_data.spot_buy.price = book_data[i].price;
            m_data.spot_sell.price = book_data[i-1].price;
            m_data.spot_buy.volume = book_data[i].volume;
            m_data.spot_sell.volume = book_data[i-1].volume;
          }
          return(true);
        }
      }  
    }  
  } 
  return(false);
}
//+------------------------------------------------------------------+
//| Expert Book Event function                                       |
//+------------------------------------------------------------------+
void OnBookEvent(const string &symbol)
{
  if((symbol == Symbol()) || (symbol == SSCode)) 
  {
    if(GetBook(Symbol()) == true)
    {
      if(GetBook(SSCode) == true)
      {
        //TODO YOU TS
      }
    }
  }  
}
//+------------------------------------------------------------------+
 
prostotrader:

Mentre non c'è la possibilità di fare altre cose, ho deciso di

Per continuare il mio lavoro su MT5 --> Quik

Ho trovato una soluzione per scrivere un robot su MT5 e dare ordini di trading a Quik.

Il robot in MT5 funzionerà con futures o azioni.

E anche futures di lavoro comuni - azioni.

Per lavorare abbiamo bisogno di un conto reale FORTS (MT5) e l'EBS con Quick in qualsiasi broker.

Approssimazione del "pesce" dell'Expert Advisor

Buon lavoro!

Cosa può fare un pesce? :)

È possibile ottenere informazioni sul mercato attraverso la biblioteca?

Più commenti, per favore, nel codice!
 
Aleksey Vyazmikin:

Buon affare!

Cosa possono fare i pesci? :)

È possibile ottenere informazioni sul mercato attraverso la biblioteca?

Più commenti, per favore, nel codice!

Non c'è ancora nulla da spiegare, ho un problema con gli ordini pendenti perché non ci sono callback in MT5.

Voglio avere ordini pendenti nel mio arsenale.

Документация по MQL5: Константы, перечисления и структуры / Торговые константы / Свойства ордеров
Документация по MQL5: Константы, перечисления и структуры / Торговые константы / Свойства ордеров
  • www.mql5.com
Приказы на проведение торговых операций оформляются ордерами. Каждый ордер имеет множество свойств для чтения, информацию по ним можно получать с помощью функций Идентификатор позиции, который ставится на ордере при его исполнении. Каждый исполненный ордер порождает сделку, которая открывает новую или изменяет уже существующую позицию...
 
prostotrader:

Non c'è ancora nulla da spiegare, c'è un problema con gli ordini pendenti, non ci sono callback in MT5.

e vogliamo avere ordini pendenti.

Le callback possono essere organizzate attraverso OnChartEvent, è possibile inviare una pressione di tasti da delphi al grafico MT.

 
Sergey Chalyshev:

Le callback possono essere organizzate tramite OnChartEvent, potete anche inviare una pressione di tasti sul grafico MT da delphi.

Ciao Seryozh.

Grazie, lo proverò.

E lei ha un esempio?

 
prostotrader:

Ciao, Seryozh.

Grazie, farò una prova.

Ha un esempio?

Non ho nessuna soluzione pronta, ho appena provato, non riesco a trovare un esempio in questo momento, forse più tardi.

Guarda qui per ora.

Обмен данными между советниками
Обмен данными между советниками
  • 2019.03.31
  • www.mql5.com
Есть ли возможность обмена данными между двумя советниками, которые работают одновременно с двумя разными инструментами...
 

Ho dimenticato di prendere il deposito da Quick, quindi.... Ho rinunciato a questo.

 
prostotrader:

Ho dimenticato di prendere il deposito da Quick, quindi.... Ho rinunciato a questo.

Ebbene da QUIK è possibile inviare le informazioni richieste tramite file, come opzione.

Motivazione: