vps server - page 4

 
Subscribers:
and if there is no internet, there won't be any ticks. The OnTick function will not work ?
Also true. I am somehow fixated on the connection to the trade server. Of course you are right - no internet, no ticks - no one trades anywhere.
 
Vladimir Karputov:
Also correct. I'm somehow stuck on the connection to the trading server. Of course you're right - no internet, no ticks - no one trades anywhere.

Yes, thank you)

Another question. Can you tell me how to select from the history the orders of the last week ?

 
Subscribers:

Yes, thank you)

Another question. Can you tell me how to select the orders of the last week from the history?

Who uses orders now? It's better to analyse the trades. Here is an example of requesting trades from the history:

//+------------------------------------------------------------------+
//|                                         HistoryDealGetTicket.mq5 |
//|                        Copyright 2016, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2016, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.000"
#property script_show_inputs
//---
input datetime from_date=D'2016.09.20 11:11:00';
input datetime to_date=D'2016.09.20 11:40:00';
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
  {
   ulong deal_ticket;            // тикет сделки
   ulong order_ticket;           // тикет ордера,по которому была совершена сделка
   datetime transaction_time;    // время совершения сделки  
   long deal_type;              // тип торговой операции
   long deal_entry;              // направление сделки
   long position_ID;             // идентификатор позиции
   string deal_description;      // описание операции
   double volume;                // объем операции
   string symbol;                // по какому символу была сделка
                                 ////--- установим начальную и конечную дату для запроса истории сделок
//   datetime from_date=0;          // с самого начала
//   datetime to_date=TimeCurrent();// по текущий момент
//--- запросим историрю сделок в указанном интервале
   HistorySelect(from_date,to_date);
//--- общее количество в списке сделок
   int deals=HistoryDealsTotal();
//--- теперь обработаем каждую сделку
   for(int i=0;i<deals;i++)
     {
      deal_ticket=HistoryDealGetTicket(i);
      volume=HistoryDealGetDouble(deal_ticket,DEAL_VOLUME);
      transaction_time=(datetime)HistoryDealGetInteger(deal_ticket,DEAL_TIME);
      order_ticket=HistoryDealGetInteger(deal_ticket,DEAL_ORDER);
      deal_type=HistoryDealGetInteger(deal_ticket,DEAL_TYPE);
      deal_entry=HistoryDealGetInteger(deal_ticket,DEAL_ENTRY);
      symbol=HistoryDealGetString(deal_ticket,DEAL_SYMBOL);
      position_ID=HistoryDealGetInteger(deal_ticket,DEAL_POSITION_ID);
      deal_description=GetDealDescription(deal_entry,deal_type,volume,symbol,order_ticket,position_ID);
      //--- сделаем красивое форматирование для номера сделки
      string print_index=StringFormat("% 3d",i);
      //--- выведем информацию по сделке
      Print(print_index+": deal #",deal_ticket," at ",transaction_time,deal_description);
     }
  }
//+------------------------------------------------------------------+
//| Возвращает строковое описание операции                           |
//+------------------------------------------------------------------+
string GetDealDescription(long deal_entry,long deal_type,double volume,string symbol,long ticket,long pos_ID)
  {
   string descr;
//---
   switch(deal_entry)
     {
      case DEAL_ENTRY_IN:     descr="Вход в рынок, "; break;
      case DEAL_ENTRY_OUT:    descr="Выход из рынка, "; break;
      case DEAL_ENTRY_INOUT:  descr="Разворот, "; break;
      case DEAL_ENTRY_OUT_BY: descr="Закрытие встречной позицией, "; break;
     }
//---
   switch(deal_type)
     {
      case DEAL_TYPE_BALANCE:                  return ("balance");
      case DEAL_TYPE_CREDIT:                   return ("credit");
      case DEAL_TYPE_CHARGE:                   return ("charge");
      case DEAL_TYPE_CORRECTION:               return ("correction");
      case DEAL_TYPE_BUY:                      descr+="buy"; break;
      case DEAL_TYPE_SELL:                     descr+="sell"; break;
      case DEAL_TYPE_BONUS:                    return ("bonus");
      case DEAL_TYPE_COMMISSION:               return ("additional commission");
      case DEAL_TYPE_COMMISSION_DAILY:         return ("daily commission");
      case DEAL_TYPE_COMMISSION_MONTHLY:       return ("monthly commission");
      case DEAL_TYPE_COMMISSION_AGENT_DAILY:   return ("daily agent commission");
      case DEAL_TYPE_COMMISSION_AGENT_MONTHLY: return ("monthly agent commission");
      case DEAL_TYPE_INTEREST:                 return ("interest rate");
      case DEAL_TYPE_BUY_CANCELED:             descr+="cancelled buy deal"; break;
      case DEAL_TYPE_SELL_CANCELED:            descr+="cancelled sell deal"; break;
     }
   descr=StringFormat("%s %G %s (order #%d, position ID %d)",
                      descr,  // текущее описание
                      volume, // объем сделки
                      symbol, // инструмент сделки
                      ticket, // тикет ордера,вызвавшего сделку
                      pos_ID  // ID позиции, в которой участвовала сделка
                      );
   return(descr);
//---
  }
//+------------------------------------------------------------------+
Files:
 
Vladimir Karputov:

Who uses warrants nowadays? It is better to analyse the trades. Here is an example of requesting trades from history:


Thanks, but I need it on mql4. I don't want to switch to mql5 yet. Somehow I got used to MT4.
 
Subscribers:
Thanks, but I need to go to mql4. I don't want to switch to mql5 yet. I have somehow got used to MT4.
For lazybones and those who don't like progress:MQL4 and MetaTrader 4
 
Vladimir Karputov:
For lazy people and those who are alien to progress:MQL4 and MetaTrader 4
ahaha... Thank you. There are still a lot of people staying on MT4. Who likes what... I don't argue, there are useful features on MT5, but I don't like the fact that you can't open two different positions in different directions with different ticks on the same symbol.
 
Subscribers:
ahaha... thanks. There are still a lot of people staying on MT4. What anyone likes... I don't argue, there are useful features on MT5, but I don't like the fact that you can't open two different positions in different directions with different tickets on the same symbol.

Where does this nihilism come from? You need to open a MetaTrader 5 terminal before you can talk :). The MetaTrader 5 terminal has long had TWO types of trading accounts: netting and hedging (hedging being "two different positions in different directions with different ticks on the same symbol").

 
Vladimir Karputov:

Where does this nihilism come from? You need to open a MetaTrader 5 terminal before you can talk :). The MetaTrader 5 terminal has long had TWO types of trading accounts: netting and hedging (hedging being "two different positions in different directions with different ticks on the same symbol").

I didn't know about hedging. Thanks. I will have a look now.
 
Subscribers:
I didn't know about the hedge. Thank you. (chuckles) I'll take a look now.
How to open hedge accounts:hedge position accounting system,
 
Vladimir Karputov:
How to open hedge accounts:hedge position accounting system,

no "Use hedging" checkbox available ...( Maybe an old terminal?