Interfacing charts with MySQL

sanjayrao

Member
Joined
May 22, 2019
Posts
9
Likes
0
I have my algos which are running in a server running mysql
I want to print the indicator values in motivewave charts from mysql.

Background:
I get the live data feed from one of the brokers and store it in MySQL. Where my algos are running and the values are populated into a few other MySQL tables.
Now I use the jfree chart to plot the values. I would like to plot these values in the motivewave platform.
All these values are plotted at tick, Current screnario, I am able to plot a month’s worth of data ( price plus indicators) on the Jfree charts, after which it runs out of memory.
Is there anyway I can integrate and plot this indicator on motivewave platform? Has anyone done anything similar? Any help or guidance much appreciated.
 

Tony

Moderator
Staff member
Joined
May 22, 2019
Posts
13
Likes
10
Hi Sanjay,

If you are looking to implement a study in MotiveWave that accesses the data in MySQL, then yes you should be able to access this data from the study code. You would need to include the relevant java libraries to access MySQL.

If you are just looking to access the data for display in a chart, you would need to export the data in CSV format and then import it into MotiveWave (File -> Chart -> Import Data from the Console Menu Bar).

You could automate this by creating a batch process and update the same file. MotiveWave will monitor the input file and automatically import the data the next time you open the chart. Just make sure the "Monitor Input File For Changes" option is checked (see below):

Import Data Dialog.png
 

sanjayrao

Member
Joined
May 22, 2019
Posts
9
Likes
0
Thanks, the info was really helpful.
Is there a way to live stream the data from MySQL to motivewave charts? I was looking at plotting something similar to stochastic oscillator. I am using this to day trade and the entries and exits have to be on a 1minute chart (the data gets updates every tick).
 

Tony

Moderator
Staff member
Joined
May 22, 2019
Posts
13
Likes
10
Hi Sanjay,

Sorry but we do not support live streaming from a database.
 

sanjayrao

Member
Joined
May 22, 2019
Posts
9
Likes
0
Let me try to phrase my question slightly differently.
Is there a way I can write my own custom indicator which uses historic tick values to make calculations.
Let me give an example:
If I need to lookup x bars at every tick for multiple currency pairs (similar to currency strength trading system) where one calculates average of multiple pairs effecting one currency pairs,
If we take cable (GBP/USD) as an example, I would calculate the value of all GBP cross and USD cross pairs to get the strength of GBP vs USD and plot the values in the chart. Could you guide me on how I should go about writing a custom indicator which 1) uses historic (tick) value
2) store these value in memory
3) print it on the chart
 

Tony

Moderator
Staff member
Joined
May 22, 2019
Posts
13
Likes
10
Yes, you can do this with a custom study in MotiveWave.
We don't have a specific example to cover this in our current set of studies.

1) You can access tick data from the Instrument interface (see https://www.motivewave.com/sdk/javadoc/index.html). There are several methods for this: forEachTick(...), getTicks(...). I would recommend using one of the forEachTick methods since it does not load all of the ticks into memory.
In version 6 (currently in Beta) there are also methods for looking up historical bars: forEachBar(...) and getBars(...)

In your case if you have this data stored in a MySQL database, you could connect to that via JDBC (for example) and load it directly from the database. You will need to include the necessary jar files (see section 11.3 of the SDK Guide: https://www.motivewave.com/sdk/MotiveWave_SDK_Programming_Guide.pdf)

2) You can store information on the DataSeries object, or locally in the study using any collection you like (such as a Map).

3) If you just want to plot Bars or Lines(paths) you can use the PathDescriptor. This will automatically plot a series of values that are stored in the DataSeries object. You can also access the graphics context directly (see the Figure::draw method) if you need to something custom.

The details above will become much more clear once you have looked at our sample project. You can download this from here:

We can also provide you with source code from our non-premium studies/strategies if you want to look at any other examples or use them as a starting point.
 

sanjayrao

Member
Joined
May 22, 2019
Posts
9
Likes
0
Thanks, that was helpful. Where can I get Source from the non premium studies. That would be a great starting point. Thanks again.
 

rockylin

New member
Joined
Aug 7, 2020
Posts
1
Likes
0
It currently updates whenever you change the bar size. But we could add that as an enhancement in the near future.
Is this enhancement available now? if not, any schedule?
I love Motivewave, the total experience is awesome!
 

LearningEW

Member
Joined
May 28, 2021
Posts
7
Likes
6
It currently updates whenever you change the bar size. But we could add that as an enhancement in the near future.
Hi,

Any update on this feature....updating the data base through CSV on a defined time interval like 30sec etc or real time and no need to change the bar size for updating.
 

MotiveWave_Joe

Moderator
Staff member
Joined
Mar 26, 2019
Posts
223
Likes
67
Hi,

This is still on our features request sheet for future review and consideration.
 
Top