Using the OnTrade event in MQL4

Поділитися
Вставка
  • Опубліковано 17 вер 2024
  • MQL5 includes an OnTrade event that fires when a trade change happens. This code will show you how to implement something similar in MQL4
    Downloading the code
    The code shown in the video is available to our premium discord members. Premium membership is a monthly subscription. To join our discord server and download this and other code
    orchardforex.c...
    Free downloads for Metatrader 4 and 5
    MT4: www.orchardfor...
    MT5: www.orchardfor...
    Follow our regular market updates:
    Web: www.orchardfor...
    Twitter: / orchardforex
    Facebook: / orchardforex-327549444...
    Telegram: t.me/orchardforex
    Discord: / discord

КОМЕНТАРІ • 27

  • @lorenzocoletta8028
    @lorenzocoletta8028 3 роки тому +2

    Amazing video! Waiting for the part 2 where you explain how the class can return to the user an information about what parameters changed (stop loss, new trade etc).

  • @AlexTechie
    @AlexTechie 2 роки тому +1

    Another great video, I love how you delve into advanced concepts.

  • @chrischannel3250
    @chrischannel3250 2 роки тому

    25:50 Yes, I would like You to create a follow-up video showing more functionality of the StartScan. Thank You for a present video, very useful.

  • @hamzavictor2385
    @hamzavictor2385 3 роки тому

    As usual, thank you. Very educating content.

  • @eTaupe
    @eTaupe Рік тому

    Very good subject
    Dying to see the next step: extracting changes.
    And how you will manage a situation where N orders placed on other instruments are executed
    How you will retrieve and sort the events

    • @OrchardForex
      @OrchardForex  Рік тому

      You probably want this. ua-cam.com/video/T0IcIIVaMT8/v-deo.html

  • @sankohm99
    @sankohm99 3 роки тому

    Thanks. Excellent info!

  • @marvin1507able
    @marvin1507able 3 місяці тому

    Very nice tutorial! Just a short question. Since, as you mentioned, the OnTick function only fires the scan if there actually is a tick, it can lead to delays. How about a bool variable "running" set to true in OnInit and false in OnDeinit and a while(running) loop in the OnTick Function with a call of Sleep(100) at the end of the loop. So the scan would be fired every 100ms. May this removes the delay?

  • @ssj4vrn
    @ssj4vrn 11 місяців тому +1

    Is there a corresponding ontrade video for MT5?I could not find any

  • @johnskinner3145
    @johnskinner3145 3 роки тому

    Thank you

  • @Macam2macam
    @Macam2macam 3 роки тому

    thanks sir.

  • @sleepingpanda7931
    @sleepingpanda7931 3 роки тому

    BEAUTIFULL:)

  • @00GRILL
    @00GRILL Рік тому +1

    HI, very nice video.
    i have replicated the content and i get message windows Something Happened. How i can show content of the operation i made ?
    Thank's a lot

    • @OrchardForex
      @OrchardForex  Рік тому

      I can't help without full detail of the error. If this is a windows error then you may have a problem with your MT installation. If not then you should include the actual error message from MT. All I can suggest is to remove code and see what happens, then add code back gradually until you find the problem.

    • @00GRILL
      @00GRILL Рік тому

      @@OrchardForex
      No the question is not related to an error. Like in your example I get the correct message box with something happen. So is working. The question was … how I can get the detailed operation I made in mt4 for example in that message box or with a print.
      Always thanks for you answer

    • @OrchardForex
      @OrchardForex  Рік тому +1

      @@00GRILL The id argument is the code for the event that triggered the OnChartEvent. sparam is the name of the object involved. You have to work out the details from there.

  • @Dan_s_Channel
    @Dan_s_Channel 2 роки тому

    Thanks for the tutorial. In MT4 I receive an error message by dropping the EA on the chart: OnTradeTest EURUSD,M5: incorrect start position 0 for ArraySort function. Thanks for help.
    I found the reason by myself. The Error appears if there is no order available. OrdersTotal() is 0! A simple if-statement before filling the array fixes the issue.
    A following video would be great!

    • @OrchardForex
      @OrchardForex  2 роки тому

      The error doesn't stop the EA running. There is already a follow up video but not about this. Sorry about the first response, I had a trade and didn't notice.

  • @totetronico
    @totetronico 3 роки тому

    Thanks a lot Sir, better a 100 lot ;), I was wondering if in qml4 is possible to Drag a Button by only holding click. and not like the way 2click select drag of the ornidary objects(lines etc)

    • @OrchardForex
      @OrchardForex  3 роки тому

      I've nver done this but you could try detecting the mouse down event and mouse release and just move the button in code. The double click is only there to first select the object, avoids accidental changes that way, so you could also just programatically make your objects already selected.

  • @mohammadahmed5047
    @mohammadahmed5047 3 роки тому

    Great Stuff.. Would you like to give me example what we can achieve onTrade event

    • @OrchardForex
      @OrchardForex  3 роки тому +2

      You would probably use this to manage trades, for example to take action when a stop order converts to a trade or when a take profit or stop loss is hit.

  • @yougchee9418
    @yougchee9418 3 роки тому

    If I made EA which opens a buy position like at 2 and stop loss 1 , if the candle do a rapid pull down and hit stop loss and drag it to the end of candle and increase it, how can I write extra code to enforce the stop loss not to be moved down or dragged down in anyway during rapid pulldown

    • @OrchardForex
      @OrchardForex  3 роки тому

      In short you can't. As a not recommended option you would have to not use the stop loss but instead write your own code to close the trade and set slippage to prevent the price moving too far. But this does not force the trade to close where you want it. If the price moves past the allowed slippage the trade is simply not closed and you are left with a losing trade.