Any tips for a faster executing EA?
Page 1 of 612 12 LastLast
Results 1 to 10 of 12

Thread: Any tips for a faster executing EA?

  1. #1
    Howdy,

    I had been wondering if anyone would have the ability to provide some hints or suggestions for how to make your code perform faster please. I am not trying to construct a HFT algo so real-time execution is secondary (but of course always a bonus). Instead, I'm trying to cut down the egy tester time between each pass.
    This may have clear benefits for time utilisation when running a large optimisation (because I am).

    I'm working within the MetaTrader surroundings but welcome conversation with any language that someone might use.
    I have these ideas that we are already implementing:

    MetaTrader 5 (64 bit and uses all of cores)
    stronger CPU (within ones budget)
    The use of Integers
    Object Orientated Programming (I'm not 100% about this but it seem logical that a range of smaller amount .mqh documents is going to be faster than one gigantic .mq5 document - ideas?)

    Any other hints?

    Thanks very much!

  2. #2
    Thank You for the clarifiion.

    I don't have any background in computers but have been teaching myself programming for a while today, so there'll be large phases of my computer science understanding overlooking. Sorry if this was a clear mistake.

    Searching for good habits to pick up, eager to find out.

  3. #3
    Quote Originally Posted by ;
    Thanks for the clarifiion. that I don't have any background in computers but've been teaching myself programming for a while today, so there will be large chapters of my personal computer science understanding overlooking. Sorry if this was a clear mistake. Looking for good habits to select up, eager to find out.
    Increasing calculation energy is the very last measure you should take. In optimizing the calculations, the true calculation reduction comes. You can see the impact of algorithm optimization really well if you try to calculate a Fibonacci number iterative vs recursive. One of these takes.The mql4/5 editor has a build in profiling tool which should provide you a basic understanding about which part of the algorithm takes a long time. How frequently does your code execute? Is it really essential for every tick to be mimicked or is it sufficient to test only the pub opening? This will give you a reduction in backtesting time. Is there large portions of the code which do not need to be implemented over and over again? Would you compose a simply if check and disregard a lot of calculations every cycle? Micro optimization (if you really want that last bit mql4 can do) like mapping frequently used values instead of calculating them over and over again. Buffer loop conditional variables. I think local factors are somewhat quicker as well as international range. So you're able to save a fraction of a moment there. Employing little shift instead of branch. Try to steer clear of modulo etc.... However, this is kind of overkill for you I guess.

  4. #4
    Hello,

    Out of what I know:

    MT5 multicore could be okay, but you need to program so. That means dividing your code in threads that can execute concurrently.

    More powerfull CPU, yes, that will accelerate your execution time, but if your transmission period (internet) is slow that has no sense.

    Use of integers? I don't know this, you want to convert doubles to integers and vice-versa? The conversion period will make you lose the gain of using them unless you create quite heavy calculations.

    OOP, no, that allows just to decode the code, the resulting binary isn't faster than procedural code. And the duration of header files or having multiple header files rather than one large has nothing to do with execution speed.

    BT

  5. #5
    Quote Originally Posted by ;
    Thank You for the clarifiion. that I have no background in computers but've been teaching myself programming for a while now, so there'll be large phases of my personal computer science knowledge overlooking. Sorry if this was an obvious mistake. On the lookout for good habits to select up, keen to find out.
    I don't know a lot about MQL, I just got into it on the weekend. I've got a lot of knowledge about other languages however. The matter is: design languages aren't created for computers, they are made for humans. The computer reads a translated version - generated by the compiler. The compilers output hasn't too much resemblance with what you see in your editor. The compiler will change (Boost ) a lot, such as inlining of code which then will make the code even larger instead of smaller.

    General information: Do not go for the micro optimization until your code really works. It is a waste of time. Tackle the total program structure, logic and your calculations (in case you heavily rely upon those). Just by taking a look at the construction of an EA for example it's quite apparent that to much (unnecessary) computation in OnTick() is a bad idea as that routine is called very frequently.

  6. #6
    Quote Originally Posted by ;
    quote Increasing calculation power is the very last measure you should take. The true calculation decrease comes in optimizing the algorithms. You may observe the effect of algorithm optimization quite well if you try to calculate a Fibonacci number iterative vs recursive. One of these takes minutes the other one just miliseconds. The mql4/5 editor has a built-in tool which should give you a basic understanding about which portion of the algorithm requires quite a while. How often does your code execute? Is it really important for every tick to...
    Hi Kilian,
    Thank you for the reply.
    Iterative vs recursive Fibonacci: Never heard of this and is something I'll continue reading up on. Found some things on stackoverflow.
    Mql5 editor profiling tool: Not something I have used previously, found a few posts on it and reading about it today. Obvious solution, thank you!
    OnTick: I have been very mindful of the and attempted to maintain majority of tasks OnBar but yes one of the transaction types is OnTick that is eating away at processing time. This looks like a few low hanging fruit.
    Portions of the code being executed over and over again? : This is not a area I have considered much and will research. I believe you're correct there should be a few fantastic efficiency available here.
    Micro optimization: Love the suggestions and when I get that far I will definitely try anything (great for my learning no matter ).

    Much appreciated.

  7. #7
    Quote Originally Posted by ;
    Hello, From what I know: MT5 multicore may be okay, but you will need to program so. That usually means dividing your code in threads that can execute concurrently. Much more powerfull CPU, yes, that may accelerate your implementation time, but if your transmission period (net ) is slow which has no sense. Use of integers? I don't know this, you would like to convert doubles to integers and vice-versa? The conversion period will make you eliminate the gain of using them if you don't make quite heavy calculations. OOP, no, which allows only to reorganize...
    Hey Broketrader,

    MT5 multicoreI never realised that it is possible to separate your code into various threads like that. This may make a impact. Currently you get the advantage of multicore when conducting the optimiser. (which is an epic difference over mt4).
    CPU: Im considering obtaining a new machine currently. The new Haswell chips look pretty slick. Internet connection speed isn't an issue. I am just concentrated on the code implementing.
    Integers: I could be completely wrong but with my limited comprehension Integers are easier for a machine to compute than say a Dual. E.g. only function in pips or _Points when calculating things like stops and goals. Not considering converting integers and pops back and forth.
    Int StopLoss = 300; // StopLoss at _Points
    unable to be carried out everywhere, exactly where the chance presents itself.

    Thanks for all your input it's greatly appreciated.

  8. #8
    Quote Originally Posted by ;
    quote I don't know a lot about MQL, I just got to it on the weekend. I have a lot of knowledge about other languages though. The matter is: design languages are not made for computers, they are made for humans. The computer reads a translated version - generated by the compiler. The compilers output hasn't too much resemblance with what you see in your editor. The compiler will change (Boost ) a lot, such as inlining of code which then is likely to make the code even larger rather than smaller. General advice: Do not go for the micro blogging...
    Thanks for the general information. I will do that. Tackle the larger problem (structure, calculations and logic ) and then work my way down to the micro level.
    OnTick() seems like a fantastic place to begin for easy gains.

    New to mql? Best in your trading to you! If you are familiar with programming in general you should churn through mql pretty fast. Mql4 is certainly the flavour of selection, but if you know your things go directly to mql5. The benefits in analyzing eat any advantage that mql4 could provide. Its a tired old horse and everybody keeps on flogging it.

  9. #9
    I see windows task manager, I saw mt4 only can utilize 25 CPU in maximum, then, mt4 stucked.
    The way to boost% use of CPU for mt4 in order to mt4 conduct fast, no stucked?

  10. #10
    Quote Originally Posted by ;
    I see windows task manager, I saw mt4 just may use 25 CPU in maximum, then, mt4 stucked. The way to increase% usage of CPU for mt4 in order to mt4 run quickly, no stucked?
    I figure you have a quad core PC - in that case 25 percent equates to 100% of a single core. To benefit from several cores an appliion has to be designed for multi threading (parallel implementation ) so there's likely nothing you can do on your end.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
This website uses cookies
We use cookies to store session information to facilitate remembering your login information, to allow you to save website preferences, to personalise content and ads, to provide social media features and to analyse our traffic. We also share information about your use of our site with our social media, advertising and analytics partners.