Reverse Exponential Moving Average - NinjaTrader Programming | futures io social day trading

Reverse Exponential Moving Average
 Updated: September 3rd, 2017 (06:18 AM) Views / Replies: 1,970 / 3 Created: January 20th, 2016 (10:41 AM) by cutzpr Attachments: 1

 Welcome to futures io.

# Reverse Exponential Moving Average

United States

Favorite Futures: Forex

Posts: 30 since Apr 2012

Reverse Exponential Moving Average

Does anyone have a Reverse Exponential Moving Average ninjascript? Or can help me convert this code from Amibrokers to Ninjatrader

// Reverse EMA function, by D.Tsokakis, June 2003

Code
 ``` ``` P=20; CLOSEviaEMA=0.5*((P+1)*EMA(C,P)-(P-1)*Ref(EMA(C,P),-1)); Plot (C,"CLOSE",1,1); Plot (CLOSEviaEMA,"CLOSEviaEMA",7,8);  ``` ```

 January 20th, 2016, 10:41 AM Quick Summary Quick Summary Post Quick Summary is created and edited by users like you... Add FAQ's, Links and other Relevant Information by clicking the edit button in the lower right hand corner of this message.

United States

Favorite Futures: Forex

Posts: 30 since Apr 2012

I need some coding/math guru's to please let me know what is wrong with this code. The formula for a
Please register on futures.io to view futures trading content such as post attachment(s), image(s), and screenshot(s).
.

There are two different methods to calc this formula which I believe I coded correctly, but all I am getting is essentially a straight line, not a moving average even after verifying different inputs. Is there something wrong with the coding of the formula? or how I am processing the bars? Please assist.

Code
 ``` ``` public class ReverseEMA : Indicator     {              //public Series rEMA;      int k, calcbar ;          double lambda,lambdator, numerator,denominator,quotient;                  protected override void OnStateChange()         {             if (State == State.SetDefaults)             {                 Description                            = @"ReverseEMA";                 Name                                = "ReverseEMA";                 Calculate                            = Calculate.OnBarClose;                 IsOverlay                            = true;                 DisplayInDataBox                    = true;                 DrawOnPricePanel                    = true;                 DrawHorizontalGridLines                = true;                 DrawVerticalGridLines                = true;                 PaintPriceMarkers                    = true;                 ScaleJustification                    = NinjaTrader.Gui.Chart.ScaleJustification.Right;                 //Disable this property if your indicator requires custom values that cumulate with each new market data event.                  //See Help Guide for additional information.                 IsSuspendedWhileInactive            = true;                 Period                    = 10;                 BarsRequiredToPlot = Period; // Do not plot until their are atleast enough bars to calcu REMA                 AddPlot(Brushes.DarkBlue, "REMA");             }             else if (State == State.Configure)             {                     //rEMA    = new Series(this);                 k = Period;                 lambda=  2.0 / (1 + k);                 lambdator   = 1.0;                   numerator   = 0.0;                 denominator = 0.0;  // REMA formula-expansion contains +1 at the end, never less, never negative             }             }//protected override void OnStateChange()         protected override void OnBarUpdate()          {             if (CurrentBars[0] < BarsRequiredToPlot) return; // Ensures we have enough bars loaded for our iterations and indicator             if (CurrentBar == 0) Value[0] = Input[0]; // Sets temp value for indicator first bar          /*-----------------------------------------------------------------------------/         Only used for error checking if Lambda will be independant          of Period -----------------------------------------------------------------------------*/     /*                                   if (  lambda <= 0.0        // lambda shall not fall on/under  0.0                || lambda >  1.0        //        shall not grow beyond    1.0                || k      <= 0          // depth  shall not be negative or 0                )                return -1.0;            // context-protecting RET value          */          /*-----------------------------------------------------------------------------/         First way for code formula -----------------------------------------------------------------------------*/                           double quotient;                  for (int ReversePTR  = k; ReversePTR >0; ReversePTR--)                 {               calcbar = CurrentBar - ReversePTR;                   numerator   += Math.Pow(lambda,k-ReversePTR) * Input[calcbar];              denominator += Math.Pow(lambda,k-ReversePTR);              quotient =     numerator / denominator;                                          Print(" I am on bar " + CurrentBar +                   "\r\n The CalcBar is " + calcbar +                 "\r\n The Price is " + Input[calcbar] +                  "\r\n The ReversePTR is " + ReversePTR +                  "\r\n The current count is " + (k-ReversePTR) +                 "\r\n The Lambda is " + Math.Pow(lambda,k-ReversePTR) +                  "\r\n The Numerator is " + numerator +                  "\r\n The Denominator is " + denominator +                 "\r\n The quotient is " + quotient +                  "\r\n-------------------------");                     }         Values[0][0] =  (numerator / denominator);         Print(" The REMA is " + Values[0][0] +         "\r\n");          /*-----------------------------------------------------------------------------/         Second way for code formula ------------------------------------------------------------------------------/                  for (int ReversePTR  = k; ReversePTR >0; ReversePTR--)                 {              calcbar = CurrentBars[0] - ReversePTR;                              numerator   += lambdator * Input[calcbar];                                                     denominator += lambdator;             lambdator   *= lambda;             quotient =     numerator / denominator;                              Print(" I am on bar " + CurrentBar +                   "\r\n The CalcBar is " + calcbar +                 "\r\n The Price is " + Input[calcbar] +                  "\r\n The ReversePTR is " + ReversePTR +                  "\r\n The current count is " + (k-ReversePTR) +                 "\r\n The Lambdator is " + lambdator +                  "\r\n The Numerator is " + numerator +                  "\r\n The Denominator is " + denominator +                 "\r\n The quotient is " + quotient +                  "\r\n -------------------------");                                  }         Values[0][0] =  (numerator / denominator);         Print(" The REMA is " + Values[0][0] +          "\r\n"); */ //-----------------------------------------------------------------------                             } //protected override void OnBarUpdate()  ``` ```

Attached Files

 September 3rd, 2017, 06:18 AM Elite Member Leesburg, VA   Trading Experience: Advanced Platform: NinjaTrader   Posts: 80 since Aug 2010 Thanks: 74 given, 32 received Done for you Did you ever get this going?. The new S&C article has links to code for NT7 & 8 and other platforms. TRADERSâ€™ TIPS - SEPTEMBER 2017
 The following user says Thank You to buzzsaw for this post:

 futures io > Reverse Exponential Moving Average

Upcoming Webinars and Events (4:30PM ET unless noted)

Right now

Right now

## Journal in July -- over \$2,500 in prizes w/NinjaTrader

July

 Similar Threads Thread Thread Starter Forum Replies Last Post monsieur NinjaTrader 1 November 29th, 2015 05:23 PM Mopaditi NinjaTrader 3 September 24th, 2014 03:11 PM sharmas Elite Automated Trading 62 April 9th, 2012 06:44 PM Kush NinjaTrader Programming 5 November 6th, 2011 12:49 PM yiman NinjaTrader Programming 4 July 29th, 2011 08:03 AM

 Tags average, code, coding, ema, error, guru, information, market data, moving average, ninja, ninjascript, ninjatrader, nt7, reverse, values

 Copyright © 2019 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432 , info@futures.io All information is for educational use only and is not investment advice.There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
no new posts
Page generated 2019-06-23 in 0.20 seconds with 15 queries on phoenix