Help creating an new indicator that will calculate and return a single result as output
Help creating an new indicator that will calculate and return a single result as output
15 Oct 2023, 03:03
Hi guys, I found a problem while creating multiple SMAs and trying to use it as source in standard deviation it’s not possible to add up these SMAs, it says operator ‘+’ cannot be applied to operands of type ’SimpleMoving Average’ and ’SimpleMoving Average’, can you help me with the problem?
eg:
var sma1 = Indicators.SimpleMovingAverage(Bars.ClosePrices, 50);
var sma2 = Indicators.SimpleMovingAverage(Bars.ClosePrices, 100);
var sma3 = Indicators.SimpleMovingAverage(Bars.ClosePrices, 150);
var sma4 = Indicators.SimpleMovingAverage(Bars.ClosePrices, 200);
var sma_1234 = (((sma1+sma2)/2) + ((sma3+sma4)/2))/2
var sd = Indicators.StandardDeviation(sma_1234.Result,50, MovingAverageType.Simple);
var sma_1234 = (((sma1+sma2)/2) + ((sma3+sma4)/2))/2
this is the part where it cannot do it in robot it has to be done it alone in an new indicator calculate and return a single result as output, but I am too new to code, could anyone please help with the indicator code? Much appreciated !
Replies
JXTA
15 Oct 2023, 05:35
( Updated at: 16 Oct 2023, 04:03 )
RE: Help creating an new indicator that will calculate and return a single result as output
PanagiotisChar said:
Hi there,
You cannot do this in C#. To do this you need to create a new IndicatorDataSeries and add the values one by one inside the calculate method.
Hi, thanks for reply, do you mean calculate in cbot onbar() area or in a new indicator then refer it to cbot?
I have a new post here with my indicator, can we please move our future discussion to here? Many thanks!
https://ctrader.com/forum/calgo-support/42069
@JXTA
PanagiotisChar
15 Oct 2023, 04:11
Hi there,
You cannot do this in C#. To do this you need to create a new IndicatorDataSeries and add the values one by one inside the calculate method.
@PanagiotisChar