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

Indictor wont plot the time in the output window

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

    Indictor wont plot the time in the output window

    I am using an indicator to print EMA values in the output window but I currently it just shows the date and the value NOT the time. Is there a way to get it to show the time as well as the date.

    Here is the script. Thanks in advance.

    #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>
    ///
    /// </summary>
    [Description("")]
    public class WilliamsRValuePrint : Indicator
    {
    #region Variables

    #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()
    {
    //double rsiValue = WilliamsR(40)[0]; RSI(Median, 14, 1)[0];

    //double rsiValue = CashCloseES().PriorClose[0];
    double rsiValue = EMA(200)[0];
    // Prints whatever indicator etc value against the timestamp.
    Print("" + Time[0].ToShortDateString() + "" + "," + rsiValue.ToString("N2"));


    //Produces comma separated file for data export and ##-## file update.
    //Print(Time[0]+ "," +Open[0]+ ","+High[0]+ ","+Low[0]+ ","+Close[0]+ ","+Volume[0]);


    Plot0.Set(rsiValue);
    }

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

    #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 WilliamsRValuePrint[] cacheWilliamsRValuePrint = null;

    private static WilliamsRValuePrint checkWilliamsRValuePrint = new WilliamsRValuePrint();

    /// <summary>
    ///
    /// </summary>
    /// <returns></returns>
    public WilliamsRValuePrint WilliamsRValuePrint()
    {
    return WilliamsRValuePrint(Input);
    }

    /// <summary>
    ///
    /// </summary>
    /// <returns></returns>
    public WilliamsRValuePrint WilliamsRValuePrint(Data.IDataSeries input)
    {
    if (cacheWilliamsRValuePrint != null)
    for (int idx = 0; idx < cacheWilliamsRValuePrint.Length; idx++)
    if (cacheWilliamsRValuePrint[idx].EqualsInput(input))
    return cacheWilliamsRValuePrint[idx];

    lock (checkWilliamsRValuePrint)
    {
    if (cacheWilliamsRValuePrint != null)
    for (int idx = 0; idx < cacheWilliamsRValuePrint.Length; idx++)
    if (cacheWilliamsRValuePrint[idx].EqualsInput(input))
    return cacheWilliamsRValuePrint[idx];

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

    WilliamsRValuePrint[] tmp = new WilliamsRValuePrint[cacheWilliamsRValuePrint == null ? 1 : cacheWilliamsRValuePrint.Length + 1];
    if (cacheWilliamsRValuePrint != null)
    cacheWilliamsRValuePrint.CopyTo(tmp, 0);
    tmp[tmp.Length - 1] = indicator;
    cacheWilliamsRValuePrint = 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>
    ///
    /// </summary>
    /// <returns></returns>
    [Gui.Design.WizardCondition("Indicator")]
    public Indicator.WilliamsRValuePrint WilliamsRValuePrint()
    {
    return _indicator.WilliamsRValuePrint(Input);
    }

    /// <summary>
    ///
    /// </summary>
    /// <returns></returns>
    public Indicator.WilliamsRValuePrint WilliamsRValuePrint(Data.IDataSeries input)
    {
    return _indicator.WilliamsRValuePrint(input);
    }
    }
    }

    // This namespace holds all strategies and is required. Do not change it.
    namespace NinjaTrader.Strategy
    {
    public partial class Strategy : StrategyBase
    {
    /// <summary>
    ///
    /// </summary>
    /// <returns></returns>
    [Gui.Design.WizardCondition("Indicator")]
    public Indicator.WilliamsRValuePrint WilliamsRValuePrint()
    {
    return _indicator.WilliamsRValuePrint(Input);
    }

    /// <summary>
    ///
    /// </summary>
    /// <returns></returns>
    public Indicator.WilliamsRValuePrint WilliamsRValuePrint(Data.IDataSeries input)
    {
    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.WilliamsRValuePrint(input);
    }
    }
    }
    #endregion

    #2
    GKonheiser,

    Time[0] is the complete time stamp with both date and time. If you want date and time, remove this: ToShortDateString()
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Ryan your a star thank you. : )

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by algospoke, Yesterday, 06:40 PM
      2 responses
      23 views
      0 likes
      Last Post algospoke  
      Started by ghoul, Today, 06:02 PM
      3 responses
      14 views
      0 likes
      Last Post NinjaTrader_Manfred  
      Started by jeronymite, 04-12-2024, 04:26 PM
      3 responses
      45 views
      0 likes
      Last Post jeronymite  
      Started by Barry Milan, Yesterday, 10:35 PM
      7 responses
      21 views
      0 likes
      Last Post NinjaTrader_Manfred  
      Started by AttiM, 02-14-2024, 05:20 PM
      10 responses
      181 views
      0 likes
      Last Post jeronymite  
      Working...
      X