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

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 DJ888, 04-16-2024, 06:09 PM
    4 responses
    12 views
    0 likes
    Last Post DJ888
    by DJ888
     
    Started by terofs, Today, 04:18 PM
    0 responses
    8 views
    0 likes
    Last Post terofs
    by terofs
     
    Started by nandhumca, Today, 03:41 PM
    0 responses
    6 views
    0 likes
    Last Post nandhumca  
    Started by The_Sec, Today, 03:37 PM
    0 responses
    3 views
    0 likes
    Last Post The_Sec
    by The_Sec
     
    Started by GwFutures1988, Today, 02:48 PM
    1 response
    9 views
    0 likes
    Last Post NinjaTrader_Clayton  
    Working...
    X