Tag Archives: No

MotiveWave SDK Java no 3rd party coding problems so far

Here they are as there are few 3rd party examples

BIG UPDATE BELOW which means I got this partially working!!

I tested to add a Redis NOSQL (3rd party) using simple Jedis Jar. This was done fairly easily with another Mac OS based proprietary platform like Dukascopy JForex. I could see the Redis update when running the strategy or study within MotiveWave. This builds fine. but there does not seem debugging log capabilities for a strategy but there is for studies. Also, when making changes in the Java in Eclipse, the MotiveWave platform does not seem to pick up the latest changes  in a dynamically changed class.  The only way for this to be picked up is by reseting the platform.

My opinion but it is looking good but …

I think there needs to a be lot more samples from MotiveWave instead of just 3 simple studies and 1 strategy. I could only find one other 3rd party providing further examples. Unfortunately, I am not  in the business of spinning my wheels to figure this out as compared to other brokers/platform who provide flawless coding experiences. I think I need to see a demo or better examples.

Until then, I am may just use MotiveWave for charting or connecting with IQFeed only. I can do that with the entry level MotionWave edition. This platform is very exciting indeed but I need to get to see improvements in the above area before I get serious with it from a coding point for view.

BIG UPDATE on getting Java coding! (Nov 29)

See the video to see what is working including text writing and CSV reading files

Here is working Java code as hinted in the video

package study_examples;

import com.motivewave.platform.sdk.common.Coordinate;

import com.motivewave.platform.sdk.common.DataContext;

import com.motivewave.platform.sdk.common.DataSeries;

import com.motivewave.platform.sdk.common.Defaults;

import com.motivewave.platform.sdk.common.Enums;

import com.motivewave.platform.sdk.common.Inputs;

import com.motivewave.platform.sdk.common.MarkerInfo;

import com.motivewave.platform.sdk.common.desc.InputDescriptor;

import com.motivewave.platform.sdk.common.desc.IntegerDescriptor;

import com.motivewave.platform.sdk.common.desc.MAMethodDescriptor;

import com.motivewave.platform.sdk.common.desc.MarkerDescriptor;

import com.motivewave.platform.sdk.common.desc.PathDescriptor;

import com.motivewave.platform.sdk.common.desc.SettingGroup;

import com.motivewave.platform.sdk.common.desc.SettingTab;

import com.motivewave.platform.sdk.common.desc.SettingsDescriptor;

import com.motivewave.platform.sdk.common.desc.ValueDescriptor;

import com.motivewave.platform.sdk.draw.Marker;

import com.motivewave.platform.sdk.study.RuntimeDescriptor;

import com.motivewave.platform.sdk.study.Study;

import com.motivewave.platform.sdk.study.StudyHeader;

import java.io.File;

import java.io.FileWriter;

import java.io.IOException;

import redis.clients.jedis.Jedis;

import java.io.BufferedReader;

import java.io.FileNotFoundException;

import java.io.FileReader;

import java.io.IOException;

/** Moving Average Cross. This study consists of two moving averages: 

    Fast MA (shorter period), Slow MA. Signals are generated when the 

    Fast MA moves above or below the Slow MA. Markers are also displayed 

    where these crosses occur. */

@StudyHeader(

  namespace=”com.mycompany”, 

  id=”MACROSS”, 

  name=”Sample Moving Average Cross”,

  label=”MA Cross”,

  desc=”Displays a signal arrow when two moving averages (fast and slow) cross.”,

  menu=”Examples”,

  overlay=true,

  signals=true)

public class SampleMACross extends Study

{

  enum Values { FAST_MA, SLOW_MA };

  enum Signals { CROSS_ABOVE, CROSS_BELOW };

  @Override

  public void initialize(Defaults defaults)

