Simple MT4 - Java bridge - page 3

 
cyberflohr:
Are you using the right getter method - getDoubleProperty(jCtx, "DoublePropertyName") ?

I've verified the sample mt4jSAmple.mq4 with double values and it works.

setDoubleProperty(jCtx, "DoublePropertySample", DoubleProperty);
if (DoubleProperty != getDoubleProperty(jCtx, "DoublePropertySample")) {
Alert("Double wasn't set correct: " + getDoubleProperty(jCtx, "DoublePropertySample"));

}


Maybe it's the float value itself, what is the float value?

Environment

========

> MT4.00 build 418

> Java Runtime : C:\Program Files (x86)\Java\jre6\bin\client\jvm.dll

java version "1.6.0_31"
Java(TM) SE Runtime Environment (build 1.6.0_31-b05)

Java HotSpot(TM) Client VM (build 20.6-b01, mixed mode, sharing)



MT4 inclusion :

==========

#import "mt4j.dll"

double getDoubleProperty(int jctx, string property);

void setDoubleProperty(int jctx, string property, double value);

#import


Java implementation :

==============

private double doublePropertySample;


public double getDoublePropertySample() {

return this.doublePropertySample;

}

public void setDoublePropertySample(double doubleProperty) {
this.doublePropertySample = doubleProperty;
}



Following code is run :

==============

double send_test_double = -8008.12345678912;

setDoubleProperty(pid,"DoublePropertySample",send_test_double);
double received_test_double = getDoubleProperty(pid,"DoublePropertySample");

Print("Double Send (as is) ",send_test_double);
Print("Double Send Test ",DoubleToStrMorePrecision(send_test_double,16));
Print("Double Received (as is) ",received_test_double);
Print("Double Received Test ",DoubleToStrMorePrecision(received_test_double,16));
Print("Double Comparison Test ",send_test_double == received_test_double);


Following lines in terminal logging :

=======================

2012.05.10 00:55:55 ATT - Java EURUSD,M5: Double Send (as is) -8008.1235
2012.05.10 00:55:55 stdlib EURUSD,M5: loaded successfully
2012.05.10 00:55:55 ATT - Java EURUSD,M5: Double Send Test -8008.1234567891197003
2012.05.10 00:55:55 ATT - Java EURUSD,M5: Double Received (as is) -1.#IND
2012.05.10 00:55:55 ATT - Java EURUSD,M5: Double Received Test -1.6627963145224000
2012.05.10 00:55:55 ATT - Java EURUSD,M5: Double Comparison Test 1


Hope you can see something on it, as I have compared it already many times (maybe I overlook something).

 
pivotpoint:

Environment

========

> MT4.00 build 418

> Java Runtime : C:\Program Files (x86)\Java\jre6\bin\client\jvm.dll

java version "1.6.0_31"
Java(TM) SE Runtime Environment (build 1.6.0_31-b05)

Java HotSpot(TM) Client VM (build 20.6-b01, mixed mode, sharing)



MT4 inclusion :

==========

#import "mt4j.dll"

double getDoubleProperty(int jctx, string property);

void setDoubleProperty(int jctx, string property, double value);

#import


Java implementation :

==============

private double doublePropertySample;


public double getDoublePropertySample() {

return this.doublePropertySample;

}

public void setDoublePropertySample(double doubleProperty) {
this.doublePropertySample = doubleProperty;
}



Following code is run :

==============

double send_test_double = -8008.12345678912;

setDoubleProperty(pid,"DoublePropertySample",send_test_double);
double received_test_double = getDoubleProperty(pid,"DoublePropertySample");

Print("Double Send (as is) ",send_test_double);
Print("Double Send Test ",DoubleToStrMorePrecision(send_test_double,16));
Print("Double Received (as is) ",received_test_double);
Print("Double Received Test ",DoubleToStrMorePrecision(received_test_double,16));
Print("Double Comparison Test ",send_test_double == received_test_double);


Following lines in terminal logging :

=======================

2012.05.10 00:55:55 ATT - Java EURUSD,M5: Double Send (as is) -8008.1235
2012.05.10 00:55:55 stdlib EURUSD,M5: loaded successfully
2012.05.10 00:55:55 ATT - Java EURUSD,M5: Double Send Test -8008.1234567891197003
2012.05.10 00:55:55 ATT - Java EURUSD,M5: Double Received (as is) -1.#IND
2012.05.10 00:55:55 ATT - Java EURUSD,M5: Double Received Test -1.6627963145224000
2012.05.10 00:55:55 ATT - Java EURUSD,M5: Double Comparison Test 1


