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

Simple indicator

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

    Simple indicator

    Hello

    With your help in the past, i did this indicator.
    How can i define that it show the calculation on the main panel (price chart) instead
    line on the indicator panel
    like (example result) 0.25 on one of the corners
    Thank you

    #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 Ofer : Indicator
    {
    #region Variables
    // Wizard generated variables
    private int myInput0 = 1; // Default setting for MyInput0
    // User defined variables (add any user defined variables below)
    #endregion
    private double X = 0;

    #region Initialize and Terminate
    protected override void Initialize()
    {
    ChartOnly = true;
    Overlay = true;
    CalculateOnBarClose = false;
    //AllowRemovalOfDrawObjects = true;
    }



    #endregion

    protected override void OnBarUpdate()
    {
    X = (Close[0] - Low[0]) / (High[0] - Low[0]);
    Value.Set(X);
    }

    #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("")]
    [GridCategory("Parameters")]
    public int MyInput0
    {
    get { return myInput0; }
    set { myInput0 = Math.Max(1, value); }
    }
    #endregion
    }
    }

    #region NinjaScript generated code. Neither change nor remove.
    // This namespace holds all indicators and is required. Do not change it.
    namespace NinjaTrader.Indicator
    {
    public partial class Indicator : IndicatorBase
    {
    private Ofer[] cacheOfer = null;

    private static Ofer checkOfer = new Ofer();

    /// <summary>
    /// Enter the description of your new custom indicator here
    /// </summary>
    /// <returns></returns>
    public Ofer Ofer(int myInput0)
    {
    return Ofer(Input, myInput0);
    }

    /// <summary>
    /// Enter the description of your new custom indicator here
    /// </summary>
    /// <returns></returns>
    public Ofer Ofer(Data.IDataSeries input, int myInput0)
    {
    if (cacheOfer != null)
    for (int idx = 0; idx < cacheOfer.Length; idx++)
    if (cacheOfer[idx].MyInput0 == myInput0 && cacheOfer[idx].EqualsInput(input))
    return cacheOfer[idx];

    lock (checkOfer)
    {
    checkOfer.MyInput0 = myInput0;
    myInput0 = checkOfer.MyInput0;

    if (cacheOfer != null)
    for (int idx = 0; idx < cacheOfer.Length; idx++)
    if (cacheOfer[idx].MyInput0 == myInput0 && cacheOfer[idx].EqualsInput(input))
    return cacheOfer[idx];

    Ofer indicator = new Ofer();
    indicator.BarsRequired = BarsRequired;
    indicator.CalculateOnBarClose = CalculateOnBarClose;
    #if NT7
    indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256;
    indicator.MaximumBarsLookBack = MaximumBarsLookBack;
    #endif
    indicator.Input = input;
    indicator.MyInput0 = myInput0;
    Indicators.Add(indicator);
    indicator.SetUp();

    Ofer[] tmp = new Ofer[cacheOfer == null ? 1 : cacheOfer.Length + 1];
    if (cacheOfer != null)
    cacheOfer.CopyTo(tmp, 0);
    tmp[tmp.Length - 1] = indicator;
    cacheOfer = tmp;
    return indicator;
    }
    }
    }
    }

    // This namespace holds all market analyzer column definitions and is required. Do not change it.
    namespace NinjaTrader.MarketAnalyzer
    {
    public partial class Column : ColumnBase
    {
    /// <summary>
    /// Enter the description of your new custom indicator here
    /// </summary>
    /// <returns></returns>
    [Gui.Design.WizardCondition("Indicator")]
    public Indicator.Ofer Ofer(int myInput0)
    {
    return _indicator.Ofer(Input, myInput0);
    }

    /// <summary>
    /// Enter the description of your new custom indicator here
    /// </summary>
    /// <returns></returns>
    public Indicator.Ofer Ofer(Data.IDataSeries input, int myInput0)
    {
    return _indicator.Ofer(input, myInput0);
    }
    }
    }

    // This namespace holds all strategies and is required. Do not change it.
    namespace NinjaTrader.Strategy
    {
    public partial class Strategy : StrategyBase
    {
    /// <summary>
    /// Enter the description of your new custom indicator here
    /// </summary>
    /// <returns></returns>
    [Gui.Design.WizardCondition("Indicator")]
    public Indicator.Ofer Ofer(int myInput0)
    {
    return _indicator.Ofer(Input, myInput0);
    }

    /// <summary>
    /// Enter the description of your new custom indicator here
    /// </summary>
    /// <returns></returns>
    public Indicator.Ofer Ofer(Data.IDataSeries input, int myInput0)
    {
    if (InInitialize && input == null)
    throw new ArgumentException("You only can access an indicator with the default input/bar series from within the 'Initialize()' method");

    return _indicator.Ofer(input, myInput0);
    }
    }
    }
    #endregion

    #2
    Hello Oferedry,

    To export a script so that this is simple to share and to attach to a forum post:
    1. Click File -> Utilities -> Export NinjaScript
    2. Enter a unique name for the file in the value for 'File name:'
    3. Select the strategy from the objects list on the left -> click the right facing arrow ">" to add the strategy to the export
    4. Click the 'Export' button -> click 'yes' to add any referenced indicators to the export -> click OK to clear the export location message


    By default your exported file will be in the following location:
    • (My) Documents\NinjaTrader 7\bin\Custom\ExportNinjaScript\<export_file_name.z ip>


    Below is a link to the help guide on Exporting NinjaScripts.
    http://www.ninjatrader.com/support/h...nt7/export.htm


    The Overlay property when set to false will add the indicator to its own panel. When true, the indicator will be added to the panel of the source data series.


    Use ScaleJustification to control which price margin will be used by the indicator.
    Chelsea B.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by BarzTrading, Today, 07:25 AM
    2 responses
    14 views
    1 like
    Last Post BarzTrading  
    Started by devatechnologies, 04-14-2024, 02:58 PM
    3 responses
    19 views
    0 likes
    Last Post NinjaTrader_BrandonH  
    Started by tkaboris, Today, 08:01 AM
    0 responses
    3 views
    0 likes
    Last Post tkaboris  
    Started by EB Worx, 04-04-2023, 02:34 AM
    7 responses
    162 views
    0 likes
    Last Post VFI26
    by VFI26
     
    Started by Mizzouman1, Today, 07:35 AM
    1 response
    10 views
    0 likes
    Last Post NinjaTrader_Gaby  
    Working...
    X