Serial port communication - page 2

 

Hello, a couple of thoughts by me

a. Certainly a good idea to use microcontrollers; but how about outputing to GSM? Maybe you should consider using a cheap smartphone with Android and  evaluate what are the options using USB and the Android NDK. Or maybe Firefox OS. In that case, using an also cheap mobile data plan it may even be possible to use the phone as a backup internet provider; which brings us to b.

b. Maybe a VPS or a dedicated line (aka T3) is all we need as a simple home internet connection is not an ideal place for a trade environment; I was speeking with a technician about some disconnections tha happen from time to time, and he said that normal conditions are considered 4 disconnections per day

 c. you may try to ping regurarly a server and use a company that offers web SMS  services along with an API

 
rubengarber: The Win32 API were my first idea with "Importing Function (#import)", but  MQL4 not recognize "HANDLE hComm;"and I locked
Of course it doesn't, HANDLE isn't part of MT4. What is the definition of your HANDLE? then define it in MT4
#define HANDLE int // 32 bit opaque
#import ...
You must translate everything necessary. Like I did for a pre-build 600 TimeGMT() function:
#import "kernel32.dll"
int    GetTimeZoneInformation(int& TZInfoArray[]);
#import
datetime LocalTimeToUTC(){   // TimeLocal to GMT forum.mql4.com/12057#522900
   // This is called only by TimeGMT. Check for IsDLLsAllowed() done there.
   int      TZInfoArray[43];
   int      tz = GetTimeZoneInformation(TZInfoArray);
   int      GMTshift = TZInfoArray[0]; // GetTimeZoneInformation will return
   #define TIME_ZONE_ID_DAYLIGHT 2     // the right Bias even when it returns
   #define TIME_ZONE_ID_UNKNOWN  0     // UNKNOWN
   if(tz == TIME_ZONE_ID_DAYLIGHT || tz == TIME_ZONE_ID_UNKNOWN)
      GMTshift += TZInfoArray[42];
   return (TimeLocal() + GMTshift*60);
//{msdn.microsoft.com/en-us/library/windows/desktop/ms724421%28v=vs.85%29.aspx
// typedef struct _TIME_ZONE_INFORMATION {      typedef struct _SYSTEMTIME {
// LONG        Bias;           [ 0]  (min)   WORD wYear;       [0]
// WCHAR       StandardName[32];  [ 1]       WORD wMonth;            Jan=1
// SYSTEMTIME  StandardDate;      [17]       WORD wDayOfWeek;  [1]   Sun=1
// LONG        StandardBias;      [21]       WORD wDay;
// WCHAR       DaylightName[32];  [22]       WORD wHour;       [2]
// SYSTEMTIME  DaylightDate;      [38]       WORD wMinute;
// LONG        DaylightBias;      [42]       WORD wSecond;     [3]
//                                   }       WORD wMilliseconds;              }
//}
}
 
Thanks for every ideas.

I thought in a microcontroller because I want to monitor the power supply failure to UPS(Uninterrunped Power System) before the batteries die and switch off  the PC and the Routter
 
rubengarber:
When you have your PC at home and want to monitor faults and alarms you have several options , if there is ethernet, the PC works , MT4 runs smoothly and the Script or the EA works , all messages can be reported by:
- Messages on the PC
- email
- SMS via ethernet
- MT4 mobile
the problem appears if any fails; software or hardware .

I am evaluating an alternative :
CONTROL SYSTEM FAILURE (economic )
Failure to supervise :
- Faulty connection to the server ( ethernet, network , power, ... )
- Crash Script ( EA ) or MT4
- Faulty PC
- ....
the microcontroller supervises the operation and send the SMS

My idea has 2 options :
A - The Script ( EA ) communicates directly through the serial port to the micro .

B - The Script ( or EA ) communicates with a program (via pipeline) and this program communicates via the serial port to the microcontroller . The advantage of this system is that the program could control multiple MT4

                 


The part of the microcontralador have solved , I am now evaluating options about PC and MT4

Hello rubengarber.


Sorry to show up so late with respect to your thread. I am actually very interested in creating a communication between MT4 and an external device as you are. The fact is that I don't understand why you would have an external device like this because, if you want to send messages by GSM. If the system crashes (whatever the element has crashed), it will stop all of this, unless you try to monitor your port for new messages from the platform on the same principle as a watchdog for microcontrollers and then, this external device will warn you about the disruption. It should be an idea but it is too much for only a crash. You may try to create in your EA a part which sends PENDING orders for example every minute/5min/15min (or whatever the number you want) for example, you create a SELL STOP or a SELL LIMIT (don't remember which, anyway) at 0.0001 for any non JPY pair (0.01 for JPY pairs and GOLD), numbers that will never trigger the order, close it at the next sample and reopen it maybe with a different value (0.0002 or 0.02). So if the system does not produce a pending order, there will be something wrong on your MT4 platform.

The part for which I would be hugely interested in a serial port communication between MT4 platform and an external device, it that I could send data, mainly the price of my assets (currency pairs, metals, crypto, indices and so on) to the external device and this device should act as the indicator or pattern calculator! It would also allow to create programs on PC or smartphone that allows to display charts in any mode I want, for example, in ticks, in seconds, in minutes (even 2, 3, 4 which are not proposed by MT4) or other representation models such as Renko, Kagi, and other that I have not named. Thanks to this system, it will help to only use resources of the computer to display charts and send/receive data over the serial port. The external device could be a Raspberry for example or even a nice Cyclone SoC!!!

 

Another thing you can do which is as well complicated is to install ZeroMQ for example : see video here. You will find a file called DWX_ZeroMQ_Server_v2.0.1_RC8.mq4. This file communicates to a virtual server via some ports (default are 32768, 32769 and 32770). Well, either you can find another port number for which your EA can communicate via serial port, or you will have to create your own script in C (or Python ,or Java or maybe some others). In Python you can find something to solve the communication to serial ports.

Kindly

3) MT4 Setup | DWX ZeroMQ Connector for Algorithmic Trading
3) MT4 Setup | DWX ZeroMQ Connector for Algorithmic Trading
  • 2019.09.17
  • www.youtube.com
In this tutorial, we run through exactly how to install and configure MetaTrader for use with the DWX ZeroMQ Connector. DWX ZeroMQ Connector for Algorithmic ...
Reason: