Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Ema(Ema(5)-Ema(15), 3) or Ema(DataSeries, 3)

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Ema(Ema(5)-Ema(15), 3) or Ema(DataSeries, 3)

    I have a seemingly valid DataSeries. I can access all values with MyDataSeries[x]. When I try to use MyDataSeries as the 1st argument of EMA(), Ninja Always returns ADX(Close, 14, 3), it even documents the panel with ...ADX(..., 14,3). This was verified by a Ninja support engineer. It was also raised up to development. They do not have an answer. If I pass Close, High, Low, etc. to EMA() it works fine. I would actually like to pass MyDataSeries to EMA() or Jurik's Jma(). MyDataSeries also plots perfect values to my StrategyPlot. The only problem there is getting a smoothed average of the StrategyPlot values. All of the values in MyDataSeries are valid. The order of definitions is in the right order in the Initialize section. All of this is within a Strategy. I tried passing StrategyPlot(1) and several variations of StrategyPlot(1) to EMA()...again, with no luck.
    Again, the basic logic is very simple:
    An EMA of Ema(FastLen)-Ema(SlowLen) or Ema(MyDataSeries, 3).
    Any suggestions or work arounds would be appreciated. Thanks.

    #2
    Originally posted by ChuckAllen View Post
    I have a seemingly valid DataSeries. I can access all values with MyDataSeries[x]. When I try to use MyDataSeries as the 1st argument of EMA(), Ninja Always returns ADX(Close, 14, 3), it even documents the panel with ...ADX(..., 14,3). This was verified by a Ninja support engineer. It was also raised up to development. They do not have an answer. If I pass Close, High, Low, etc. to EMA() it works fine. I would actually like to pass MyDataSeries to EMA() or Jurik's Jma(). MyDataSeries also plots perfect values to my StrategyPlot. The only problem there is getting a smoothed average of the StrategyPlot values. All of the values in MyDataSeries are valid. The order of definitions is in the right order in the Initialize section. All of this is within a Strategy. I tried passing StrategyPlot(1) and several variations of StrategyPlot(1) to EMA()...again, with no luck.
    Again, the basic logic is very simple:
    An EMA of Ema(FastLen)-Ema(SlowLen) or Ema(MyDataSeries, 3).
    Any suggestions or work arounds would be appreciated. Thanks.
    This was a bit difficult to understand, so let me ask if I understood it correctly.
    • You have a Strategy.
    • Inside this strategy, you have defined and populated a DataSeries.
    • Inside the strategy, you want to take an EMA of said DataSeries.

    Is my understanding correct?

    Comment


      #3
      Very Close To Logic You Described.

      I have 2 moving averages of the Close...Ema(5) and Ema(15). I take this difference and put it into a DataSeries oDiffAvgs. I can access this DataSeries the same as any other...oDiffAvgs[0]. Below are most of the definitions and codings.
      acmIEma() is an indicator that allows me to smooth data before and after the EMA(). It also allows me to color the line based on up and down movements. This has worked fine for years. The Add(oEma..) plots perfectly on the price bars. The StrategyPlot(1) plots the Ema(5)-Ema(15) values perfectly.
      private acmIEma oEmaAvg1; // Fast
      private DataSeries oDiffAvgs;
      oDiffAvgs = new DataSeries(this);

      oEmaAvg1 = acmIEma(aEmaInputSeriesType, ...
      Add(oEmaAvg1);
      oEmaAvg1.Plots[0].Pen.Color = Color.MediumBlue;
      oEmaAvg1.Plots[0].Pen.Width = 1;
      oEmaAvg1.Update();
      oDiffAvgs.Set(oEmaAvg1[0] - oEmaAvg3[0]);
      dDiffAvgs = oDiffAvgs[0];
      StrategyPlot(1).Value.Set(oEmaAvg1[0] - oEmaAvg3[0]);
      * oEmaDiffAvgs = EMA(Close, 3); // <- This works fine.
      * oEmaDiffAvgs = EMA(oDiffAvgs, 3); // <- This displays & returns EMA(ADX(data, 14,3) its even displayed as such in the pane's title bar.
      * I attached a screen dump that shows the 'bad' result in pane #4...notice EMA(ADX(...).
      *If you want to see more, I would love to chat, email, etc. Let me know & I will be glad to give personal info. THANKS.
      Attached Files

      Comment


        #4
        Originally posted by ChuckAllen View Post
        I have 2 moving averages of the Close...Ema(5) and Ema(15). I take this difference and put it into a DataSeries oDiffAvgs. I can access this DataSeries the same as any other...oDiffAvgs[0]. Below are most of the definitions and codings.
        acmIEma() is an indicator that allows me to smooth data before and after the EMA(). It also allows me to color the line based on up and down movements. This has worked fine for years. The Add(oEma..) plots perfectly on the price bars. The StrategyPlot(1) plots the Ema(5)-Ema(15) values perfectly.
        private acmIEma oEmaAvg1; // Fast
        private DataSeries oDiffAvgs;
        oDiffAvgs = new DataSeries(this);

        oEmaAvg1 = acmIEma(aEmaInputSeriesType, ...
        Add(oEmaAvg1);
        oEmaAvg1.Plots[0].Pen.Color = Color.MediumBlue;
        oEmaAvg1.Plots[0].Pen.Width = 1;
        oEmaAvg1.Update();
        oDiffAvgs.Set(oEmaAvg1[0] - oEmaAvg3[0]);
        dDiffAvgs = oDiffAvgs[0];
        StrategyPlot(1).Value.Set(oEmaAvg1[0] - oEmaAvg3[0]);
        * oEmaDiffAvgs = EMA(Close, 3); // <- This works fine.
        * oEmaDiffAvgs = EMA(oDiffAvgs, 3); // <- This displays & returns EMA(ADX(data, 14,3) its even displayed as such in the pane's title bar.
        * I attached a screen dump that shows the 'bad' result in pane #4...notice EMA(ADX(...).
        *If you want to see more, I would love to chat, email, etc. Let me know & I will be glad to give personal info. THANKS.
        I took another look at this and I think I understand what is happening. Unfortunately, I can only go by symptoms, as I do not have access to source code to tell whether or not my speculations are actually true.

        The issue here is that you are trying to Add() the EMA of a DataSeries, as opposed to the EMA of an IDataSeries. The Add() syntax, more or less implies that you must use an IDataSeries for Add() to a strategy. It would appear that ADX() is used as an internal default synchronization mechanism, so when you gave the invalid DataSeries parameter in this case, NT passed to the ADX() and used it instead. Technically, that would probably be a bug: NT should have identified the incorrect parameter and done something about it, instead of silently falling over to some internal override. Thinking about it, this may be a consequence of some inheritance in nested clases, as it is, in fact, valid to take the EMA of a DataSeries: just not to then add said EMA directly to a strategy.

        There is really only one neat solution. Turn the oEMADiffAvgs into an indicator, and then Add() the indicator. While not recommended, if you really must, you can define the indicator class in the same file, so that you can remember and note the inherent dependency.
        Last edited by koganam; 07-27-2014, 11:27 AM. Reason: Corrected grammar.

        Comment


          #5
          Thank you for your idea/help. I will try this very soon.

          Comment


            #6
            Originally posted by ChuckAllen View Post
            Thank you for your idea/help. I will try this very soon.
            I trust that you have solved your issue. This thread shows where I first saw the synchrony code, but could not quite remember when you opened this thread.

            ref: http://www.ninjatrader.com/support/f...d.php?p=385085

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by sidlercom80, 10-28-2023, 08:49 AM
            168 responses
            2,262 views
            0 likes
            Last Post sidlercom80  
            Started by Barry Milan, Yesterday, 10:35 PM
            3 responses
            10 views
            0 likes
            Last Post NinjaTrader_Manfred  
            Started by WeyldFalcon, 12-10-2020, 06:48 PM
            14 responses
            1,429 views
            0 likes
            Last Post Handclap0241  
            Started by DJ888, 04-16-2024, 06:09 PM
            2 responses
            9 views
            0 likes
            Last Post DJ888
            by DJ888
             
            Started by jeronymite, 04-12-2024, 04:26 PM
            3 responses
            41 views
            0 likes
            Last Post jeronymite  
            Working...
            X