  {

try {

File file = new File(“/Users/quantlabsnet/atestfile1.txt”);

FileWriter fileWriter = new FileWriter(file);

fileWriter.write(“This is “);

fileWriter.write(“a test”);

fileWriter.flush();

fileWriter.close();

} catch (IOException e) {

this.debug(e.toString());

e.printStackTrace();

}

//https://www.mkyong.com/java/how-to-read-and-parse-csv-file-in-java/

String csvFile = “/Users/quantlabsnet/country.csv”;

    BufferedReader br = null;

    String line = “”;

    String cvsSplitBy = “,”;

    try {

        br = new BufferedReader(new FileReader(csvFile));

        while ((line = br.readLine()) != null) {

            // use comma as separator

            String[] country = line.split(cvsSplitBy);

            this.debug(“Country [code= ” + country[4] + ” , name=” + country[5] + “]”);

        }

    } catch (FileNotFoundException e) {

        e.printStackTrace();

        this.debug(e.toString());

    } catch (IOException e) {

        e.printStackTrace();

        this.debug(e.toString());

    } finally {

        if (br != null) {

            try {

                br.close();

            } catch (IOException e) {

                e.printStackTrace();

                this.debug(e.toString());

            }

        }

    }

// Jedis jedis = new Jedis(“localhost”); 

//    this.debug(“Connection to server sucessfully”); 

//    //check whether server is running or not 

//    this.debug(“Server is running: “+jedis.ping()); 

 

this.debug(“hello debug from SampleMACross()”);

 

    // User Settings

    SettingsDescriptor sd=new SettingsDescriptor();

    setSettingsDescriptor(sd);

    SettingTab tab=new SettingTab(“General”);

    sd.addTab(tab);

    // Fast MA (shorter period)

    SettingGroup ma1=new SettingGroup(“Fast MA”);

    tab.addGroup(ma1);

    ma1.addRow(new InputDescriptor(Inputs.INPUT, “Fast Input”, Enums.BarInput.CLOSE));

    ma1.addRow(new MAMethodDescriptor(Inputs.METHOD, “Fast Method”, Enums.MAMethod.EMA));

    ma1.addRow(new IntegerDescriptor(Inputs.PERIOD, “Fast Period”, 10, 1, 9999, 1));

    // Slow MA (shorter period)

    SettingGroup ma2=new SettingGroup(“Slow MA”);

    tab.addGroup(ma2);

    ma2.addRow(new InputDescriptor(Inputs.INPUT2, “Slow Input”, Enums.BarInput.CLOSE));

    ma2.addRow(new MAMethodDescriptor(Inputs.METHOD2, “Slow Method”, Enums.MAMethod.EMA));

    ma2.addRow(new IntegerDescriptor(Inputs.PERIOD2, “Slow Period”, 20, 1, 9999, 1));

    tab=new SettingTab(“Display”);

    sd.addTab(tab);

    SettingGroup lines=new SettingGroup(“Lines”);

    tab.addGroup(lines);

    lines.addRow(new PathDescriptor(Inputs.PATH, “Fast MA”, defaults.getGreenLine(), 1.0f, null, true, false, false));

    lines.addRow(new PathDescriptor(Inputs.PATH2, “Slow MA”, defaults.getBlueLine(), 1.0f, null, true, false, false));

    SettingGroup markers=new SettingGroup(“Markers”);

    tab.addGroup(markers);

    markers.addRow(new MarkerDescriptor(Inputs.UP_MARKER, “Up Marker”, Enums.MarkerType.TRIANGLE, Enums.Size.SMALL, defaults.getGreen(), defaults.getLineColor(), true, true));

    markers.addRow(new MarkerDescriptor(Inputs.DOWN_MARKER, “Down Marker”, Enums.MarkerType.TRIANGLE, Enums.Size.SMALL, defaults.getRed(), defaults.getLineColor(), true, true));

    // Runtime Settings

    RuntimeDescriptor desc=new RuntimeDescriptor();

    setRuntimeDescriptor(desc);

    desc.setLabelSettings(Inputs.INPUT, Inputs.METHOD, Inputs.PERIOD, Inputs.INPUT2, Inputs.METHOD2, Inputs.PERIOD2);

    desc.exportValue(new ValueDescriptor(Values.FAST_MA, “Fast MA”, new String[] { Inputs.INPUT, Inputs.METHOD, Inputs.PERIOD }));

    desc.exportValue(new ValueDescriptor(Values.SLOW_MA, “Slow MA”, new String[] { Inputs.INPUT2, Inputs.METHOD2, Inputs.PERIOD2 }));

    desc.exportValue(new ValueDescriptor(Signals.CROSS_ABOVE, Enums.ValueType.BOOLEAN, “Cross Above”, null));

    desc.exportValue(new ValueDescriptor(Signals.CROSS_BELOW, Enums.ValueType.BOOLEAN, “Cross Below”, null));

    desc.declarePath(Values.FAST_MA, Inputs.PATH);

    desc.declarePath(Values.SLOW_MA, Inputs.PATH2);

    // Signals

    desc.declareSignal(Signals.CROSS_ABOVE, “Fast MA Cross Above”);

    desc.declareSignal(Signals.CROSS_BELOW, “Fast MA Cross Below”);

    desc.setRangeKeys(Values.FAST_MA, Values.SLOW_MA);

  }