Hope you can see something on it, as I have compared it already many times (maybe I overlook something).



Or do you happen to have updated versions of the software available with other enhancements? I'm currently using the v2 version of the dll.
 

Hi pivotpoint,

I've testet your code with my MT build 409 and it works.

06:37:18 mt4jSample EURUSD,H4: Double Send (as is) -8008.1235
06:37:18 stdlib EURUSD,H4: loaded successfully
06:37:18 mt4jSample EURUSD,H4: Double Send Test -8008.1234567891197003
06:37:18 mt4jSample EURUSD,H4: Double Received (as is) -8008.1235
06:37:18 mt4jSample EURUSD,H4: Double Received Test -8008.1234567891197003

06:37:18 mt4jSample EURUSD,H4: Double Comparison Test 1


Nevertheless I've searched around and found an interessting posting. Seems that the version (418) which you are using has some serious bugs.

https://www.mql5.com/en/forum/138657


regards,

cyberflohr

 
New Version: V0.3

support added for noargs void-method.

MT4 code:

// calls a noargs void method in your EA class.
callNoArgsMethod(jCtx, "doSomething");


regards,

cyberflohr

Files:
mt4j_v0.3.zip  17 kb
 
brooky29:

Hi

Error 126 to my understanding means that MT4 cannot find the dll file. Assuming that you are calling it by it's correct name it needs primarily to be in the /experts/libraries/ folder. It can go elsewhere but this is your best location.

Hope this helps.

Cheers

Brooky

In fact, after several tests and search on external forums, i found that Error 126 is released by the system when the DLL can't find one of its dependencies... i highly recommend using the tool depends.exe to figure out which dll dependency is missing on your operative system.
 

Hi,

I am having error below for MT build 432

2012.06.14 00:23:24 2011.09.26 20:00 mt4jSample EURUSD,H4: function 'addNewBar' call from dll 'mt4j.dll' critical error c0000005 at 6D8860FA.

For me, it looks like the build got issue with the api.

Would we hitting the same issue again if we upgraded with newer MT build?


Thanks


 

Hello,

I have a problem loading the mt4jSample.jar. I have added a few code in SampleEA.java which require external jar files, however after I repackaged mt4jSample.jar the the system seems not recognized or can not find where those external jar files.

The new SampleEA.java works fine in Eclipse but just not working in MetaTrader 4, if I removed those code which calling external jar files and repackaged, mt4jSample.jar works fine.

Can you please tell me where I should define or set class path for those external jar files? I tried mt4j.properties but not working.

Many thanks

 
javaelf:

Hello,

I have a problem loading the mt4jSample.jar. I have added a few code in SampleEA.java which require external jar files, however after I repackaged mt4jSample.jar the the system seems not recognized or can not find where those external jar files.

The new SampleEA.java works fine in Eclipse but just not working in MetaTrader 4, if I removed those code which calling external jar files and repackaged, mt4jSample.jar works fine.

Can you please tell me where I should define or set class path for those external jar files? I tried mt4j.properties but not working.

Many thanks

This Forum is about mql4 coding . . .
 
RaptorUK:
This Forum is about mql4 coding . . .

Thanks, but as I mentioned in the post, there is no problems when I run it in Eclipse but has problems in MetaTrader4. Not sure where MQL4 or MetaTrader4 should configure the class path.
 
javaelf:

Hello,

I have a problem loading the mt4jSample.jar. I have added a few code in SampleEA.java which require external jar files, however after I repackaged mt4jSample.jar the the system seems not recognized or can not find where those external jar files.

The new SampleEA.java works fine in Eclipse but just not working in MetaTrader 4, if I removed those code which calling external jar files and repackaged, mt4jSample.jar works fine.

Can you please tell me where I should define or set class path for those external jar files? I tried mt4j.properties but not working.

Many thanks

mt4j.properties is the right place for expanding the classpath i.e.

jvmOption.1=-Djava.class.path=experts\libraries\mt4jSample.jar;experts\libraries\mylib.jar;c:\mylibs\mylib2.jar


cyberflohr

Reason: