#### Custom indicator using SeriesCalculatorBaseWithValues

Posted By allen80 6 Years Ago

## Custom indicator using SeriesCalculatorBaseWithValues

 Message Posted Sunday August 19 2012 Hi I want to make a custom indicator using SeriesCalculatorBaseWithValues - which as I understand stores the whole series - which can be looked back etc.But I don't know how to do this - the doc provides an example only for using the IndicatorBase.What I want is a simple moving average example - so I know how to look at previous bar observation.is there a sample example for this? full class code. That would be VERY useful for me to learn.thanks Posted Sunday August 26 2012 hello? Posted Tuesday September 11 2012 Here is the code for the EMA indicator, which uses SeriesCalculatorBaseWithValues:public class EMA : SeriesCalculatorBaseWithValues{         private int periods = 50;         private int validCount = 0;         private double yesterdaysMA = double.NaN;          [ConstructorArgument("Periods", ConstructorArgumentType.Integer, "50", 1)]         public EMA(int periods)                 : base(1)         {                 this.periods = periods;         }          public EMA(int periods, ISeries input)                 : this(periods)         {                 SetInputs(input);         }          protected override double CalcNewValue(int index)         {                 validCount++;                  if (double.IsNaN(yesterdaysMA))                 {                          yesterdaysMA = inputs[0].LookBack(index);                 }                   double todaysMA = IndicatorMath.EMAValue(inputs[0].LookBack(index), yesterdaysMA, periods);                 yesterdaysMA = todaysMA;                  if (validCount < periods)                 {                          return double.NaN;                 }                  return todaysMA;                            }          protected override void Reset()         {                 yesterdaysMA = double.NaN;                 validCount = 0;         }} Thanks,Daniel Posted Thursday September 13 2012 great, will take a look at this now, thanks Posted Thursday September 20 2012 HiI have now made the indicator - how to I import it into righedge as plugin? so that it's available on the indicator menu OR accessible by code? (i've just copied myindicator.dll from my VS project to the plugin folder)thanks! Posted Friday September 21 2012 For it to be accessible by code, you need to add a reference in your trading system project. Right click on it in the project tree, select "Add Reference...", click on "Browse...", and find and select the DLL.For it to show up in the indicator menu, dropping it in the plugin folder should be enough (though you'll need to restart RightEdge). There are some attributes that you need to give the indicator a name and ID and such which I didn't include in the source code I posted here, but you should be able to see in other samples.Thanks,Daniel Posted Friday September 21 2012 I tried adding a reference to MyIndicator.dll and get error below. Not a valid .NET library, error: Could not load file or assembly 'C:\Program Files (x86)\Yye Software\RightEdge 2010\Plugins\MyIndicator.dll' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.so it seems RE only supports .NET 3.5?compiling for .NET 3.5 works for code above, but I get error below!Error   An object reference is required for the non-static field, method, or property 'RightEdge.Common.SeriesCalculatorBase.Current.get'   and no intellisense is available!? Edited: Friday September 21 2012 by allen80 Posted Monday September 24 2012 any update on this? thanks Posted Tuesday September 25 2012 RE supports 4.0. Add the following to your RightEdge config file (in the ‘RightEdge 2010’ folder): startup>     supportedRuntime version="v4.0" />    startup>"It should go just above ‘/configuration>’You will need to include "<" before each of the lines above - I had to exclude due because this editor thinks it's html code.Duane Edited: Tuesday September 25 2012 by alpha23 Posted Tuesday September 25 2012 so will that resolve the error I get below? I compiled the plugin for .net 3.5 so don't think it's related to the .net version. Thanks Error An object reference is required for the non-static field, method, or property 'RightEdge.Common.SeriesCalculatorBase.Current.get'

## Reading This Topic

2005-2018 © RightEdge Systems