Is it possible to get values from ChartIndicator
Is it possible to get values from ChartIndicator
03 Oct 2024, 22:39
Hi,
Just asking if it is possible to get values from ChartIndicator ? like
foreach(ChartIndicator chartindicator in Chart.Indicators) {
foreach(IndicatorLine line in chartindicator.Lines) {
// something like
value = line[index] // or chartindicator[line][index]
}
}
I am struggling on retriving values from indicators added to a chart, like accessing the IndicatorDataSeries object from indicators. Please help.
Thank you in Advance
Replies
PanagiotisCharalampous
05 Oct 2024, 06:21
Hi there,
It is not possible to get the values from the chart indicator. You would need to create the indicator inside your cBot instead.
Best regards,
Panagiotis
@PanagiotisCharalampous
soskrr
05 Oct 2024, 22:37
RE: Is it possible to get values from ChartIndicator
PanagiotisCharalampous said:
Hi there,
It is not possible to get the values from the chart indicator. You would need to create the indicator inside your cBot instead.
Best regards,
Panagiotis
Hi there,
Let's say I have the Indicator's name “MovingAverage”
, how can I create the indicator using that string?
assembly = typeof(cAlgo.API.Indicators.MovingAverage).Assembly;
Type type = assembly.GetType("cAlgo.API.Indicators.SimpleMovingAverage");
object instance = Activator.CreateInstance(type, new obj[] { //prams });
Can I use an assembly to do this ?
Thank you
@soskrr
firemyst
06 Oct 2024, 03:03
RE: RE: Is it possible to get values from ChartIndicator
soskrr said:
PanagiotisCharalampous said:
Hi there,
It is not possible to get the values from the chart indicator. You would need to create the indicator inside your cBot instead.
Best regards,
Panagiotis
Hi there,
Let's say I have the Indicator's name
“MovingAverage”
, how can I create the indicator using that string?assembly = typeof(cAlgo.API.Indicators.MovingAverage).Assembly; Type type = assembly.GetType("cAlgo.API.Indicators.SimpleMovingAverage"); object instance = Activator.CreateInstance(type, new obj[] { //prams });
Can I use an assembly to do this ?
Thank you
Did you even look at the example URL link I provided?
Spotware has provided an example there for the SMA.
@firemyst
soskrr
06 Oct 2024, 08:37
RE: RE: RE: Is it possible to get values from ChartIndicator
firemyst said:
soskrr said:
PanagiotisCharalampous said:
Hi there,
It is not possible to get the values from the chart indicator. You would need to create the indicator inside your cBot instead.
Best regards,
Panagiotis
Hi there,
Let's say I have the Indicator's name
“MovingAverage”
, how can I create the indicator using that string?assembly = typeof(cAlgo.API.Indicators.MovingAverage).Assembly; Type type = assembly.GetType("cAlgo.API.Indicators.SimpleMovingAverage"); object instance = Activator.CreateInstance(type, new obj[] { //prams });
Can I use an assembly to do this ?
Thank you
Did you even look at the example URL link I provided?
Spotware has provided an example there for the SMA.
Hi,
It's a different scenario
@soskrr
soskrr
06 Oct 2024, 08:51
( Updated at: 06 Oct 2024, 12:12 )
RE: RE: RE: Is it possible to get values from ChartIndicator
firemyst said:
soskrr said:
PanagiotisCharalampous said:
Hi there,
It is not possible to get the values from the chart indicator. You would need to create the indicator inside your cBot instead.
Best regards,
Panagiotis
Hi there,
Let's say I have the Indicator's name
“MovingAverage”
, how can I create the indicator using that string?assembly = typeof(cAlgo.API.Indicators.MovingAverage).Assembly; Type type = assembly.GetType("cAlgo.API.Indicators.SimpleMovingAverage"); object instance = Activator.CreateInstance(type, new obj[] { //prams });
Can I use an assembly to do this ?
Thank you
Did you even look at the example URL link I provided?
Spotware has provided an example there for the SMA.
hi,
it's a different scenario. I know how to initialise an indicator. what i am trying to do is, first getting all names of indicators added to a chart. then from the names i can initailie indicators (We don't know what indicators they will be). Finally, we can read their values. Hope I explained clear.
I think using System.Reflection can achieve that.
object result = Indicators.GetType().GetMethod("IndicatorName").Invoke(Indicators, new object[] { params };DataSeries data = (DataSeries)result.GetType().GetProperty("PropertyName").GetValue(result);
That's what I think that can achieve my thoughts, I don't know if it is the right way. Please correct me if i am wrong.
Thank you
@soskrr
firemyst
04 Oct 2024, 14:42 ( Updated at: 05 Oct 2024, 08:40 )
Have you seen these examples?
https://help.ctrader.com/ctrader-algo/articles/for-developers/how-to-use-custom-indicators-in-cbots/#initialising-an-indicator
One way or the other you have to program it in your bot code, so reference the indicator in your bot instead of trying to read a value from teh chart
@firemyst