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

Quick MA an alternative to Juirk MA

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

    Quick MA an alternative to Juirk MA

    I remember a good while ago Elliot looking for something like this and he shared the Modified Optimal Elliptical Filter. The indicator is in Easy language. If someone could translate it, it would be very useful to all NT users.

    Here's a pic comparing them. Jurik is cyan and Quick is yellow. Also attached is the code is in the zip file.

    okay also posting the code.

    // Plots a fractional-bar Quick Moving Average
    // with the option to select gapless daily opens.
    //
    // copyright 2008 John McCormick jmactrader.com
    //
    // feel free to copy and use this code royalty free
    // as long as it retains the above acknowledge
    //

    inputs:
    Price(Close),
    Quick_Length(9),
    displace(0),
    gapless(0); // set gap to a non-zero value to skip over opening daily gaps

    Var: Length(maxlist(1,Quick_Length));

    // GapLess

    Vars: // gapless O,H,L,C where O=C[1]
    RelO(0),
    RelH(0),
    RelL(0),
    RelC(0),
    gap(0),
    Accum(0),
    WtMean(0);

    if date<>date[1] then begin
    gap = O-C[1];
    Accum = Accum+gap;
    end;

    RelO = O-Accum;
    RelC = C-Accum;
    RelH = H-Accum;
    RelL = L-Accum;

    // Gapless bars - end

    WtMean = (RelH+RelL+RelC)/3;

    // End Gapless

    if gapless=0
    then plot1[displace](FMA_Smooth(price,length),"FMA_Quick")
    else plot1[displace](FMA_Smooth(RelC,length)+accum,"FMA_Quick");

    Function-------------------------------------------------------

    // generates very smooth and responsive moving average
    // copyright 2008 John McCormick jmactrader.com
    // feel free to copy and use this code royalty free
    // as long as you don't remove the above acknowledgement
    //

    Inputs:
    Price(numericseries),
    Length(numericsimple);

    Vars:
    j(0),
    workinglen(maxlist(1,absvalue(Length))),
    peak(workinglen/3),
    tot(0),
    divisor(0);

    Array:
    val[100](0);

    if workinglen>100 then workinglen=100; // use larger array to handle lengths over 100


    tot=0;
    divisor=0;
    for j=1 to floor(workinglen+1) begin
    if j<=peak then val[j]=j/peak
    else val[j]=(workinglen+1-j)/(workinglen+1-peak);
    tot=tot+price[j-1]*val[j];
    divisor=divisor+val[j];
    end;
    if divisor<>0 then FMA_smooth=tot/divisor;
    The code under the dashes is the smoothing function.
    Attached Files
    Last edited by Ninja B; 12-06-2008, 10:43 AM.

    #2
    As a last resort you can try a 3rd party NinjaScript Consultant here if you want: http://www.ninjatrader.com/webnew/pa...injaScript.htm
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      MOEF is in this thread if anyone needs it.



      BTW, when it comes to short periods I've found that the closest thing to the JMA is the ADXVMA. For longer periods I think ZiNonLagMA and StepMA are just as good if not better than the JMA.

      Also if you post the actual code you might have better luck than an ELD file which requires TS to open.

      Comment


        #4
        ^^^ Thanks. I use StepMA also. It's great. Posted the actual code.

        Comment


          #5
          As a Ninja beginner and non-programmer, I am entering the steep learning curve of going beyond the strategy builder.

          I am trying to generate some strategies with the huge selection of MovingAverages. I see several indicators where lines change in color depending on trend conditions. However how do you use this in strategies?

          As a simple approach I tried to use the ZiNonLagMA in a strategy, E.g. Just trying to buy where yellow goes to green and sell when green to yellow or red.

          Is there a way to use the Plot Values "UpTrend", "DownTrend" and "NonTrend" directly in a strategy with some sort of a boolean expression?
          e.g. If ..... is "UpTrend" then ....
          It does not work with the strategy builder.


          After looking at the indicator code, I tried to use the sTrend expression in a strategy with
          UpTrend: "if ( ZiNonLagma.sTrend[0] > 0 && ZiNonLagma.sTrend[1] > 0 )" then ....
          DownTrend: "if ( ZiNonLagma.sTrend[0] < 0 && ZiNonLagma.sTrend[1] < 0 )" then ....
          It did not do what I wanted, but these expressions appear to trigger at least something.

          However I got totally stuck with the NonTrend part.
          If I understand the code in the indicator file correctly the NonTrend is determined first (before the Up and Downtrend) via a user definable filter calculation.

          // Plot Non Trend
          Values[2].Set( 0, serie[0] );

          sTrend[0] = sTrend[1];

          if ( serie[0] - serie[1] > filter * TickSize / splitTick )
          sTrend.Set( 0, 1);
          else if ( serie[1] - serie[0] > filter * TickSize / splitTick )
          sTrend.Set(0, -1);
          else
          sTrend.Set(0, 0);



          I tried using "ZiNonLagma.sTrend[0] = ZiNonLagma.sTrend[1]" as exit condition, but that did not work.


          Anybody an idea or pointer on how to use the ZiNonLagMA correctly in a strategy?

          PS I attached my non working teststrategy and the ZiNonLagMa indicator as this indicator was non easy to find... just stumbled on it when reading the posts.
          Attached Files

          Comment


            #6
            Not sure exactly what you are trying. You cannot create plots from a strategy. However you can create DataSeries and the access it the information just like a plot.
            Josh P.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by dappa, Today, 09:18 AM
            0 responses
            0 views
            0 likes
            Last Post dappa
            by dappa
             
            Started by bill2023, Yesterday, 08:51 AM
            4 responses
            22 views
            0 likes
            Last Post bltdavid  
            Started by trilliantrader, Today, 08:16 AM
            3 responses
            9 views
            0 likes
            Last Post NinjaTrader_BrandonH  
            Started by NinjaTrader_ChelseaB, 01-08-2017, 06:59 PM
            79 responses
            19,662 views
            5 likes
            Last Post zrobfrank  
            Started by funk10101, Today, 08:14 AM
            3 responses
            5 views
            0 likes
            Last Post NinjaTrader_Jesse  
            Working...
            X