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.
Set/Get PlotValue across two indicators? [SOLVED]
- JoshM
- Posts: 2195
- Joined: 20 May 2011
- Location: The Netherlands
- Has thanked: 1544 times
- Been thanked: 1565 times
- Contact:
Re: Set/Get PlotValue across 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.Can Set/Get PlotValue be used to access a variable (double) between two indicators?
Re: Set/Get PlotValue across two indicators?
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():
And then in my destination indicator, I do this in CalcBar():
Both indicators are on the same chart.
From my source indicator, I do this in CalcBar():
Code: Select all
StrategyInfo.SetPlotValue(0,profit_target);
Code: Select all
profit_target = StrategyInfo.GetPlotValue(0);
- JoshM
- Posts: 2195
- Joined: 20 May 2011
- Location: The Netherlands
- Has thanked: 1544 times
- Been thanked: 1565 times
- Contact:
Re: Set/Get PlotValue across two indicators?
It also doesn't work on my end in MultiCharts .NET64 Version 9.1 Release (Build 12064).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.
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:
(I leave this topic for MultiCharts Support since they can probably tell us the why & how).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.
- Henry MultiСharts
- Posts: 9165
- Joined: 25 Aug 2011
- Has thanked: 1264 times
- Been thanked: 2957 times
Re: Set/Get PlotValue across two indicators? [SOLVED]
Hello JohnR,
Set/Get PlotValue can be used in signals, functions and indicators only if any signal is applied to the main chart.
Set/Get PlotValue can be used in signals, functions and indicators only if any signal is applied to the main chart.
- Henry MultiСharts
- Posts: 9165
- Joined: 25 Aug 2011
- Has thanked: 1264 times
- Been thanked: 2957 times
Re: Set/Get PlotValue across two indicators?
You can use these commands between two indicators or functions. You just need to have a signal applied to a chart.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?
Re: Set/Get PlotValue across two indicators?
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).