How Can i Plot a line with json ?

qseworks

Member
Joined
Dec 12, 2019
Posts
6
Likes
2
i have a json file like so :

Code:
{
  date:date,
  open:open,
  high:high,
  low:low,
  close:close,
  volume:volume
}

The Question is How can plot a line with these values in Motivewave using the SDK ?

any guidance would be appreciated
 

Spin

Well-known member
Joined
May 22, 2019
Posts
474
Likes
189
I believe you would have to add a library to your project that 'translates' JSON to Java.
Read (an external ?) file with the values, import them into your MW-Study/Strategy, use them to draw line(s)

This might get you started:
https://www.baeldung.com/java-json
 

qseworks

Member
Joined
Dec 12, 2019
Posts
6
Likes
2
I believe you would have to add a library to your project that 'translates' JSON to Java.
Read (an external ?) file with the values, import them into your MW-Study/Strategy, use them to draw line(s)

This might get you started:
https://www.baeldung.com/java-json

Hi Spin , Thank you for your reply ,

i already have the json mapped as Java objects via jackson's api of Date Type and of Double . my issue here is how can i store the information on the DataSeries object, display a line with the PathDescriptor to automatically plot a series of values that are stored in the DataSeries object

any help would be appreciated , and thanks again for your reply
 

Spin

Well-known member
Joined
May 22, 2019
Posts
474
Likes
189
Ah, sorry: I misunderstood your initial question :)

You can write 'Doubles' as Values to a (data)series and by doing so 'add them to a bar's usable data':

Java:
series.setDouble(index, Values.DAY_HIGH, today_high);

Then you could have your code look up the values that you need for your line:

Java:
point1 = series.getDouble(index, Values.DAY_HIGH)

And eventually use those to plot your line.
I have no code for that yet, since I did not need it until now. I guess you could either draw a set of lines between 2 points (and repeat that a number of times, so it will become one longer line) or plot a path over all the points you stored/looked up.
I suggest you look into the SDK's 'standard MW Studies' for a Study that does exactly this and then copy that code.

Let us know if it works or not, and how you implemented it. It might one day serve others ;)
 

qseworks

Member
Joined
Dec 12, 2019
Posts
6
Likes
2
Ah, sorry: I misunderstood your initial question :)

You can write 'Doubles' as Values to a (data)series and by doing so 'add them to a bar's usable data':

Java:
series.setDouble(index, Values.DAY_HIGH, today_high);

Then you could have your code look up the values that you need for your line:

Java:
point1 = series.getDouble(index, Values.DAY_HIGH)

And eventually use those to plot your line.
I have no code for that yet, since I did not need it until now. I guess you could either draw a set of lines between 2 points (and repeat that a number of times, so it will become one longer line) or plot a path over all the points you stored/looked up.
I suggest you look into the SDK's 'standard MW Studies' for a Study that does exactly this and then copy that code.

Let us know if it works or not, and how you implemented it. It might one day serve others ;)

Thank you so much , i sure will , i appreciate all your help Spin
 
Top