MA
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)
{
...
}

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