Code optimization EA

 
Hello, I wrote an expert that has no logic errors and works in the backtest. The execution speed limit in the code below runs with a delay of 3 to 5 candles. I would be grateful if someone could answer the following questions.

According to the code and skin image given, is there a way to reduce this delay in the operation?

void CheckForSignal()

{

//---

      double Up = iCustom(_Symbol,PERIOD_CURRENT,"SSL3_1",3,0);

      double Down = iCustom(_Symbol,PERIOD_CURRENT,"SSL3_1",4,0);

      double Up1 = iCustom(_Symbol,PERIOD_CURRENT,"ec-a",0,0);

      double Down1 = iCustom(_Symbol,PERIOD_CURRENT,"ec-a",1,0);    

     if(Up != EMPTY_VALUE && Up1 != EMPTY_VALUE  )

     {           

      if((Close_Opposite_Signal && OpenOrders(OP_SELL) > 0) )

         CloseTrade(OP_SELL);

      if((!Hedging && OpenOrders(OP_SELL) == 0 && OpenOrders(OP_BUY) == 0) || Hedging )

         EnterTrade(OP_BUY);            

     }

     else if (Down != EMPTY_VALUE && Down1 != EMPTY_VALUE)

     {

      if((Close_Opposite_Signal && OpenOrders(OP_BUY) > 0)  )

         CloseTrade(OP_BUY);

      if((!Hedging && OpenOrders(OP_BUY) == 0 && OpenOrders(OP_SELL) == 0) || Hedging )

         EnterTrade(OP_SELL);   

     }     

}



Битва за скорость: QLUA vs MQL5 - почему MQL5 быстрее от 50 до 600 раз?
Битва за скорость: QLUA vs MQL5 - почему MQL5 быстрее от 50 до 600 раз?
  • www.mql5.com
Для сравнения языков MQL5 и QLUA мы написали несколько тестов, которые замеряют скорость выполнения базовых операций. В тестах использовался компьютер с Windows 7 Professional 64 bit , MetaTrader 5 build 1340 и QUIK версии 7.2.0.45.
Files:
Capture.PNG  25 kb
 
shahram jafari: . The execution speed limit in the code below runs with a delay of 3 to 5 candles. I would be grateful if someone could answer the following questions.

According to the code and skin image given, is there a way to reduce this delay in the operation?

  1. Why did you post your MT4 question in the MT5 General section instead of the MQL4 section, (bottom of the Root page)?
              General rules and best pratices of the Forum. - General - MQL5 programming forum? (2017)
    Next time, post in the correct place. The moderators will likely move this thread there soon.

  2. Do you really expect an answer? There are no mind readers here and our crystal balls are cracked, so we can't see your machine.
         How To Ask Questions The Smart Way. (2004)
              Be precise and informative about your problem

    Always post all relevant code (using Code button) or attach the source file.

  3. You posted a function. Any delay is because of your delay in calling it. Or it is because you are looking at the forming candle instead of the just completed one.

    Use the debugger or print out your variables, including _LastError and prices and find out why. Do you really expect us to debug your code for you?
              Code debugging - Developing programs - MetaEditor Help
              Error Handling and Logging in MQL5 - MQL5 Articles (2015)
              Tracing, Debugging and Structural Analysis of Source Code - MQL5 Articles (2011)
              Introduction to MQL5: How to write simple Expert Advisor and Custom Indicator - MQL5 Articles (2010)