1.3) Advanced MQL Techniques - Coding a Multi-Symbol Expert Advisor (EA) for MetaTrader 5

Поделиться
HTML-код
  • Опубликовано: 14 дек 2024

Комментарии • 38

  • @bengoodall
    @bengoodall 4 года назад +3

    This is very timely as I'm trying to convert my MT4 EAs across to MT5 at the moment. It seems from the forums that there are a number of different ways of approaching the multi-currency problem. It seems a lot of effort is required to deal with the difference between receiving ticks on the symbol to which the EA is attached vs receiving ticks from other symbols. I am looking forward to going through your code in detail to see how you've dealt with it (I can't see a link yet?). Thank you for sharing I'm finding all your content very helpful. Indeed, the videos on optimization have inspired me to move to MT5 for more robust multi-currency analysis! :)

    • @martyntinsley
      @martyntinsley 4 года назад +6

      Hi Ben. You make a good point about receiving ticks. I intentionally keep this out of this particular episode since I felt it would complicate the message. So I focussed on making a multi-symbol EA using the ticks of the current chart only, to drive the OnTick() function. Unless you are dealing with HFT or time-sensitive scalping strategies, the differences are likely to be extremely negligible anyway. If you put your EA on a very liquid asset such as EURUSD, you are going to receive in the region of 100-200 ticks per minute anyway during the major trading sessions, so missing ticks from other symbols is fairly unlikely, and when it does happen it isn't likely to cause any issues. Remember if it takes longer to run through each iteration of the EA than successive ticks, MT5 will miss out interim ticks anyway, and there's absolutely nothing you can do about that (other than making your code as efficient as possible to reduce the frequency of this happening). So it's probably not worth worrying overly about IMO. If you are only processing ticks say once per minute (as I do), then the impact of the issue is lessened even further, although you will then need to control bar opening for each symbol (which I do). I will do a future session on how to manage this so hopefully, this will help. I'll look to get the code up in the next few days :)

    • @bengoodall
      @bengoodall 4 года назад +1

      @@martyntinsley Good points there. I think I might be trying to over-engineer things. I'm certainly not looking at HFT trading and in fact trade on much higher TFs, so maybe I can get away with using ticks from a liquid asset as the trigger, then a simple New Bar test for each symbol. Look forward to seeing the code :) Thanks.

    • @martyntinsley
      @martyntinsley 4 года назад +2

      Apologies for the delay Ben. The code can now be found here: The code sample(s) for this episode can be found at github.com/darwinex/advanced-mql-programming

    • @bengoodall
      @bengoodall 4 года назад

      @@martyntinsley Thanks for sharing. I will take a look.

    • @DG10-youtube-channel
      @DG10-youtube-channel 4 года назад

      @@bengoodall How can I test for New bars in other symbols?

  • @algui91
    @algui91 2 года назад +1

    I'm so grateful you made this! Just what I was looking for. Now I have a starting point to move my EAs to run on multiple symbols.
    BTW: Just discovered your channel and directly subscribed to it. Keep up the great job!

  • @aaronvillegas1098
    @aaronvillegas1098 4 года назад +4

    Now how do we actually run a backtest with our new EA? Can you please instruct on what inputs to use?

    • @TradeLikeAMachine
      @TradeLikeAMachine 4 года назад +2

      Hi Aaron. To run a multi-symbol EA backtest you simply need to specify the symbols you want to use as the value for the 'TradeSymbols' input param, making sure you delimit them with a pipe (|). Alternatively, select a param value of "ALL" to test on all of the predefined symbols. Hope I understood your question properly.

    • @helpstatistica-15
      @helpstatistica-15 7 месяцев назад

      @@TradeLikeAMachine Hi Thanks, and which symbol do we have to specify in the box "Symbol" of the tester? One of them or All symbol of MarketWatch?

  • @jayajayasinghe7155
    @jayajayasinghe7155 3 года назад +2

    Excellent set of videos. Very informative as well as timely for me. Thanks very much.
    BTW, I have a question on multi symbol EAs. I have a couple of MT5 EAs that I would like to convert to multi symbol format. I presume the EA will receive ticks only from the symbol of the chart in which the EA is placed. However, my EA needs ticks from all charts to determine the opening of the new bar in each symbol. How can you achieve this?

  • @coffeeaddict7652
    @coffeeaddict7652 4 года назад +2

    Awesome Video. Helped me very much. Have a nice day!

  • @josebelda1181
    @josebelda1181 4 года назад +2

    Thanks so much Martyn for this helpful explanation for your model to go on multisymbol, actually I was start working on something similar, for my EA and will be amazing could test your code on my EA. Appreciate if you can share the link. Thanks

    • @Darwinexchange
      @Darwinexchange  4 года назад

      Glad it helped

    • @martyntinsley
      @martyntinsley 4 года назад

      Thanks for the feedback. I'm arranging the upload of the code now. I'll update the description once done so that you can access it.

    • @martyntinsley
      @martyntinsley 4 года назад

      Apologies for the delay Jose. The code can be found here: The code sample(s) for this episode can be found at github.com/darwinex/advanced-mql-programming

    • @josebelda1181
      @josebelda1181 4 года назад

      @@martyntinsley No worries can understand. Thanks for this great explanation.

  • @mohsenjashni
    @mohsenjashni 3 года назад +2

    Thanks for this great tutorial

  • @kellyphilip2451
    @kellyphilip2451 2 года назад +1

    Kindly make a multisymbol backtesting tutorial

  • @alfredpeddington9959
    @alfredpeddington9959 3 года назад +3

    Hello, thank you for your amazing content! By the way, I have one problem with this: when I was testing your Multi Symbol code with the MT5 strategy tester, the test result was not the same if I change Symbol in the setting menu. Do you know why? I guess it might be because of the difference in the number of ticks. For example, if I set Symbol to EURUSD, I would have 24367 ticks with 2154 trades. But if I set Symbol to GBPJPY I get 24452 ticks with 2328 trades. (The input of the symbol was both set to ALL. )

    • @lucasnotini1717
      @lucasnotini1717 2 года назад

      Hello Alfred, did you get to understand how to correct this? I'm facing the exact same issue when testing multi symbols. When I change the main symbol on the strategy tester the results change, even though everything in the code is using the multi symbol array

  • @quarthaz
    @quarthaz 3 года назад +1

    Hello, words can't express how much you help me! I do have one question (Maybe it was discussed somewhere else but I couldn't find it) when using my Multi-symbol EA and optimize using Open Price Only method, some currency pairs are trading one candle later after the signal has been give. How do I make it that it trades only within the first ticks of each currency pair?

  • @unknown_traveller
    @unknown_traveller 4 года назад +1

    Hello, thank you for this great Tutorial! I have a question: I would like to add a mechaniscm so that the check for opening trades is done when a new candle appears, so just one check per candle. How would I do this?

    • @martyntinsley
      @martyntinsley 4 года назад

      Thanks for the feedback. I have now produced an episode that answers your question. You can find it here: ruclips.net/video/dRRY_WIXKRg/видео.html

  • @skhumbuzocele1330
    @skhumbuzocele1330 2 года назад +1

    how to apply this technic in Mql4?

    • @Darwinexchange
      @Darwinexchange  2 года назад

      Hi Skhumbuzo. Although MT4 supports multi symbols in 'live trading' mode, the MT4 Strategy Tester is not capable, I'm afraid. For multi-symbol backtesting, the only option is to upgrade to MT5.

    • @skhumbuzocele1330
      @skhumbuzocele1330 2 года назад

      @@Darwinexchange ......I got an array out of range error.... trying to implement this code in Mt4

  • @ronanronan9500
    @ronanronan9500 2 года назад

    Thanks for your content! Is it possible to use MarketBookGet in a multi symbol expert advisor ? I noticed that this function returns data for every symbols I want even when no new data arrives (because ontick function is called when new tick of the symbol the EA is placed, not other symbol i want to use). If i want to compute bar volume (real volume or tick volume) I have to compare new data with previous data to not add the volume or use already added bid/ask.

    • @Darwinexchange
      @Darwinexchange  2 года назад

      As you have stated, your OnTick() code will only run when a new tick is received on the chart that the EA is running on. This means that you shouldn't be attempting to manually calculate cumulative volume - even for the chart symbol, you'd still miss ticks (if for example a tick arrives while the EA is still processing). Instead you should let the platform do the hard work for you and use iVolume or CopyTickVolume instead. Hope this helps. Martyn

  • @shahinsinv
    @shahinsinv 4 года назад +1

    Thank's How can we use it to code for trade

    • @martyntinsley
      @martyntinsley 4 года назад +1

      Hi Arvind. The code is meant to illustrate how to adapt your own trading EA and give it a multi-symbol capability. So it assumes you already have an EA. I might do more episodes in the future that cover subjects such as trade execution/management.

  • @Terence01
    @Terence01 4 года назад +2

    Awesome I can't thank you enough for this wonderful code! Maybe we can make the backtest faster using multi-threading (one thread per symbol). I will give it a try, you open a new door to me.

    • @martyntinsley
      @martyntinsley 4 года назад +2

      It's my pleasure :)

    • @massimilianorinaudo209
      @massimilianorinaudo209 4 года назад +1

      @@martyntinsley Hi mister Tinsley, can you please help me to use my EA with your amazing code? i'm trying a lot of times but i'm not able to fix it. I'm not a programmer, i'm just a trader that work with mt5. Normally i code with a software but in the time i studyed some stuff of mqls and now i'm able to do easy things but not this. Please help me if you can. Let me know how to contact you. Have a nice day

  • @leonjbr
    @leonjbr 4 года назад +1

    Hi Martyn. Have you posted the link to your github? I cant see it.

    • @martyntinsley
      @martyntinsley 4 года назад

      Hi Leon. This is in the comments above. It's the 3rd link down

    • @leonjbr
      @leonjbr 4 года назад

      @@martyntinsley Ok thanks

  • @myownbusiness2242
    @myownbusiness2242 3 года назад

    hi may I know what if i want to optimise the parameter in multiple symbol tester for each symbol respectively?
    For example :
    Pairs to trade : EURUSD, GBPUSD, USDJPY
    Parameters to Optimize : MA(Period), BB(Period), SL (pip), TP(pip)
    As if according to the framework above, the optimisation results will generate a list of many possible combination
    For eg :
    EURUSD, MA(PERIOD)20, BB(Period)20, SL(15), TP(30)
    EURUSD, MA(PERIOD)30, BB(Period)59, SL(15), TP(50)
    GBPUSD, MA(PERIOD)20, BB(Period)20 SL(15), TP(30)
    GBPUSD, MA(PERIOD)30, BB(Period)59, SL(15), TP(50)
    But the thing is, i just only need one best configuration for each respective trading pair only, how can i do so? thanks