High CPU usage on using custom .ex4 and .dll file

91 views
Skip to first unread message

Mario Lukačić

unread,
Jul 11, 2018, 3:36:05 AM7/11/18
to NJ4X Forum

Hi

I am using custom files to send/receive data to my website.

File are stored in, .ex4  "jfx_term folder\custom_term\MQL4\Experts", and .dll in " jfx_term folder\custom_term\MQL4\Libraries"

Now i am curious 
if i use MT4 without nj4x it is using about 0-1% CPU and arround 44 mb memory
if i use MT4 with nj4x its consume about 6-10% CPU and arround 65 mb memory

Here is an image with both


Both nj4x and normal MT4 are using same .dll and .ex4 files.

Roman Gerasimenko

unread,
Jul 11, 2018, 4:28:22 AM7/11/18
to NJ4X Forum
try to hide all market watch symbols

ср, 11 лип. 2018 о 10:36 Mario Lukačić <mluk...@gmail.com> пише:
--
You received this message because you are subscribed to the Google Groups "NJ4X Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nj4x+uns...@googlegroups.com.
To post to this group, send email to nj...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Message has been deleted

Mario Lukačić

unread,
Jul 11, 2018, 4:55:48 AM7/11/18
to NJ4X Forum
I already tried that and also stripped all charts and history bars to its lightest, i took out anything that is using resources from the MT4.

This only reduced RAM usage by almost a half, now RAM is around 38 MB but CPU same 10% and more.

Roman Gerasimenko

unread,
Jul 11, 2018, 5:07:55 AM7/11/18
to NJ4X Forum
please send {term_location}\logs\socket.log to sup...@nj4x.com - it can help to check abnormal activity ... 
is your app connected to the terminal at the time?

ср, 11 лип. 2018 о 11:55 Mario Lukačić <mluk...@gmail.com> пише:
I already tried that and also stripped all charts and history bars to its lightest, i took out anything that is using resources from the MT4.

This only reduced RAM usage by almost a half, now RAM is around 38 MB but CPU same 10% and more.

--

Mario Lukačić

unread,
Jul 11, 2018, 5:40:34 AM7/11/18
to NJ4X Forum
I sent you log files.

App is not connected on terminal, i used it only to run a terminal with custom template then i turn off app.

So only that runs is that Server with 1 active terminal.

Roman Gerasimenko

unread,
Jul 11, 2018, 5:47:05 AM7/11/18
to NJ4X Forum
that might be a problem, because jfx EA is constantly trying to reconnect to the application which has been used to start it. Please leave your app running and check CPU usage.

ср, 11 лип. 2018 о 12:40 Mario Lukačić <mluk...@gmail.com> пише:
I sent you log files.

App is not connected on terminal, i used it only to run a terminal with custom template then i turn off app.

So only that runs is that Server with 1 active terminal.

--

Mario Lukačić

unread,
Jul 11, 2018, 6:22:02 AM7/11/18
to NJ4X Forum
Look now with app running, even if i turn app off its same


Here is a code that i am using in this simple app


using System;
using System.Configuration;
using nj4x;
using nj4x.Metatrader;

namespace nj4x_p1
{
    class Program
    {
        static void Main(string[] args)
        {
            //create strategy
            var mt4 = new Strategy();
            long chartId = 0;

            // connect to terminal server
            mt4.Connect(
                ConfigurationManager.AppSettings["terminal_host"],
                int.Parse(ConfigurationManager.AppSettings["terminal_port"]),
                new Broker(ConfigurationManager.AppSettings["broker"]),
                ConfigurationManager.AppSettings["account"],
                ConfigurationManager.AppSettings["password"]
            );

            // user API methods
            if (mt4.IsConnectedToTerminal() == true) {
                // account connected
                Console.WriteLine($"Connected : Account {mt4.AccountNumber()}");
                
                // open chart
                chartId = mt4.ChartOpen("AUDUSD", Timeframe.PERIOD_H4);

                // if chart is opened, chart id is returned if chart is opened / loaded !!!!!
                if (chartId != 0)
                {
                    Console.WriteLine("CHART OPENED, trying to load chart AUDUSD ... ");

                    var template_dir = "AUD_test EA_Q4A.tpl"; // path to custom template file
                    if (mt4.ChartApplyTemplate(chartId, template_dir))
                    {
                        Console.WriteLine("Template loaded SUCCESS !");
                        //Environment.Exit(0); // close script !
                    }
                    else
                    {
                        Console.WriteLine("Template not loaded !");
                    }

                }
                else
                {
                    Console.WriteLine("Chart not opened");
                } // open chart
                
            }
            else
            {
                Console.WriteLine("Not connected to terminal");
            }
            Console.ReadLine();
            
        }

    }
}




Roman Gerasimenko

unread,
Jul 11, 2018, 6:27:31 AM7/11/18
to NJ4X Forum
Please add symbols removal from market watch right after the connection, e.g.

foreach (var symbol in mt4.Symbols) mt4.SymbolSelect(symbol, false);



ср, 11 лип. 2018 о 13:22 Mario Lukačić <mluk...@gmail.com> пише:

Mario Lukačić

unread,
Jul 11, 2018, 6:32:19 AM7/11/18
to NJ4X Forum
Same thing, cpu is over 25%

Roman Gerasimenko

unread,
Jul 11, 2018, 6:37:27 AM7/11/18
to NJ4X Forum
Unfortunately I can not reproduce this situation - cpu is 0% all the time for both connected or disconnected app. 
There might be some incompatibilities between your custom EA dll and jfx EA dll... both are using socket api, it is hard to say

I'll check how you can remove jfx EA chart after your setup is complete so terminal will keep running without nj4x api.

ср, 11 лип. 2018 о 13:32 Mario Lukačić <mluk...@gmail.com> пише:
Same thing, cpu is over 25%

--
Reply all
Reply to author
Forward
0 new messages