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

Modified Optimum Elliptic Filter, can someone help?

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

    Modified Optimum Elliptic Filter, can someone help?

    Would anyone be able to help create the John Ehlers Modified Optimal Elliptical Filter (TASC July 2000) for NinjaTrader?

    It seems to be the closest 'open source' substitute for the Jurik Moving Average and I think it could be really useful as a component of other indicators.




    Here is the formula:
    Smooth = .13785*(2*Price – Price[1]) + .0007*(2*Price[1] – Price[2]) + .13785*(2*Price[2] –Price[3]) + 1.2103*Smooth[1] - .4867*Smooth[2]


    This is what I tried, but I couldn't get it to work:
    Code:
    Plot0.Set(0.13785 * (2*Close[0] – Close[1]) + 0.0007 *(2*Close[1] – Close[2]) + 0.13785*(2* Close[2] –Close[3]) + 1.2103*Plot0[1] -0.4867*Plot0[2]);
    Also here is the .mq4 code if its helpful...
    Code:
    #property indicator_chart_window
    #property indicator_buffers 1
    #property indicator_color1 Red
    
    double smooth[];
    
    int buffers = 0;
    int drawBegin = 0;
    
    int init() {
        drawBegin = 16;
        initBuffer(smooth, "MOEF", DRAW_LINE);
        IndicatorBuffers(buffers);
        IndicatorShortName("ModifiedOptimumEllipticFilter");
        return (0);
    }
      
    int start() {    
        if (Bars <= drawBegin) return (0);
        int countedBars = IndicatorCounted();
        if (countedBars < 0) return (-1);
        if (countedBars > 0) countedBars--;
        int s, limit = Bars - countedBars - 1;
        for (s = limit; s >= 0; s--) {
            smooth[s] = 0.13785 * (2 * P(s) - P(s + 1)) 
                      + 0.0007  * (2 * P(s + 1) - P(s + 2)) 
                      + 0.13785 * (2 * P(s + 2) - P(s + 3)) 
                      + 1.2103  * smooth[s + 1] - 0.4867 * smooth[s + 2]; 
        }
        return (0);  
    }
    
    double P(int index) {
        return ((High[index] + Low[index]) / 2.0);
    }
    
    void initBuffer(double array[], string label = "", int type = DRAW_NONE, int arrow = 0, int style = EMPTY, int width = EMPTY, color clr = CLR_NONE) {
        SetIndexBuffer(buffers, array);
        SetIndexLabel(buffers, label);
        SetIndexEmptyValue(buffers, EMPTY_VALUE);
        SetIndexDrawBegin(buffers, drawBegin);
        SetIndexShift(buffers, 0);
        SetIndexStyle(buffers, type, style, width);
        SetIndexArrow(buffers, arrow);
        buffers++;
    }

    #2
    Have you added this check to your code? http://www.ninjatrader-support.com/v...ead.php?t=3170
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by Josh View Post
      Have you added this check to your code? http://www.ninjatrader-support.com/v...ead.php?t=3170
      Yes, I know about that, which is included in the mq4 code but the simple equation itself had many other non related syntax errors (mostly ";" and ")") that I figured it was over my head.

      Perhaps for your next tutorial you could explain the rudimentery steps required to convert MetaTrader indicators to NinjaTrader...

      There's so many cool indicators available and obviously the NT dev teams time could be better spent, but if there was a halfway decent .mq4 to NT tutorial the user base could be leveraged more effectively. There's so many cool mql indicators I would love to port if only I had the ability...

      (*hint if you'd like to help make NT 6.5.0004 an update to remember go here: All 25 indicators from the book "Cybernetics Analysis for Stock and Futures" John F. Ehlers http://mqlsoft.com/download/indicators )

      Comment


        #4
        Unfortunately converting indicators from other platforms is currently outside the scope of what we can provide for. I suggest you just break down the equation into multiple steps and print values at each step to see where things are falling apart.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          Done :



          Comment


            #6
            Thanks for all the work Elliot Wave

            Comment


              #7
              Hi,

              Just an interesting observation - this indicator is almost a "carbon copy" of HMA(Close,10) and LinReg(Close,10) comes real close too.

              Happy Trading

              Comment


                #8
                Elliott Wave,
                Thanks very much for this code. I have a simple question (hopefully with a simple answer)...

                When I see this in the code:
                Code:
                [SIZE=2][FONT=Courier New][COLOR=#0000ff][SIZE=2][FONT=Courier New][COLOR=#0000ff][SIZE=2][FONT=Courier New][COLOR=#0000ff]if[/COLOR][/FONT][/SIZE][/COLOR][/FONT][/SIZE][/COLOR][/FONT][/SIZE][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] (CurrentBar < [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]3[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2])[/SIZE][/FONT]
                [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]return[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2];[/SIZE][/FONT]
                [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] (CurrentBar == [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2])[/SIZE][/FONT]
                [SIZE=2][FONT=Courier New]{[/FONT][/SIZE]
                [SIZE=2][FONT=Courier New]Value.Set([/FONT][/SIZE][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]);[/SIZE][/FONT]
                [SIZE=2][FONT=Courier New]}[/FONT][/SIZE]
                [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]else[/COLOR][/SIZE][/FONT]
                [/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]{ [/SIZE][/FONT]
                 
                [SIZE=2][FONT=Courier New]Value.Set(...........)[/FONT][/SIZE]
                [SIZE=2][FONT=Courier New]}[/FONT][/SIZE]
                [/SIZE][/FONT]
                Does this code snippet with the CurrentBar == 0 and the ELSE minimize on problems of "ghost" or "re-painting" when F5 (refresh) is hit? (btw, my problem is not with COBC = true or false)

                The reason I ask is i have some issues with repainting of objects or plots. It seems this may help me get to the bottom of this issue. If you have a sample of an indicator with DrawDots that is solid and doesn't repaint or create ghosts, could you please point the way? Thanks,

                Thanks for help with my learning.
                Kirk


                Last edited by zeller4; 11-10-2009, 09:46 AM.

                Comment


                  #9
                  Why is it called modified? As far as I can tell the formula is exactly the same as in given by J. Ehlers.

                  Also, wouldn't it be better to use Input instead of Close for formula inputs?

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by funk10101, Today, 12:02 AM
                  1 response
                  10 views
                  0 likes
                  Last Post NinjaTrader_LuisH  
                  Started by GLFX005, Today, 03:23 AM
                  1 response
                  6 views
                  0 likes
                  Last Post NinjaTrader_Erick  
                  Started by nandhumca, Yesterday, 03:41 PM
                  1 response
                  12 views
                  0 likes
                  Last Post NinjaTrader_Gaby  
                  Started by The_Sec, Yesterday, 03:37 PM
                  1 response
                  11 views
                  0 likes
                  Last Post NinjaTrader_Gaby  
                  Started by vecnopus, Today, 06:15 AM
                  0 responses
                  1 view
                  0 likes
                  Last Post vecnopus  
                  Working...
                  X