Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 1100

 
Hello, colleagues!

I havea question while programming: Is there any way to get the server time accurate to milliseconds in the EA?
For example, get: 23.09.2016 14h. : 53 min. : 54000 milliseconds? That is exactly 54 seconds, 000 milliseconds.
 
e-partner:
Hello colleagues!

I havea question while programming: Is it possible to get somehow in the Expert Advisor the time of the server with an accuracy of milliseconds?
For example, get: 23.09.2016 14h. : 53 min. : 54000 milliseconds? That is exactly 54 seconds, 000 milliseconds.

Interesting question. What do you mean, specify the last known time of the server, the time of the last quote TimeCurrent() or the current time on the server?

If it is TimeCurrent(), what will be the use, if we consider that a packet with a new quote goes through the internet from the server to the terminal for 10-500 ms and this time varies from packet to packet. Besides, it is not clear, what is the arrival of the last quote, if it comes to the server from several sources, liquidity providers, and then it is processed, and then the server sends a new tick. Also, it is not known how the server's system timer is synchronised with astronomical time. On 09.01.2014 from 04:15 to 06:15 MSK (Thursday, trading day) I was finding this out, as the deviation is not from astronomical, but from the average for 31 companies. The figure for 25 time points shows these deviations (in seconds, not ms):

And what is the point of figuring out anything in milliseconds from the data from the server?

The second option is clearer. If your computer is in sync with the astronomical time with an accuracy that you know, the astronomical time in the city where the server is running is known with the same accuracy. But why do you need it...

 

I can't figure out where the optimisation has gone from the strategy tester. Checks are all standing I can not understand anything. MT4 build 1010. Windows 8.1.

Please advise how to enable the optimization.

I will attach screenshots. I cannot see the optimization button.

Files:
desktop.zip  129 kb
 
Why does my MT4 b1010 not allow debugging on historical data (button and menu item is not active)? In MT5 everything is ok.
 
Because the developers have forbidden it.
 
int Magik;
int Slippage = 5,stopL1 = 50,takeP1 = 20;
int trend,TicketS,TicketB;
double rsi,TP,SL;
//+------------------------------------------------------------------+
//| Expert initialisation function |
//+------------------------------------------------------------------+
int OnInit()
{
if(Digits == 3 || Digits == 5)
{
Slippage *= 10;
stopL1 *= 10;
{ takeP1 *= 10;
}

return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{

}
//+------------------------------------------------------------------+
//| expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
double priseBuy = FindLastOrderPrise (OP_BUY);
double priseSel = FindLastOrderPrise (OP_SELL);
double frezeelevl = MarketInfo(OrderSymbol(),MODE_FREEZELEVEL);
rsi = iRSI(Symbol(),PERIOD_D1,7,PRICE_CLOSE,0);
trend = WhatTrend();
if (CountTrades() == 0)
{
if(trend == 1 && rsi <=30)
{
if(OrderSend(Symbol(),OP_BUYLIMIT,0.10,Ask,Slippage,0,0, "first buy order set",Magik,0)== true)
{
TicketB = FindLastTicket(OP_BUY);
if(TicketB >0)
{
SL = priseBuy + NormalizeDouble(takeP1 * Point,Digits);
TP = priseBuy - NormalizeDouble(stopL1 * Point,Digits);
if(OrderModify(TicketB,priseBuy,SL,TP,0)== true)
Comment("hooraaaahhhh");
}

}
}// if(trend == 1 && rsi <= 30)
else if(trend == 2 && rsi >= 70)
{
if(OrderSend(Symbol(),OP_SELLLIMIT,0.10,Bid,Slippage,0,0, "first order set",Magik,0)== true)
{
for(int i = OrdersTotal()-1;i >0;i--)
{
OrderSelect(i,SELECT_BY_TICKET,MODE_TRADES);
if (OrderType()== OP_SELL && OrderMagicNumber() == Magik)
{
double sl = OrderOpenPrice() + NormalizeDouble(stopL1 * Point,Digits);
double tp = OrderOpenPrice() - NormalizeDouble(takeP1 * Point,Digits);
if(OrderModify(OrderTicket(),OrderOpenPrice(),sl,tp,0)==true)break;
else continue;
}
}
}
}
}// (CountTrades() == 0)

}

I'm asking competent programmers to explain what my mistake is?! Why the order is not modified!!! and the compiler does not give out errors while doing so

 
I have studied the tutorial.I have read and taken notes...could you point out errors specifically...because the compiler gives no errors and there are no errors in the tester.but the order is not modified.as if the order is not visible in the program at all
 
burbur87:
I've studied the tutorial.I've read and taken notes.Could you point out the errors specifically...because the compiler doesn't give out any errors and there are no errors in the tester.But the order is not modified.It's like the order is not seen in the program at all

Read carefully what OrderSend() returns

 if(OrderSend (Symbol(),OP_SELLLIMIT,0.10,Bid,Slippage,0,0,"первый ордер сел установлен",Magik,0) > 0)

Actually, I would do the following:

   int ticket=OrderSend (Symbol(),OP_SELLLIMIT,0.10,Bid,Slippage,0,0,"первый ордер сел установлен",Magik,0);
   if(ticket>=0)
      {
        if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES))
          {
            if (OrderStopLoss()==0 || OrderTakeProfit()==0)
             {
               double sl = OrderOpenPrice() + NormalizeDouble(stopL1 * Point,Digits);
               double tp = OrderOpenPrice() - NormalizeDouble(takeP1 * Point,Digits);
               if(!OrderModify(OrderTicket(),OrderOpenPrice(),sl,tp,0)) Print("Error ",GetLastError()," modify order ",ticket);
             }
          }
      }
 
Sepulca:

Read carefully what OrderSend() returns

if(ticket>=0)

In fact, I would do it like this:

Can a ticket be zero?
 
AlexeyVik:
Can a ticket be equal to zero?

From the documentation about OrderSend():

.......

Return value

Returns the ticket number assigned to the order by the trade server or -1 in case of failure. To get the error information, call GetLastError().