• 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

Failed Swing Indicator

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

    Failed Swing Indicator

    I am trying to create an indicator that will calculate the SMA average of a sepcified period of the High - (Minus) the open of a bar and that value multiplied by 2.8 to plot that line on the chart. Here is how far I got using the Wizard as a start, the compilation is providing a failuer message..

    #region Using declarations
    using System;
    using System.ComponentModel;
    using System.Diagnostics;
    using System.Drawing;
    using System.Drawing.Drawing2D;
    using System.Xml.Serialization;
    using NinjaTrader.Cbi;
    using NinjaTrader.Data;
    using NinjaTrader.Gui.Chart;
    #endregion

    // This namespace holds all indicators and is required. Do not change it.
    namespace NinjaTrader.Indicator
    {
    /// <summary>
    /// Enter the description of your new custom indicator here
    /// </summary>
    [Description("Enter the description of your new custom indicator here")]
    public class FailedSwing : Indicator
    {
    #region Variables
    private int period = 4;
    // Wizard generated variables
    private string defaultInst = @"YM ##-## (Daily)"; // Default setting for DefaultInst
    // 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.RoyalBlue), PlotStyle.Line, "FSwing"));
    Overlay = false;
    }

    /// <summary>
    /// Called on each bar update event (incoming tick)
    /// </summary>
    protected override void OnBarUpdate()
    {
    // Use this method for calculating your indicator values. Assign a value to each
    // plot below by replacing 'Close[0]' with your own formula.
    Value.Set((SMA(High)[0] - SMA (Open)[0])*2.8);
    }

    #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 FSwing
    {
    get { return Values[0]; }
    }

    [Description("")]
    [GridCategory("Parameters")]
    public string DefaultInst
    {
    get { return defaultInst; }
    set { defaultInst = value; }
    }
    #endregion
    }
    }

    #2
    Hello,
    There is not a period set for the SMA. A period must be set for the SMA to calculate.
    I have proved an example of the code for Value.Set() that will compile.
    Code:
    Value.Set((SMA(High, 20)[0] - SMA(Open, 20)[0]) * 2.8);
    If we can be of any other assistance please let us know.
    Cody B.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Conall, Today, 06:11 AM
    1 response
    9 views
    0 likes
    Last Post NinjaTrader_Kate  
    Started by CaptainAmericaXX, Today, 07:41 AM
    1 response
    3 views
    0 likes
    Last Post NinjaTrader_Jim  
    Started by Longhornmark, Today, 07:06 AM
    2 responses
    7 views
    0 likes
    Last Post Longhornmark  
    Started by 2sureshk, Today, 07:29 AM
    0 responses
    5 views
    0 likes
    Last Post 2sureshk  
    Started by uday12, Yesterday, 10:26 PM
    1 response
    5 views
    0 likes
    Last Post NinjaTrader_PaulH  
    Working...
    X