Arrays.... - page 2

 
lippmaje:
Most of the cycles will be used by iCustom. Try to minimze the calls to it.

Thanks Lippmaje, but there are 13 iCustom calls and they are only called once... so essentially that would not make a difference

 

Without code it's just speculation, as you see. You can profile your code by counting how many ticks have passed:

uint ticks=GetTickCount();
...code to profile
ticks=GetTickCount()-ticks;
Print("code used ",ticks," ticks");

If it's below ~16 you need to scale it up (call the code in a for loop or so) to get more precise figures.

And using NULL instead of Symbol() is a tad faster.

Code profiling - Developing programs - MetaTrader 5
Code profiling - Developing programs - MetaTrader 5
  • www.metatrader5.com
Profiling means collecting program parameters during its execution. During a profiling, the execution time and the number of calls of individual functions and program code lines are measured. With this tool, the programmer is able to find and optimize the slowest code sections. Profiling can be performed on the normal chart of the trading...
 
lippmaje:

Without code it's just speculation, as you see. You can profile your code by counting how many ticks have passed:

If it's below ~16 you need to scale it up (call the code in a for loop or so) to get more precise figures.

And using NULL instead of Symbol() is a tad faster.

Thanks for the info... I'll have a good look at it...

 
  1. Mike Tanton: but there are 13 iCustom calls and they are only called once... so essentially that would not make a difference

    They are not called once, or else the EA would never open orders (except perhaps on initial tick.) They are called per bar or per tick. We can't see your broken code.


  2. Mike Tanton: Is it better (faster) to structure - getting -the values of my Global Variables like this:


    Array_1[15,1];

    Array_1[i,0] = iCustom(Symbol(),0,Etc1.,0,i);

    Value_1 = Array_1[i,0];

    Stop capitalizing Global Variables. That is the name of Global Variables of the Terminal

  3. Please edit your (original) post and use the CODE button (Alt-S)! (For large amounts of code, attach it.)
              General rules and best pratices of the Forum. - General - MQL5 programming forum
              Messages Editor

  4. You aren't using the arrays except for intermediate storage. Not in loops. No need for them.
    Value_1 = iCustom(Symbol(),0,Etc1.,0,i);
    

  5. But again, you don't care about a few milliseconds. Your CPU usage is elsewhere. We can't see your broken code.

    EAs : Don't do per tick that you can do per bar, or on open.
    If you are waiting for a level, don't reevaluate, wait until price reaches it (or a new bar starts and you recalculate.)
    If you are waiting for an order to open or close, only look when OrdersTotal has changed.
              How to get backtesting faster ? - MT4 - MQL4 programming forum


  6. lippmaje:
    uint ticks=GetTickCount();
    ...code to profile
    ticks=GetTickCount()-ticks;
    Print("code used ",ticks," ticks");
    The editor → debug has its own profiler.

  7. lippmaje: And using NULL instead of Symbol() is a tad faster.
    Agree. Don't use NULL.
    • You can use NULL in place of _Symbol only in those calls that the documentation specially says you can. iHigh does, iCustom does, MarketInfo does not. OrderSend does not.
    • Don't use NULL (except for pointers where you explicitly check for it.) Use _Symbol and _Period, that is minimalist as possible and more efficient.
    • Zero is the same as PERIOD_CURRENT which means _Period. Don't hard code numbers.
    • MT4: No need for a function call with iHigh(NULL,0,s) just use the predefined arrays, i.e. High[].