different types compraison

Created at 20 May 2014, 20:31
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
MA

mardahl

Joined 18.05.2014

different types compraison
20 May 2014, 20:31


Hey,
 could you tell me, how may i compare the values of a double type and an indicator type?
(how can i covert in example SimpleMovingAverage to double?)
It's impossible to compare them in the way given below.
Simple coverting the sma variable to double variable by (double)sma doesn't work.

 

[Parameter("sma")]
        public SimpleMovingAverage sma { get; set; }

	...
        ...
protected override void OnStart()
        {
            sma = Indicators.SimpleMovingAverage(MarketSeries.Median, okresy);
		...
	}

if ((Symbol.Ask > sma.Result)
{
...
}

 


@mardahl
Replies

Spotware
21 May 2014, 09:42

You need to specify an index.

            fastMa = Indicators.MovingAverage(SourceSeries, FastPeriods, MAType);
            slowMa = Indicators.MovingAverage(SourceSeries, SlowPeriods, MAType);
       
..

            var currentSlowMa = slowMa.Result.Last(0);
            var currentFastMa = fastMa.Result.Last(0);
            var previousSlowMa = slowMa.Result.Last(1);
            var previousFastMa = fastMa.Result.Last(1);

            if (previousSlowMa > previousFastMa && currentSlowMa <= currentFastMa ...

 


@Spotware

mardahl
23 May 2014, 20:51

Thank you for the answer.


@mardahl