It seems that the thread is not very active.
But anyway, I still talk about a little bit more to help for trading.
This part is not relevant for the system, but aid for notification.
NOTIFICATION PART
I am a bit lazy person, I can't stick with the computer all the time, it miss a lot of chance. How could we solve the problem? I used to use email notification, then when ever the signal occur, I can check use my phone. Put the problem is a bit late, especially for those confirmations in m1 and m5.
Until the Empty4 support the
webrequest, I found a very quick way to help me to send instant notification to my android (iphone and other tablet, or surface too) .
I use Pushbullet + node.js, which might a bit technical, but it works and helps.
Step 1. Install Pushbullet app in your devices
Step 2. Get your access token in pushbullet's website & your device identity (you can get the identity by api)
Step 3. Install node.js + Hapi.js + pushbullet (npm)
https://www.npmjs.com/package/pushbullet
Step 4. Add your host in Empty4, allow it communicate in Empty4 codes.
Step 5. Write mql4 (expert + script only, indicator not allow to call WebRequest)
Now, it is ready. Consider the following server code (node.js + Hapi.js + pushbullet)
index.js
Code: Select all
'use strict';
const Hapi = require('hapi');
const Good = require('good');
const Pushbullet = require('pushbullet');
const server = new Hapi.Server();
server.connection({ port: 80 });
const token = '[color=#FF0000]Your API Key from Pushbullet[/color]';
const device = '[color=#FF0000]Get from Pushbullet or fro api[/color]';
server.route({
method: 'POST',
path: '/reg',
handler:function(req, rep){
var pusher = new Pushbullet(token);
var msg = req.payload.Account; //<-- every details your sent is in the req.payload
pusher.note(device, 'Empty4 Notice', msg, function(error, response){
console.log(error);
});
rep('MSG Sent!');
}
});
server.register({
register: Good,
options: {
reporters: [{
reporter: require('good-console'),
events: {
response: '*',
log: '*'
}
}]
}
}, (err) => {
if (err) {
throw err; // something bad happened loading the plugin
}
server.start((err) => {
if (err) {
throw err;
}
server.log('info', 'Server running at: ' + server.info.uri);
});
});
In the command prompt type
node index.js
Test.mq4 //Mql4 script
Code: Select all
void OnStart()
{
initialize();
}
void initialize()
{
string req[];
char data[], result[];
string header;
Encoding("Account", IntegerToString(AccountNumber()), req);
Encoding("Symbol", Symbol(), req);
Encoding("Balance", DoubleToStr(AccountBalance(),2),req);
StringToCharArray(Stringtify(req), data);
int res = WebRequest("POST", "http://localhost/reg", NULL, NULL, 300, data, ArraySize(data), result, header);
Print(CharArrayToString(result));
}
void Encoding(string key, string val, string &arr[])
{
string result = StringConcatenate(key, "=", val);
int size = ArraySize(arr);
ArrayResize(arr,size+1);
arr[size] = result;
}
string Stringtify(string &arr[])
{
int size = ArraySize(arr);
string temp="";
if(size==1)
temp = arr[0];
else
for(int i=0; i<size; i++)
{
StringAdd(temp, arr[i]);
if(i<size-1)
StringAdd(temp, "&");
}
return temp;
}