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 fx.practic, 10-15-2013, 12:53 AM
        5 responses
        5,406 views
        0 likes
        Last Post Bidder
        by Bidder
         
        Started by Shai Samuel, 07-02-2022, 02:46 PM
        4 responses
        98 views
        0 likes
        Last Post Bidder
        by Bidder
         
        Started by DJ888, Yesterday, 10:57 PM
        0 responses
        8 views
        0 likes
        Last Post DJ888
        by DJ888
         
        Started by MacDad, 02-25-2024, 11:48 PM
        7 responses
        160 views
        0 likes
        Last Post loganjarosz123  
        Started by Belfortbucks, Yesterday, 09:29 PM
        0 responses
        9 views
        0 likes
        Last Post Belfortbucks  
        Working...
        X