  @Override

  protected void calculate(int index, DataContext ctx)

  {

    int fastPeriod=getSettings().getInteger(Inputs.PERIOD);

    int slowPeriod=getSettings().getInteger(Inputs.PERIOD2);

    if (index < Math.max(fastPeriod, slowPeriod)) return; // not enough data

    DataSeries series=ctx.getDataSeries();

    // Calculate and store the fast and slow MAs

    Double fastMA=series.ma(getSettings().getMAMethod(Inputs.METHOD), index, fastPeriod, getSettings().getInput(Inputs.INPUT));

    Double slowMA=series.ma(getSettings().getMAMethod(Inputs.METHOD2), index, slowPeriod, getSettings().getInput(Inputs.INPUT2));

    if (fastMA == null || slowMA == null) return;

    series.setDouble(index, Values.FAST_MA, fastMA);

    series.setDouble(index, Values.SLOW_MA, slowMA);

    if (!series.isBarComplete(index)) return;

    // Check to see if a cross occurred and raise signal.

    Coordinate c=new Coordinate(series.getStartTime(index), slowMA);

    if (crossedAbove(series, index, Values.FAST_MA, Values.SLOW_MA)) {

      MarkerInfo marker=getSettings().getMarker(Inputs.UP_MARKER);

      if (marker.isEnabled()) addFigure(new Marker(c, Enums.Position.BOTTOM, marker));

      ctx.signal(index, Signals.CROSS_ABOVE, “Fast MA Crossed Above!”, series.getClose(index));

    }

    else if (crossedBelow(series, index, Values.FAST_MA, Values.SLOW_MA)) {

      MarkerInfo marker=getSettings().getMarker(Inputs.DOWN_MARKER);

      if (marker.isEnabled()) addFigure(new Marker(c, Enums.Position.TOP, marker));

      ctx.signal(index, Signals.CROSS_BELOW, “Fast MA Crossed Below!”, series.getClose(index));

    }

    series.setComplete(index);

  }

}

 

 

NOTE I now post my TRADING ALERTS into my personal FACEBOOK ACCOUNT and TWITTER. Don't worry as I don't post stupid cat videos or what I eat!

NO SQL Server, stay with PostGresSQL database

NO SQL Server, stay with PostGresSQL database
I also decided not move ahead with SQL Server as well due to uncessary complexities to set up a connection from Matlab. As a result, the notes and caveats are below but I am sticking with PostGreSQL for now as it is very easy to work with and multi platform. It is open source as well which means it is FREE.
http://www.mathworks.com/help/database/ug/microsoft-sql-server-jdbc-windows.html
http://www.mathworks.com/help/database/ug/database.html
For JDBC connection:
http://www.mathworks.com/help/database/ug/microsoft-sql-server-jdbc-windows.html
My Notes and caveats:
https://social.msdn.microsoft.com/Forums/sqlserver/en-US/9d84f135-ae13-450e-b0b6-87d37576d8f8/sql-server-agent-gives-remote-procedure-call-failed-0x800706be?forum=sqltools
Try opening the SQL server configuration manager with RUN AS ADMIN option and see if that makes any differencofe
Add in the C:\Users\Bryan\AppData\Roaming\MathWorks\MATLAB\R2014a\javalibrarypath.txt contains something like:
C:\Users\Bryan\AppData\Roaming\MathWorks\MATLAB\R2014a\sqljdbc_4.1\enu\auth\x64
The javaclasspath.txt has
C:\Users\Bryan\Downloads\Microsoft JDBC Driver 4.1 for SQL Server\sqljdbc_4.1\enu\sqljdbc.jar
I had to correct:
C:\Users\Bryan\Downloads\Microsoft JDBC Driver 4.1 for SQL Server\sqljdbc_4.1\enu\sqljdbc4.jar

