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

Smoothed StdError Development

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

    Smoothed StdError Development

    I'm trying to write an EMA of StdError. What I get is a line that seems to simply touch the close of each bar. I used the Indicator Wizard. My only input for the Wizard was a Period of 20. Could anyone spot what I've done wrong? Thanks for the help. Here's the code.


    // This namespace holds all indicators and is required. Do not change it.
    namespace NinjaTrader.Indicator
    {
    /// <summary>
    /// EMA of Standard Error
    /// </summary>
    [Description("EMA of Standard Error")]
    public class StdErrorSmoothed : Indicator
    {
    #region Variables
    // Wizard generated variables
    private int period = 20; // Default setting for Period
    // User defined variables (add any user defined variables below)
    #endregion

    /// <summary>
    /// This method is used to configure the indicator and is called once before any bar data is loaded.
    /// </summary>
    protected override void Initialize()
    {
    Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line, "Plot0"));
    Overlay = false;
    }

    /// <summary>
    /// Called on each bar update event (incoming tick)
    /// </summary>
    protected override void OnBarUpdate()
    {
    // Calculate the standard error average
    double average = EMA(StdError(30), Period)[0];

    Plot0.Set(Close[0]);
    }

    #region Properties
    [Browsable(false)] // this line prevents the data series from being displayed in the indicator properties dialog, do not remove
    [XmlIgnore()] // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
    public DataSeries Plot0
    {
    get { return Values[0]; }
    }

    [Description("Period of EMA")]
    [GridCategory("Parameters")]
    public int Period
    {
    get { return period; }
    set { period = Math.Max(1, value); }
    }
    #endregion
    }
    }

    #2
    Originally posted by pjwinner View Post
    I'm trying to write an EMA of StdError. What I get is a line that seems to simply touch the close of each bar. I used the Indicator Wizard. My only input for the Wizard was a Period of 20. Could anyone spot what I've done wrong? Thanks for the help. Here's the code.


    // This namespace holds all indicators and is required. Do not change it.
    namespace NinjaTrader.Indicator
    {
    /// <summary>
    /// EMA of Standard Error
    /// </summary>
    [Description("EMA of Standard Error")]
    public class StdErrorSmoothed : Indicator
    {
    #region Variables
    // Wizard generated variables
    private int period = 20; // Default setting for Period
    // User defined variables (add any user defined variables below)
    #endregion

    /// <summary>
    /// This method is used to configure the indicator and is called once before any bar data is loaded.
    /// </summary>
    protected override void Initialize()
    {
    Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line, "Plot0"));
    Overlay = false;
    }

    /// <summary>
    /// Called on each bar update event (incoming tick)
    /// </summary>
    protected override void OnBarUpdate()
    {
    // Calculate the standard error average
    double average = EMA(StdError(30), Period)[0];

    Plot0.Set(Close[0]);
    }

    #region Properties
    [Browsable(false)] // this line prevents the data series from being displayed in the indicator properties dialog, do not remove
    [XmlIgnore()] // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
    public DataSeries Plot0
    {
    get { return Values[0]; }
    }

    [Description("Period of EMA")]
    [GridCategory("Parameters")]
    public int Period
    {
    get { return period; }
    set { period = Math.Max(1, value); }
    }
    #endregion
    }
    }
    It is doing what you told it to do.
    Code:
    Plot0.Set(Close[0]);
    If you want to plot the average, then tell it to plot the average.
    Code:
    Plot0.Set(average);

    Comment


      #3
      Thanks for your help. It's always embarrassing to have the obvious pointed out!

      Comment


        #4
        Originally posted by pjwinner View Post
        Thanks for your help. It's always embarrassing to have the obvious pointed out!
        Do not be embarrassed. You will be surprised how long I sometimes spend troubleshooting, only to find what is, in hindsight only, an obvious error.

        As they say, "hindsight is 20/20".

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by inanazsocial, Today, 01:15 AM
        1 response
        6 views
        0 likes
        Last Post NinjaTrader_Jason  
        Started by rocketman7, Today, 02:12 AM
        0 responses
        10 views
        0 likes
        Last Post rocketman7  
        Started by dustydbayer, Today, 01:59 AM
        0 responses
        2 views
        0 likes
        Last Post dustydbayer  
        Started by trilliantrader, 04-18-2024, 08:16 AM
        5 responses
        23 views
        0 likes
        Last Post trilliantrader  
        Started by Davidtowleii, Today, 12:15 AM
        0 responses
        3 views
        0 likes
        Last Post Davidtowleii  
        Working...
        X