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

Wilder's Moving Average

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

    Wilder's Moving Average

    Hi,

    Can someone help me to correct this indicator.

    It is showing a straight line.

    Regards
    Sujay

    Amibroker Code:
    =============
    A1 = WilderMA(C, 5);

    function WilderMA(Field, Period)
    {
    X[0] = Field[0];

    for(i = 1; i < BarCount; i++)
    {
    X[i] = Field[i]/Period + X[i - 1] * (Period - 1)/Period;
    }
    return X;
    }
    Attached Files

    #2
    sujay,

    Could you describe to me the issue a bit more here for clarification? Where did you get this indicator?
    Adam P.NinjaTrader Customer Service

    Comment


      #3
      Hi NinjaTrader_AdamP,

      I wrote this indicator by modifying EMA code.

      Formula:



      Problem:
      This is a kind of trend indicator so it should draw a line like other moving average up and down curve.

      But i am getting a horizontal straight line.
      Last edited by ssijbabu; 10-07-2012, 10:38 PM.

      Comment


        #4
        Hello,

        Likely the formula has an issue here. At first I thought it might be because it's only adding some small value each time, but looking at it closer I think it might be that the order these arithmetic operations are going through causes the issue. Division on computers can sometimes be funky if you aren't careful.



        This appears to work :

        Code:
        Plot0.Set(CurrentBar == 0 ? Input[0] : ((Plot0[1]*(period-1) + Input[0])/period ) );
        Last edited by NinjaTrader_AdamP; 10-08-2012, 08:19 AM.
        Adam P.NinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_AdamP View Post
          Hello,

          Likely the formula has an issue here. At first I thought it might be because it's only adding some small value each time, but looking at it closer I think it might be that the order these arithmetic operations are going through causes the issue. Division on computers can sometimes be funky if you aren't careful.



          This appears to work :

          Code:
          Plot0.Set(CurrentBar == 0 ? Input[0] : ((Plot0[1]*(period-1) + Input[0])/period ) );
          Thanks for the code Adam. Here is the indicator.
          Attached Files

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by f.saeidi, Today, 05:56 AM
          1 response
          3 views
          0 likes
          Last Post Jltarrau  
          Started by Jltarrau, Today, 05:57 AM
          0 responses
          4 views
          0 likes
          Last Post Jltarrau  
          Started by Stanfillirenfro, Yesterday, 09:19 AM
          7 responses
          51 views
          0 likes
          Last Post NinjaTrader_Gaby  
          Started by TraderCro, 04-12-2024, 11:36 AM
          4 responses
          70 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Mindset, Yesterday, 02:04 AM
          1 response
          15 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Working...
          X