Set/Get PlotValue across two indicators?  [SOLVED]

Questions about MultiCharts .NET and user contributed studies.
JohnR
Posts: 26
Joined: 05 Sep 2012
Has thanked: 2 times
Been thanked: 2 times

Set/Get PlotValue across two indicators?

Postby JohnR » 30 Mar 2016

Can Set/Get PlotValue be used to access a variable (double) between two indicators?

In my case I have one indicator (I2) that is on a daily chart (data 2). Another indicator (I1) is on a point based chart (data 1). I calculate a needed value in I2 and I need to access that value in I1.

User avatar
JoshM
Posts: 2089
Joined: 20 May 2011
Location: The Netherlands
Has thanked: 1525 times
Been thanked: 1485 times
Contact:

Re: Set/Get PlotValue across two indicators?

Postby JoshM » 31 Mar 2016

JohnR wrote:Can Set/Get PlotValue be used to access a variable (double) between two indicators?

Yes, it's no problem to use `StrategyInfo.GetPlotValue()` and `StrategyInfo.SetPlotValue()` between indicators, despite having to access it through `StrategyInfo`. You can also use those methods to communicate data between a function and strategy, between two functions, or between a function and indicator.

JohnR
Posts: 26
Joined: 05 Sep 2012
Has thanked: 2 times
Been thanked: 2 times

Re: Set/Get PlotValue across two indicators?

Postby JohnR » 31 Mar 2016

I must be doing something wrong, or not understanding something because the value I get back is always 0.

From my source indicator, I do this in CalcBar():

Code: Select all

StrategyInfo.SetPlotValue(0,profit_target);


And then in my destination indicator, I do this in CalcBar():

Code: Select all

profit_target = StrategyInfo.GetPlotValue(0);


Both indicators are on the same chart.

User avatar
JoshM
Posts: 2089
Joined: 20 May 2011
Location: The Netherlands
Has thanked: 1525 times
Been thanked: 1485 times
Contact:

Re: Set/Get PlotValue across two indicators?

Postby JoshM » 01 Apr 2016

JohnR wrote:I must be doing something wrong, or not understanding something because the value I get back is always 0.

(...)

Both indicators are on the same chart.

It also doesn't work on my end in MultiCharts .NET64 Version 9.1 Release (Build 12064).

I'm not sure why it doesn't work; if I recall correctly, it did work in the past. And last year, Henry also said it works:

Henry MultiСharts wrote:SetPlotValue, GetPlotValue - allows sending information from an existing on chart instance of a signal or indicator to the receiving indicator applied to the same chart. Helps to avoid excessive programming and eliminate discrepancies between indicator and signal.


(I leave this topic for MultiCharts Support since they can probably tell us the why & how).

JohnR
Posts: 26
Joined: 05 Sep 2012
Has thanked: 2 times
Been thanked: 2 times

Re: Set/Get PlotValue across two indicators?

Postby JohnR » 01 Apr 2016

Ok, thank you for checking on your end.

My version is Multicharts.NET64 Version 9.1 Release (Build 12413)

User avatar
Henry MultiСharts
Posts: 8503
Joined: 25 Aug 2011
Has thanked: 1213 times
Been thanked: 2731 times

Re: Set/Get PlotValue across two indicators?  [SOLVED]

Postby Henry MultiСharts » 04 Apr 2016

Hello JohnR,

Set/Get PlotValue can be used in signals, functions and indicators only if any signal is applied to the main chart.

JohnR
Posts: 26
Joined: 05 Sep 2012
Has thanked: 2 times
Been thanked: 2 times

Re: Set/Get PlotValue across two indicators?

Postby JohnR » 04 Apr 2016

Are you saying it only works if the set (or get) is inside of a signal on the main chart? Meaning you can't use this between two indicators or functions?

User avatar
Henry MultiСharts
Posts: 8503
Joined: 25 Aug 2011
Has thanked: 1213 times
Been thanked: 2731 times

Re: Set/Get PlotValue across two indicators?

Postby Henry MultiСharts » 04 Apr 2016

JohnR wrote:Are you saying it only works if the set (or get) is inside of a signal on the main chart? Meaning you can't use this between two indicators or functions?
You can use these commands between two indicators or functions. You just need to have a signal applied to a chart.

User avatar
orad
Posts: 104
Joined: 14 Nov 2012
Has thanked: 40 times
Been thanked: 15 times

Re: Set/Get PlotValue across two indicators?

Postby orad » 01 Jul 2017

Another caveat I noticed is StrategyInfo.GetPlotValue has to be called directly from the instance of Indicator that is plotted, and for some reason, if you call it from a base class it will return zero (0).


Return to “MultiCharts .NET”