Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Draw horizontal line from time 1 to time 2

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

    Draw horizontal line from time 1 to time 2

    Hi ,
    First day using NT and first time trying the NT script by its wizard.Successfully compiled. Could it be a good start?
    Now I've a problem : How can I plot the horizontal lines both from 930 high and low to 1330 then from 1330 high and low to next day 930. Any help will be much appreciated.


    #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>
    /// Breakout of high and low
    /// </summary>
    [Description("Breakout of high and low")]
    public class Breakout : Indicator
    {
    #region Variables
    // Wizard generated variables
    // 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.Orange), PlotStyle.Line, " Hi"));
    Add(new Plot(Color.FromKnownColor(KnownColor.Green), PlotStyle.Line, " Lo"));
    CalculateOnBarClose = true;
    Overlay = true;
    PriceTypeSupported = true;
    }
    /// <summary>
    /// Called on each bar update event (incoming tick)
    /// </summary>
    protected override void OnBarUpdate()
    {
    // Use this method for calculating your indicator values. Assign a value to each
    // plot below by replacing 'Close[0]' with your own formula.
    Hi.Set(High[0]);
    Lo.Set(Low[0]);

    if (ToTime(Time[0]) == 093000 || ToTime(Time[0]) == 133000)
    {
    double myHigh = High[0];
    double myLow = Low[0];
    }

    }
    #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 Hi
    {
    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 Lo
    {
    get { return Values[1]; }
    }
    #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 Breakout[] cacheBreakout = null;
    private static Breakout checkBreakout = new Breakout();
    /// <summary>
    /// Breakout of high and low
    /// </summary>
    /// <returns></returns>
    public Breakout Breakout()
    {
    return Breakout(Input);
    }
    /// <summary>
    /// Breakout of high and low
    /// </summary>
    /// <returns></returns>
    public Breakout Breakout(Data.IDataSeries input)
    {
    if (cacheBreakout != null)
    for (int idx = 0; idx < cacheBreakout.Length; idx++)
    if (cacheBreakout[idx].EqualsInput(input))
    return cacheBreakout[idx];
    Breakout indicator = new Breakout();
    indicator.BarsRequired = BarsRequired;
    indicator.CalculateOnBarClose = CalculateOnBarClose;
    indicator.Input = input;
    indicator.SetUp();
    Breakout[] tmp = new Breakout[cacheBreakout == null ? 1 : cacheBreakout.Length + 1];
    if (cacheBreakout != null)
    cacheBreakout.CopyTo(tmp, 0);
    tmp[tmp.Length - 1] = indicator;
    cacheBreakout = tmp;
    Indicators.Add(indicator);
    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>
    /// Breakout of high and low
    /// </summary>
    /// <returns></returns>
    [Gui.Design.WizardCondition("Indicator")]
    public Indicator.Breakout Breakout()
    {
    return _indicator.Breakout(Input);
    }
    /// <summary>
    /// Breakout of high and low
    /// </summary>
    /// <returns></returns>
    public Indicator.Breakout Breakout(Data.IDataSeries input)
    {
    return _indicator.Breakout(input);
    }
    }
    }
    // This namespace holds all strategies and is required. Do not change it.
    namespace NinjaTrader.Strategy
    {
    public partial class Strategy : StrategyBase
    {
    /// <summary>
    /// Breakout of high and low
    /// </summary>
    /// <returns></returns>
    [Gui.Design.WizardCondition("Indicator")]
    public Indicator.Breakout Breakout()
    {
    return _indicator.Breakout(Input);
    }
    /// <summary>
    /// Breakout of high and low
    /// </summary>
    /// <returns></returns>
    public Indicator.Breakout Breakout(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.Breakout(input);
    }
    }
    }
    #endregion

    #2
    Kelvin,

    You can use DrawLine() after 9:30. DrawLine() has barsAgo parameters for when you want to start drawing the line and when you want to stop. Just stop drawing the line at 13:30 and increment the start barsAgo each step of the way to 13:30.
    Josh P.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by pilotfo, Today, 12:50 PM
    1 response
    8 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by DTSSTS, Today, 11:35 AM
    2 responses
    11 views
    0 likes
    Last Post DTSSTS
    by DTSSTS
     
    Started by sinpeople, Today, 07:20 AM
    2 responses
    9 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by Frank1000, Today, 03:05 AM
    5 responses
    16 views
    0 likes
    Last Post Frank1000  
    Started by fscabrera03, Yesterday, 01:18 PM
    2 responses
    25 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Working...
    X