Profile Picture

data series as parameter ?

Posted By rgrg 9 Years Ago
Message
Posted Saturday May 31 2008
Hi,

I would like to know whether possible to pass in data series to the indicator ?

For example, SMA( X, 10) calculate 10 period simple moving average of X
where X can be open, high, low, close
X may also be 10 period average of ATR, 20 period average of RSI ...... etc

Is it possible to write such a SMA in RE so that it accept any type of dataseries ?
Posted Saturday May 31 2008
in VB:

 

dim mySMA as new SMA(5)

then in startup:

mySma.setinputs(close)

 

so in startup you can setinputs to whatever series...

walt

Posted Saturday May 31 2008
There are a few ways to do this.

Through the UI:

You will want to drag the SMA and ATR indicators to the Indicators node of the trading system tree (the trading system tree is where we show the files associated with a system, the references, and the indicators.  If you're not sure what this is let me know and I can make a screen shot).

After this you can click on the indicators and then set properties in the 'Properties' pane.  There is a property called "Input" and selecting this will show a dropdown with bar properties and all other indicators. 

This is the easiest way and how I generally do it.

From code:

public class MySymbolScript : MySymbolScriptBase

{

      SMA sma;

      AverageTrueRange atr;

           

      public override void Startup()

      {

            atr = new AverageTrueRange(14);          

            sma = new SMA(10, atr);

           

            sma.ChartSettings.ChartPaneName = "atr";

            atr.ChartSettings.ChartPaneName = "atr";

      }

 

      public override void NewBar()

      {

           

      }

}

 

Posted Saturday May 31 2008
thx very much Smile
Posted Sunday September 07 2008
How do you calculate an EMA of a user series? It seems user series can't be used as an input to an indicator? I have a user series "Ratio" calculated as the ratio between two symbols. When I try ExpMovAvg= new EMA(40,Ratio) in the start up section of the symbol script, I get an error message saying I can't use user series as input to an indicator. If I change Ratio from a user series to a DivideSeries it works, but then I only get two decimals for the resulting ratio, which doesn't seem to be enough for what I'm trying to do... any advice please?

Input 0 to indicator ExpMovAvg was a user series.  User series cannot be used as inputs to indicators.
   at RightEdge.Common.IndicatorManager.x39f8db9e6eff648f(xcc9f24b2b74c9456 x4a3f0a05c02f235f)
   at RightEdge.Common.IndicatorManager.Initialize()
   at RightEdge.Shared.SystemWrapper.InitializeModule(SystemData systemData, SystemRunInfo dndInfo, ServiceFactory brokerFactory)
   at RightEdge.Shared.SystemWrapper.RunSystem(SystemData systemData, SystemRunInfo runInfo, Dictionary`2 historicalData, ServiceFactory brokerFactory)
   at RightEdge.Shared.SystemWrapper.RunSystem(DateTime start, String filename, ServiceFactory brokerFactory)
   at RightEdge.Shared.SystemWrapper.RunSystem(DateTime start, String filename, ServiceFactory brokerFactory)
   at RightEdge.Shared.TradingModuleWrapper.RunSystem(SystemDataCreationSettings settings, Dictionary`2 historicalData, SystemRunInfo dndInfo, ServiceAppDomainFactory brokerFactoryFactory)
   at RightEdge.SystemProgress.InitAndRunSystem()

Posted Sunday September 07 2008
As the message says, you cannot use UserSeries as inputs to indicators.  This is because the updated indicator values are all calculated before your NewBar() code is called.  So it's not possible to calculate a UserSeries value by the time it would be needed by the indicator.

Using the DivideSeries should work.  It isn't limited to two decimal places, so that is probably a display issue.  How are you displaying the divide series value?

Thanks,
Daniel

Posted Sunday September 07 2008
Thanks Daniel. I'm displaying the ratio in a separate chart panel. I want to calculate a channel made up of the average of the ratio+/- the std dev of the ratio, among other things. The ratio and channel values are displayed as e.g. 1.26, which is not enough for me to see exactly when I have a breakout. Unfortunately, the trades are not generated where I'm expecting them to be, which is why it would be helpful to see some more decimal points. For the user series I just multiplied the ratio by 100, but I couldn't think of a way to do the same for the DivideSeries.
Posted Sunday September 07 2008
Right now it looks like there's not a way to specify the number of decimal places in a custom chart pane.  However, you can use the DivideSeries to get your ratio and then use a MulitplySeries to multiply it by 100.  Let us know if you run into problems.

Thanks,
Daniel

Posted Monday September 08 2008
Thanks Daniel, that did the trick Smile


Similar Topics


Reading This Topic


2005-2017 © RightEdge Systems