• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Sma formula with ninjatrader 7 and anomolies

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

    Sma formula with ninjatrader 7 and anomolies

    I am programming an indicator for a client and I need to know a few things.

    Did ninjatrader change the SMA algorithm ever?

    I have an indicator that was made years ago to get SMA information and plot it out. It looks very close but there are a couple of spike anomolies. If indicator on the top is reading an SMA indicator from ninjatrader and the indicator on the bottom is reading and SMA indicator from ninjatrader How can I get different information.

    secondly i tried to manually make an sma algorithm to see if it gives the same information.

    double FindSMA(int nPeriod)
    {

    double dSMA = 0;

    for(int x= 0; x< nPeriod; x++)
    {

    dSMA = dSMA + Close[nPeriod];
    }

    dSMA = (double)dSMA/ nPeriod;

    return dSMA;
    }


    This gives totally different information than what Ninjatrader shows. My charts are not the same.

    Lastly what are these parameters

    double last = Value[1] * Math.Min(CurrentBar, Period);

    if (CurrentBar >= Period)
    Value.Set((last + Input[0] - Input[Period]) / Math.Min(CurrentBar, Period));
    else
    Value.Set((last + Input[0]) / (Math.Min(CurrentBar, Period) + 1));


    What is Value[1]; ???

    What is Input[0]; ???

    If the pictures below are both Ninjatrader SMA indicators then why is the plotting anomalies exist

    Formula SMA(120)[0];
    Attached Files
    Last edited by ballboy11; 10-09-2017, 07:07 AM.

    #2
    Hello ballboy11,

    Thank you for your note.

    The calculation to get the SMA is the same.

    I'm not sure what you are trying to achieve through writing your own SMA method vs using Ninja's however I would suggest you add print statements to your for loop to identify your mistake.

    Please let us know if you need further assistance.
    Alan P.NinjaTrader Customer Service

    Comment


      #3
      Thank you.


      Last question is what is

      What is Value[1]; ???

      What is Input[0]; ???

      Comment


        #4
        Hello Ballboy11,

        Please see Input and Values at the following link,
        https://ninjatrader.com/support/help..._reference.htm

        Please let us know if you need further assistance.
        Alan P.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by jrm999, Today, 07:44 PM
        0 responses
        2 views
        0 likes
        Last Post jrm999
        by jrm999
         
        Started by Iargo, Today, 05:53 PM
        0 responses
        3 views
        0 likes
        Last Post Iargo
        by Iargo
         
        Started by kadan, Today, 05:24 PM
        1 response
        5 views
        0 likes
        Last Post kadan
        by kadan
         
        Started by mntemel, Today, 04:17 PM
        0 responses
        8 views
        0 likes
        Last Post mntemel
        by mntemel
         
        Started by guigs88, Today, 02:57 PM
        2 responses
        4 views
        0 likes
        Last Post guigs88
        by guigs88
         
        Working...
        X