Dukascopy
 
 
Wiki JStore Search Login

Attention! Read the forum rules carefully before posting a topic.

    Try to find an answer in Wiki before asking a question.
    Submit programming questions in this forum only.
    Off topics are strictly forbidden.

Any topics which do not satisfy these rules will be deleted.

jforex matlab connection via matlabcontrol java library
 Post subject: jforex matlab connection via matlabcontrol java library Post rating: 0   New post Posted: Sun 19 Feb, 2012, 13:55 

User rating: 0
Joined: Fri 17 Feb, 2012, 22:14
Posts: 7
i'm using this library https://code.google.com/p/matlabcontrol/ for java matlab connection. Everything works fine on netbeans java project, but the same code gives connection error on jforex.
Error comes out when establishing socket connection.

What might be the cause of work or not difference on netbeans and jforex?
Maybe anyone was on the same project?


 
 Post subject: Re: jforex matlab connection via matlabcontrol java library Post rating: 0   New post Posted: Mon 20 Feb, 2012, 08:34 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Use @Library annotation for including libraries in jforex enironment:
https://www.dukascopy.com/wiki/#Include_libraries


 
 Post subject: Re: jforex matlab connection via matlabcontrol java library Post rating: 0   New post Posted: Mon 20 Feb, 2012, 21:29 

User rating: 0
Joined: Fri 17 Feb, 2012, 22:14
Posts: 7
Everething is ok with code, i guess. I get the "conn" message on connection exception. Here's piece of it.
package hello;

import com.dukascopy.api.*;
import matlabcontrol.*;
import matlabcontrol.MatlabConnectionException;
import matlabcontrol.MatlabInvocationException;
import com.dukascopy.api.IEngine.OrderCommand;
import com.mathworks.jmi.*;

@Library("jmi.jar;matlabcontrol-4.0.0.jar")
@RequiresFullAccess


public class MA_Play implements IStrategy {
 
    private IContext context = null;
    private IEngine engine = null;
    private IChart chart = null;
    private IIndicators indicators = null;
    private boolean posCreated = false;
    private int tagCounter = 0;
    private double[] ma1 = new double[Instrument.values().length];
    private IConsole console;
 
 public void rty() throws MatlabConnectionException, MatlabInvocationException
{
    //Create a proxy, which we will use to control MATLAB
    MatlabProxyFactory factory = new MatlabProxyFactory();
    MatlabProxy proxy = factory.getProxy();
   

    //Disconnect the proxy from MATLAB
    //proxy.disconnect();
}


    public void onStart(IContext context) throws JFException {
        this.console = context.getConsole();
       
        try {rty();
        }
        catch (MatlabInvocationException e){console.getOut().println("incob");}
        catch (MatlabConnectionException e){console.getOut().println("conn");}
       
       
        this.context = context;
        engine = context.getEngine();
        indicators = context.getIndicators();
    }
 


 
 Post subject: Re: jforex matlab connection via matlabcontrol java library Post rating: 0   New post Posted: Tue 21 Feb, 2012, 13:21 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
First please set up a program that succesfully works with the library. Then integrate the program into a strategy and try it in Standalone. And finally try it in JForex.
Also consider printing the exception message for more information, e.g.:
console.getOut().println("conn " + e);


 
 Post subject: Re: jforex matlab connection via matlabcontrol java library Post rating: 0   New post Posted: Tue 21 Feb, 2012, 14:21 

User rating: 0
Joined: Fri 17 Feb, 2012, 22:14
Posts: 7
13:12:42 connmatlabcontrol.MatlabConnectionException: Support code location was determined improperly; location does not actually exist. Location determined as: C:\JFOREX

i don't know why the location was determined like that, but anyway it's solved now. i'm new to java, so thx for exception hint, it helped.


 

Jump to:  

  © 1998-2025 Dukascopy® Bank SA
On-line Currency forex trading with Swiss Forex Broker - ECN Forex Brokerage,
Managed Forex Accounts, introducing forex brokers, Currency Forex Data Feed and News
Currency Forex Trading Platform provided on-line by Dukascopy.com