I'm having some trouble matching up two sets of data which should be the same.
1) I have a Signal with uses the function XAverage. It is initialized as such:
Code: Select all
private XAverage slow_ema;
protected override void Create()
{
// Initialize the EMA.
slow_ema = new XAverage(this);
}
protected override void StartCalc()
{
// Initialize the EMA.
price = BarsOfData(1).Close; // Also tried Bars.Close
slow_ema.Price = price;
slow_ema.Length = 21;
}
2) I also have a Mov_Avg_Exponential indicator on the chart with the same parameters: 21 length and 0 displace.
-------------------------
When I run the signal, I access the value of the XAverage function using this method:
Code: Select all
slow_ema[0] // Or sometimes slow_ema[1]
Code: Select all
[IOGMode(IOGMode.Enabled)]
public class MyEMASignal : SignalObject {
...
Code: Select all
Bars.Status != EBarState.Close // Also tried Bars.Status != EBarState.Open
Here's what the chart shows:
and here is the EMA value, output from the signal:
Code: Select all
4/11/2013 12:00:00 PM - Slow EMA[0]: 0.850830263588033
4/11/2013 12:00:00 PM - Slow EMA[1]: 0.850830263588033
I'm really not sure what else to try to get the correct EMA in my signal. Maybe some of you brilliant MultiCharts.NET users or staff could help shed some light on my predicament?
Thanks very much for your time!
Kenny