Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

IndicatorReversal2

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

    IndicatorReversal2

    I've been trying over a week to get an indicator to work-so far no luck at all-here is he current----

    #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 IndicatorReversal2 : Indicator
    {
    #region Variables
    // Wizard generated variables
    private int myInput0 = 6; // Default setting for MyInput0
    private int myInput1 = 12; // Default setting for MyInput1
    // 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.Red), PlotStyle.Dot, "Plot0"));
    Add(new Plot(Color.FromKnownColor(KnownColor.Green), PlotStyle.Line, "Plot1"));
    CalculateOnBarClose = false;
    Overlay = false;
    PriceTypeSupported = false;
    }


    protected override void OnBarUpdate()
    {

    Plot0.Set(MyInput[0] > MyInput1[1]);
    Plot1.Set(MyInput[0] < MyInput1[1]);
    }

    #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]; }
    }

    [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 Plot1
    {
    get { return Values[1]; }
    }

    [Description("")]
    [Category("Parameters")]
    public int MyInput0
    {
    get { return myInput0; }
    set { myInput0 = Math.Max(1, value); }
    }

    [Description("")]
    [Category("Parameters")]
    public int MyInput1
    {
    get { return myInput1; }
    set { myInput1 = Math.Max(1, value); }
    }
    #endregion
    }
    }

    #2
    These lines here may need some modification:
    Plot0.Set(MyInput[0] > MyInput1[1]);
    Plot1.Set(MyInput[0] < MyInput1[1]);

    If you are trying to set a value to the plots based on those conditions you would do something like this:
    Code:
    if (MyInput[0] > MyInput1[1])
         Plot0.Set(1); // 1 is some arbitrary value. You can put what you want here and it will plot that value for you.
    if (MyInput[0] < MyInput1[1])
         Plot1.Set(1);
    Because you are using an index of 1 to check the previous bar's value you will also need to be mindful of this tip: http://www.ninjatrader-support.com/v...ead.php?t=3170
    Josh P.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    574 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    332 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    101 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    553 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    551 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X