Reverse Exponential Moving Average - futures io
futures io



Reverse Exponential Moving Average


Discussion in NinjaTrader

Updated
    1. trending_up 2,755 views
    2. thumb_up 1 thanks given
    3. group 2 followers
    1. forum 3 posts
    2. attach_file 1 attachments




Welcome to futures io: the largest futures trading community on the planet, with well over 125,000 members
  • Genuine reviews from real traders, not fake reviews from stealth vendors
  • Quality education from leading professional traders
  • We are a friendly, helpful, and positive community
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts
  • We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

(If you already have an account, login at the top of the page)

 
Search this Thread
 

Reverse Exponential Moving Average

(login for full post details)
  #1 (permalink)
 cutzpr 
United States
 
Experience: None
Platform: MT4,TWS,Ninja Trader
Trading: Forex
 
cutzpr's Avatar
 
Posts: 35 since Apr 2012
Thanks: 10 given, 10 received

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); 

Started this thread Reply With Quote

Journal Challenge April 2021 results (now extended!):
Competing for $1800 in prizes from Jigsaw
looks_oneMaking a Living with the Microsby sstheo
(79 thanks from 10 posts)
looks_twoSalao's Journalby Salao
(23 thanks from 5 posts)
looks_3Deetee’s DAX Trading Journal (time based)by Deetee
(16 thanks from 8 posts)
looks_4Learning to Profit - A journey in algorithms and optionsby Syntax
(12 thanks from 7 posts)
looks_5Rogue MNQ 2/21 Journeyby RogueJoules
(0 thanks from 2 posts)
 
Best Threads (Most Thanked)
in the last 7 days on futures io
The Crude Dude Oil Trading System
73 thanks
futures io site changelog and issues/problem reporting
71 thanks
Would You Sell Your System?
65 thanks
FIO Journal Challenge - April 2021 w/Jigsaw Trading
30 thanks
Big Mike in Ecuador
25 thanks
 
(login for full post details)
  #3 (permalink)
 cutzpr 
United States
 
Experience: None
Platform: MT4,TWS,Ninja Trader
Trading: Forex
 
cutzpr's Avatar
 
Posts: 35 since Apr 2012
Thanks: 10 given, 10 received


I need some coding/math guru's to please let me know what is wrong with this code. The formula for a Reverse Exponential Moving Average is .

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<double> rEMA; 
    
int kcalcbar ;     
    
double lambda,lambdatornumerator,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<double>(this);
                
Period;
                
lambda=  2.0 / (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 == 0Value[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  kReversePTR >0ReversePTR--)
                { 
             
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
Register to download File Type: cs CC.ReverseEMA.cs (7.0 KB, 15 views)
Started this thread Reply With Quote
 
(login for full post details)
  #4 (permalink)
 buzzsaw 
Leesburg, VA
 
Experience: Advanced
Platform: NinjaTrader
 
Posts: 80 since Aug 2010
Thanks: 77 given, 33 received

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

Reply With Quote
The following user says Thank You to buzzsaw for this post:


futures io Trading Community Platforms and Indicators NinjaTrader > Reverse Exponential Moving Average


Last Updated on September 3, 2017


Upcoming Webinars and Events
 

NinjaTrader Indicator Challenge!

Ongoing
 

Journal Challenge w/$1,800 in prizes!

April
 

Seven Trading Mistakes Solved With Smart Trading Tools w/Brannigan Barrett

Elite only
     



Copyright © 2021 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