If you the JDBC 4.1, you will get error of
3:01:30 PM com.microsoft.sqlserver.jdbc.SQLServerConnection <init>

SEVERE: Java Runtime Environment (JRE) version 1.7 is not supported by this driver. Use the sqljdbc4.jar class library, which provides support for JDBC 4.0.

Use the JDBC4.0 not 4.1!
I created Data Source to SQL Server with sample sa credentials for SQL Server authentication
 

Join my FREE newsletter to learn more about how I use PostGres For trading 

NOTE I now post my TRADING ALERTS into my personal FACEBOOK ACCOUNT and TWITTER. Don't worry as I don't post stupid cat videos or what I eat!

No to Java 7, Trradestation Easy and Multichart Power languages, only Matlab, Microsoft .NET, and c++ for pure quant and HFT

No to Java 7, Trradestation Easy and Multichart Power languages, only Matlab, Microsoft .NET, and c++ for pure quant and HFT
Back to the previous posting about Tradestation from a visitor:
Just to play devil’s advocate: Multicharts also uses easylanguage so it does has a well established open-source component out there, and you would presumably just be using easylanguage as a way to get your DLLs in to the system.  The platform is free if you open an account and make only 10 RT trades a month. It is multi-core 64 bit system and you can run as many instances of your strategy as you want within the platform so you are only limited by memory and processing speed you have available:
Maybe you’re talking about running many servers at once all communicating with each other? In that case then yeah I see your point.
My response:
I only want to work with Matlab, .NET and/or C++. Nothing else including Java 7  for its latest set of security breaches. These other proprietary languages like Tradestation Easy or Multichart Power Languages will limit you in so many ways. I shall not go into in this posting as there are so many postings you can search for. You can go ahead see what I talking about but if you follow my advise, you will save yourself well over a year of wasted development. I wish I had known earlier.
NOTE I now post my TRADING ALERTS into my personal FACEBOOK ACCOUNT and TWITTER. Don't worry as I don't post stupid cat videos or what I eat!

Wide stops, Tight stops or No stops in your quant analytics?

Wide stops, Tight stops or No stops in your quant analytics?

Every trader runs into this question at some point. So from your experience what do you think are best?

If anyone interested, my thoughts on this question are at
http://www.atraderjournal.com/2012/02/wide-stops-tight-stops-or-no-stops.html

 

good question and it all comes down to trading style which does take time to develop. We use a number of succesful systems using a range of stops and my colleague Mark Austin uses some very tight stops on FTSE with success.

However I thought a number of readers might be more interested in the more relaxed trading style offered by the “no stop” approach. Just to give a few examples I bought Barlcays at around 100 in March 2009 with no stop. The next day it halved to 50 so not great timing but it quickly bounced back and I bagged a good profit – my “stop” here may be called value + not being over-geared. More recently I bought the VIX EFT in May 2011 with the VIX around 20 – no stop but the VIX rarely goes below 14 although there can be a cost of carry – we had to wait a few months with price going against us but bagged a 100%+ profit in September. Did something similar with the short FTSE ETF (SUK2) and again made money.

Of course it does not always work out and you need to have the cash to buy these instruements but if you don’t want to spend excess time glued to screens this is a good way to go

Mark and I both issue daily reports on markets and you can fine out more at www.johnpiper.info

 

Stops either physical or mental are very important for trading purposes. Depending from your trading style you might place different types of stop orders. However, placing correct stop orders won’t make you a master trader but it certainly is a component of it. I personally use a lot of stop on close orders to avoid intraday volatility, but this is according to my trading style and may not suit everybody.

 

NOTE I now post my TRADING ALERTS into my personal FACEBOOK ACCOUNT and TWITTER. Don't worry as I don't post stupid cat videos or what I eat!