I tried the following but observed that it was not plotted live. I have to reload the indicator then it started to show on chart.Advice needed. Thanks!
#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>
[Description("Breakout System")]
public class NTMTSGetBarUS : Indicator
{
#region Variables
// Wizard generated variables
// User defined variables (add any user defined variables below)
private bool RedBars;
private double op01;
#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 (PeriodType.Minute,30);
CalculateOnBarClose = false;
Overlay = true;
PriceTypeSupported = false;
}
private DateTime startDateTime01;
private DateTime endDateTime01;
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
startDateTime01 = new DateTime(Time[0].Year, Time[0].Month, Time[0].Day, 13, 00, 0);
endDateTime01 = new DateTime(Time[0].Year, Time[0].Month, Time[0].Day, 13, 30, 0);
int startBarsAgo01 = GetBar(startDateTime01);
int endBarsAgo01 = GetBar( endDateTime01);
if(BarsInProgress ==1)
if( ToTime(Time[0]) == 133000 )
{
op01 = Open[0];
}
DrawLine("Rega01", false, startBarsAgo01, op01 , endBarsAgo01 ,op01, Color.Pink, DashStyle.Dot, 3);
{
if (ToTime(Time[0]) >= 80000 && ToTime(Time[0]) < 83000 ||
ToTime(Time[0]) >= 90000 && ToTime(Time[0]) < 93000 ||
ToTime(Time[0]) >= 100000 && ToTime(Time[0]) <103000 ||
ToTime(Time[0]) >= 110000 && ToTime(Time[0]) <113000 ||
ToTime(Time[0]) >= 120000 && ToTime(Time[0]) <123000 ||
ToTime(Time[0]) >= 130000 && ToTime(Time[0]) <133000 ||
ToTime(Time[0]) >= 140000 && ToTime(Time[0]) <143000 ||
ToTime(Time[0]) >= 150000 && ToTime(Time[0]) <153000 ||
ToTime(Time[0]) >= 160000 && ToTime(Time[0]) <163000 ||
ToTime(Time[0]) >= 170000 && ToTime(Time[0]) <173000 ||
ToTime(Time[0]) >= 180000 && ToTime(Time[0]) <183000 ||
ToTime(Time[0]) >= 190000 && ToTime(Time[0]) <193000 ||
ToTime(Time[0]) >= 200000 && ToTime(Time[0]) <203000 ||
ToTime(Time[0]) >= 210000 && ToTime(Time[0]) <213000 ||
ToTime(Time[0]) >= 220000 && ToTime(Time[0]) <223000 )
{RedBars = true;} else RedBars = false;
if (RedBars) BarColor = Color.Yellow;
}
}
#region Properties
#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 NTMTSGetBarUS[] cacheNTMTSGetBarUS = null;
private static NTMTSGetBarUS checkNTMTSGetBarUS = new NTMTSGetBarUS();
/// <summary>
/// Breakout System
/// </summary>
/// <returns></returns>
public NTMTSGetBarUS NTMTSGetBarUS()
{
return NTMTSGetBarUS(Input);
}
/// <summary>
/// Breakout System
/// </summary>
/// <returns></returns>
public NTMTSGetBarUS NTMTSGetBarUS(Data.IDataSeries input)
{
if (cacheNTMTSGetBarUS != null)
for (int idx = 0; idx < cacheNTMTSGetBarUS.Length; idx++)
if (cacheNTMTSGetBarUS[idx].EqualsInput(input))
return cacheNTMTSGetBarUS[idx];
lock (checkNTMTSGetBarUS)
{
if (cacheNTMTSGetBarUS != null)
for (int idx = 0; idx < cacheNTMTSGetBarUS.Length; idx++)
if (cacheNTMTSGetBarUS[idx].EqualsInput(input))
return cacheNTMTSGetBarUS[idx];
NTMTSGetBarUS indicator = new NTMTSGetBarUS();
indicator.BarsRequired = BarsRequired;
indicator.CalculateOnBarClose = CalculateOnBarClose;
#if NT7
indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256;
indicator.MaximumBarsLookBack = MaximumBarsLookBack;
#endif
indicator.Input = input;
Indicators.Add(indicator);
indicator.SetUp();
NTMTSGetBarUS[] tmp = new NTMTSGetBarUS[cacheNTMTSGetBarUS == null ? 1 : cacheNTMTSGetBarUS.Length + 1];
if (cacheNTMTSGetBarUS != null)
cacheNTMTSGetBarUS.CopyTo(tmp, 0);
tmp[tmp.Length - 1] = indicator;
cacheNTMTSGetBarUS = 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>
/// Breakout System
/// </summary>
/// <returns></returns>
[Gui.Design.WizardCondition("Indicator")]
public Indicator.NTMTSGetBarUS NTMTSGetBarUS()
{
return _indicator.NTMTSGetBarUS(Input);
}
/// <summary>
/// Breakout System
/// </summary>
/// <returns></returns>
public Indicator.NTMTSGetBarUS NTMTSGetBarUS(Data.IDataSeries input)
{
return _indicator.NTMTSGetBarUS(input);
}
}
}
// This namespace holds all strategies and is required. Do not change it.
namespace NinjaTrader.Strategy
{
public partial class Strategy : StrategyBase
{
/// <summary>
/// Breakout System
/// </summary>
/// <returns></returns>
[Gui.Design.WizardCondition("Indicator")]
public Indicator.NTMTSGetBarUS NTMTSGetBarUS()
{
return _indicator.NTMTSGetBarUS(Input);
}
/// <summary>
/// Breakout System
/// </summary>
/// <returns></returns>
public Indicator.NTMTSGetBarUS NTMTSGetBarUS(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.NTMTSGetBarUS(input);
}
}
}
#endregion

Comment