Trouble detecting new orders and sending data with WebRequest

 

Hi everyone,

I’m just getting started with writing MQL4 Expert Advisors, and I’m working on one that sends a notification to a local server whenever a new trade opens. I have the server running at http://127.0.0.1:80 , and I’m using the WebRequest() function to send the data. The EA compiles fine and runs, but it doesn’t consistently detect and notify me about new orders.

So far, I’ve done the following:

  • I’m checking OrdersTotal() and comparing it to the previous count to see if a new order was added.
  • The local server is reachable at http://127.0.0.1:80 .
  • I’ve put in some Print() statements to confirm that the number of orders changes when I open a trade. The count goes up, but the EA still doesn’t reliably send the notification.

Since I’m new to this, I might be missing something simple. I’d really appreciate any advice or suggestions to help me make this work properly. Thanks!

 

Your topic has been moved to the section: MQL4 and MetaTrader 4
Please consider which section is most appropriate — https://www.mql5.com/en/forum/172166/page6#comment_49114893

When asking a question, if relevant, also include screenshots, log output, example code, etc.

If you show your attempts and describe your problem clearly, you will most probably receive an answer from the community.

Either attach the source file, or use the CODE button (Alt-S) when inserting code or log output

Code button in editor