Welcome to Forex-TSD!, one of the largest Forex forums worldwide, where you will be able to find the most complete and reliable Forex information imaginable.
From the list below, select the forum that you want to visit and register to post, as many times you want. It’s absolutely free. Click here for registering on Forex-TSD.
Exclusive Forum
The Exclusive Forum is the only paid section. Once you subscribe, you will get free access to real cutting-edge Trading Systems (automated and not), Indicators, Signals, Articles, etc., that will help and guide you, in ways that you could only imagine, with your Forex trading.
Elite Section
Get access to private discussions, specialized support, indicators and trading systems reported every week.
Advanced Elite Section
For professional traders, trading system developers and any other member who may need to use and/or convert, the most cutting-edge exclusive indicators and trading systems for MT4 and MT5.
is it possible make mt4 dll connected to web service and make php script to shows MT4 open position through a website , so people with no MT4 can see it from website in a realtime ?
Someone posted a while ago a MQL / MySQL example which worked great, the only issue with it is that most hosting companies do not allow remote access to their database servers. However if you did have full access and control to your server you would write an EA which would connect to your database and insert the data for each new order. Then from your website simply connect to the database and read the data ... In my opinion this would be the best approach.
Now a MT4 DLL can connect to a php script but I have never tried to pass the information from the EA to the Website, I was able to successfully do it the other way around though ... You would have to look into windows sockets, and functions such as HTTP_GET / HTTP_POST.
//+------------------------------------------------------------------+ // CountAll | //+------------------------------------------------------------------+ int CountAll() { int count=0; for(int i = OrdersTotal()-1; i >=0; i--) { OrderSelect(i,SELECT_BY_POS,MODE_TRADES); int OrdMag = OrderMagicNumber(); int OrdNum = OrderTicket();
however I do want to be able to interact with MT - to send the tick and candle info to the .net app and this app communicate back to MT on when to trade.
I found this that I thought may help - Simplified Wrapper and Interface Generator
However I am a rather entry level programmer, and dont fully appreciate what is involved in having a c++ wrapper middle layer.
I would be interested to hear your opinion, if you think this could be a useful tool to use to help bridge between the c++ and .net?
You can certainly wrap a c# dll and get it to receive signals on MT4, however I am not sure about sending the price data from MT4 to the C# app/dll and how reliable it would be ... I don't really have time to investigate right now ( going on vacation next week and have to finish some projects :P ) but I will certainly try to look into that in the next few months
I have an external DLL that I've written in C++. However, I'm still quite new to C++, so I think that might be why I'm having this problem. I have another version I've written in C# that works fine, except to make C# DLLs callable by MQL I have to alter them, and this alteration appears to cause small memory leaks. I'm hoping someone here can help me out with the C++ version. Here's the story:
I've been slowly developing various libraries for programming trading strategies. One of the things I'm trying to do is develop a consistent set of services for various things like logging, locking (thread-safe access to resources), and event notification. So basically, I'm trying to pull MQL up by its bootstraps into a more modern programming paradigm. Anyway, currently I'm working on a library that will allow EAs to receive notification of various trade events (placed, filled, closed). These events could be as a result of trades taken by the event-subscribing EA or from other EAs. To accomplish this, I'm using an external DLL that basically facilitates communication between EAs via message passing. There is a publishing EA that just looks for new trade events and when one occurs, it puts a message onto a queue for the subscribing EA (each subscriber has its own queue).
So the problem is this...As long as it's only one message being passed at a time, all works fine. Obviously that's not acceptable at all though. When more than one message is passed at a time, what I'm finding is that the first message gets corrupted (it keeps returning the message as "1" when instead it should be something like "FILLED,1005167"). The second message is fine, but the first is not. I haven't tested more than two messages yet, but presumably we'd still see the same thing.
I'd love it if someone knew the answer to what it is I'm doing wrong and could shed some light on my problem. A few notes: 1) I'm eventually going to be releasing this code under Apache 2.0 and so this source file is also being put out there under Apache 2.0...I intend to release this to the community when it's working fairly smoothly. 2) I've repeatedly said 'queue' here, but if you look at the source code you'll see me using a vector instead, and basically using it like a stack. Originally I had a queue, but changed it to a vector just on the off-chance that I was doing something wrong with the STL queue that I wasn't aware of. No such luck. The real implementation will be a queue, but for now neither queue nor vector are working correctly for me.
Since I was here, I thought I'd share my experience. What you are wanting to do can certainly be done, and I've done it many times myself.
When I first started writing DLLs for use in MT4 I couldn't ever get it to work in C++. I think the problem was/is that my project settings were always incorrect in Visual Studio (there's so d@$% many of them). Just recently I found an example from CodeGuru, which I was actually able to compile and use. Now I basically cleaned out that project and use it as a template.
In the meantime, I've been writing C# DLLs and using this excellent tool here. It basically takes the IL and alters it so that it can be called from unmanaged code. The only problem is that MT4 seems to exhibit a memory leak when doing this. I haven't definitively determined if that's due to MT4 or the altering of the IL, or what, but it happens.
Next I'll either be learning to write wrappers on C++ and/or just go ahead and learn C++. Hopefully that will address the memory issue.
Anyway, what you are wanting to do can definitely be accomplished. I've managed to write some pretty complicated DLLs for MT4 in C#, including things like remoting, raw sockets, http, WinForms. Pretty much anything you can do with .NET can be called from MT4 this way (you name it, and I've probably done it). And it's very reliable. The only problem is the relatively slow memory leak.
Quote:
Originally Posted by Magick
Thanks Patrick
thats a very interesting idea to use the FTP.
however I do want to be able to interact with MT - to send the tick and candle info to the .net app and this app communicate back to MT on when to trade.
I found this that I thought may help - Simplified Wrapper and Interface Generator
However I am a rather entry level programmer, and dont fully appreciate what is involved in having a c++ wrapper middle layer.
I would be interested to hear your opinion, if you think this could be a useful tool to use to help bridge between the c++ and .net?
Since I was here, I thought I'd share my experience. What you are wanting to do can certainly be done, and I've done it many times myself.
When I first started writing DLLs for use in MT4 I couldn't ever get it to work in C++. I think the problem was/is that my project settings were always incorrect in Visual Studio (there's so d@$% many of them). Just recently I found an example from CodeGuru, which I was actually able to compile and use. Now I basically cleaned out that project and use it as a template.
In the meantime, I've been writing C# DLLs and using this excellent tool here. It basically takes the IL and alters it so that it can be called from unmanaged code. The only problem is that MT4 seems to exhibit a memory leak when doing this. I haven't definitively determined if that's due to MT4 or the altering of the IL, or what, but it happens.
Next I'll either be learning to write wrappers on C++ and/or just go ahead and learn C++. Hopefully that will address the memory issue.
Anyway, what you are wanting to do can definitely be accomplished. I've managed to write some pretty complicated DLLs for MT4 in C#, including things like remoting, raw sockets, http, WinForms. Pretty much anything you can do with .NET can be called from MT4 this way (you name it, and I've probably done it). And it's very reliable. The only problem is the relatively slow memory leak.
bwilhite you are a life saver! That looks like a great tool. Do you, by chance, have a c# project that demonstrates communicating with MT from C#? What I am wanting to do is have my .net app tell MT when to trade. Or perhaps you can recommend a link that could help. Any help would be greatly appreciated.