I've tried the following code below. The barsAgo variable is producing the correct bars ago from the input start time, but the hh and ll produced are totally off, they sare not even in the range of the day. Can you please le tme know what is wrong with the MIN MAX statements and how I can fix it.
amespace NinjaTrader.NinjaScript.Indicators
{
public class MyCustomIndicator1 : Indicator
{
protected override void OnStateChange()
{
if (State == State.SetDefaults)
{
Description = @"Enter the description for your new custom Indicator here.";
Name = "MyCustomIndicator1";
Calculate = Calculate.OnBarClose;
IsOverlay = false;
DisplayInDataBox = true;
DrawOnPricePanel = true;
DrawHorizontalGridLines = true;
DrawVerticalGridLines = true;
PaintPriceMarkers = true;
ScaleJustification = NinjaTrader.Gui.Chart.ScaleJustification.Right;
//Disable this property if your indicator requires custom values that cumulate with each new market data event.
//See Help Guide for additional information.
IsSuspendedWhileInactive = true;
}
else if (State == State.Configure)
{
}
}
protected override void OnBarUpdate()
{
int barsAgo = CurrentBar - Bars.GetBar(new DateTime (Time[0].Year, Time[0].Month, Time[0].Day, StartHour, StartMinute, 0));
Print(barsAgo);
double ll = MIN(Low, CurrentBar - barsAgo +1)[CurrentBar] ;
double hh = MAX(High, CurrentBar - barsAgo +1)[CurrentBar] ;
Print(ll);
Print(hh);
Draw.HorizontalLine(this, "alertlinehh", hh , Brushes.Yellow);
Draw.HorizontalLine(this, "alertlinell", ll , Brushes.Yellow);
}
#region Properties
[Range(0,23)]
[NinjaScriptProperty]
[Display(Name="Start hour", Description = "Enter start hour, Military time format 0 - 23", Order=1, GroupName="Parameters")]
public int StartHour
{ get; set; }
[Range(0, 59)]
[NinjaScriptProperty]
[Display(Name="Start minute", Description = "Enter start minute(s) 0 - 59",Order=2, GroupName="Parameters")]
public int StartMinute
{ get; set; }
#endregion
Comment