Announcement

Collapse
No announcement yet.

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 Danila, Today, 04:38 AM
      1 response
      7 views
      0 likes
      Last Post NinjaTrader_Marco  
      Started by sinpeople, Today, 04:38 AM
      0 responses
      7 views
      0 likes
      Last Post sinpeople  
      Started by kiffgj, Today, 04:23 AM
      0 responses
      6 views
      0 likes
      Last Post kiffgj
      by kiffgj
       
      Started by Leeroy_Jenkins, Today, 03:45 AM
      0 responses
      10 views
      0 likes
      Last Post Leeroy_Jenkins  
      Started by Realsmooth3, Yesterday, 09:10 PM
      1 response
      13 views
      0 likes
      Last Post NinjaTrader_Marco  
      Working...
      X