Profile Picture

Calculate Erroe (i thynk)

Posted By pavan074 5 Years Ago
Message
Posted Friday April 13 2012
Sorry for my english, i'm stranger.
If i calculate the EMA(65) of Eurostoxx-50 Index from 2 different istance of symbols, i get some small differences in the values (after many periods).

Here's the code:

public class MySymbolScript : MySymbolScriptBase
{
   
   private EMA emaSlow;
   
   public override void Startup()
   {
      this.emaSlow = new EMA(65);
      this.emaSlow.SetInputs(this.OtherSymbols["^STOXX50E"].Close);
   }



   public override void NewBar()
   {      
      if(this.Bars.Count < 65) return;
      
      Console.WriteLine(this.Symbol + " - " + this.Bars.Current.BarStartTime + " -" + this.emaSlow.Current);      
   }

}



Someone can help me?
Posted Sunday April 15 2012
This is probably happening because there are periods (days if you are using daily bars, hours if using hourly bars, etc.) where you have a bar for one symbol but not the other. Because of this there are times when the EMA is calculated for one symbol but not the other.

If you want to calculate the EMA based on just the Eurostox data and use that from other symbols, you can do the following:

public EMA emaSlow;

public override void Startup()
{
this.emaSlow = new EMA(65);
this.emaSlow.SetInputs(Close);
}


public override void NewBar()
{   
if(this.Bars.Count < 65 || this.OtherSymbols["^STOXX50E"].Bars.Count < 65) return;

double euroStoxxEMA = this.OtherSymbols["^STOXX50E"].emaSlow.Current;

Console.WriteLine(this.Symbol + " - " + this.Bars.Current.BarStartTime + " -" + euroStoxxEMA);   
}

Thanks,
Daniel
Posted Monday April 16 2012
Ok thank you Daniel. Now it works!!!

Massimo


Similar Topics


Reading This Topic


2005-2017 © RightEdge Systems