Importing 'values' in a different study

Spin

Well-known member
Joined
May 22, 2019
Posts
478
Likes
191
I exported a Value in one of my studies like so:

Java:
desc.exportValue(new ValueDescriptor(Values.averageATR2, Enums.ValueType.DOUBLE, "Avg ATR2", null));

I would now like to use this value 'averageATR2' in a different study, to draw text on my PricePlot.

I can't for the life of me figure out how to 'import' it there, and the SDK programming guide / SDK overview brought no answers.

A lifeline, anyone ?
Much obliged ! :)
 

MotiveWave_Joe

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

The exported values may be used as input for another study such as adding a moving average overlay to an RSI plot for example.

With MotiveWave, you can't reference the value of another study within study code (at least directly).

To do so would create a dependency between the studies which is generally considered to be poor design practice so you would need to include the code (ie duplicate) of the second study.

Alternatively, you can always place the code in a utility class and call it that way.

Take a look at the Starc Bands source code as it calls upon the Utility.class which contains source code from other studies.

Hope that helps.

Regards,
 

forum69

New member
Joined
Mar 12, 2020
Posts
2
Likes
1
Thanks Joe for the strong support. Totally agree with your point on not directly using "Values" from other studies rather use it as an input to another study.

The current version of SDK development documentation does not provide an example to use exported "Values" of one study as an input to another study. Is it possible for motive wave team to provide an example code for that? Thanks. It would be very much appreciated.

Regards and best wishes,
 

Spin

Well-known member
Joined
May 22, 2019
Posts
478
Likes
191
Thank you for your answer @MotiveWave_Joe ! (y)

So I guess I will stick to creating 'MegaStudies' that contain all the values that I need, so I can work with them, use them as triggers, ...

Could this also be (part of) an answer for my question regarding the 'Watchlist Weirdness' ?
(please refer here: WWeirdness )

Is it possible that the Watchlist cannot 'see' the 'Tiny buy' value, that is created by my Custom Study ?
 

michaelphines

Member
Joined
Apr 21, 2020
Posts
7
Likes
2
If they're all your studies, you don't have to duplicate the code, you can create classes that are shared between multiple studies in your project. No one says you have to write all of your code in your Study class. The strategy I'm developing right now has ~500 lines, but ~60 of them are in the Study class, and I don't plan on adding many more.

I only have one study right now, but any of these classes I wanted to re-use can be used in a second study without duplicating anything but those 60 lines. If I wanted to make a similar study with different drawings I would just need to reference a different drawings class. Or if I wanted to completely change my strategy, all of my custom bar calculations are encapsulated in the Bar class, and I can re-use any of those calculations in a different signals class.

There's some unfortunate coupling going on with the Study class here (e.g. the public updateFigure method), but overall I think this has been a helpful way for me to organize my logic.

229
 

forum69

New member
Joined
Mar 12, 2020
Posts
2
Likes
1
Hi Spin,

The exported values may be used as input for another study such as adding a moving average overlay to an RSI plot for example.

Hi Joe,

Could you please provide an example showing "The exported values may be used as input for another study such as....." as said above?

Thanks immensely.
 
Top