Hi,
I'm fairly new to NT8 and have issues with the following script.
1. It basically seem to mark all the bars even if they don't mee dthe conditions
2. Also it doesn't seem to mark short trades and long only.
Could you please kindly take a look at the following code and tell me where I've got it wrong?
Here is what I would like the script to do (meet all the conditions):
Low of current bar is below previous bar low
AND
High of previous bar is above previous bar close
AND
High of prev. bar is above 2 bars ago bar high
AND
Low of prev bar is above 2 bars ago bar Low
AND
Previous bar closes within bottom 30% of it's range
If all conditions are true than place an indicator 1 tick above the Low of previous bar. This will indicate where to go short and that's where the LMT entry order is going to be placed
Of course oposite would mark a long trade
if (State == State.SetDefaults)
{
Description = @"Enter the description for your new custom Indicator here.";
Name = "TestSignal";
Calculate = Calculate.OnPriceChange;
IsOverlay = true;
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;
BarsBack = 2;
AddPlot(Brushes.Orange, "EntryPlotLong");//This is Values[0][0]
AddPlot(Brushes.Blue, "EntryPlotShort");//This is Values[1][0]
}
else if (State == State.Configure)
{
}
}
protected override void OnBarUpdate()
{
//Add your custom indicator logic here.
if (CurrentBars[0] < BarsRequiredToPlot)//This just makes sure there are enough bars on the chart. Learn this stff by hitting F1 in NT8 and read help file.
return;
if ((Low[0] < Low [1]) && (High[1] > Close [1]) && (High[1] > High [2]) && (Low[1] > Low [2]) && ((High [1] - Close[1])) < ((High[1] - Low[1]) * 0.3) )
Values[0][1] = (Low[1] + 1 * TickSize);
Values[0][0] = Low[1];
if ((High[0] > High [1]) && (Low[1] < Close [1]) && (Low[1] > Low [2]) && (High[1] < High [2]) && ((High [1] - Close[1])) > ((High[1] - Low[1]) * 0.3) )
Values[0][1] = (High[1] - 1 * TickSize);
Values[0][0] = High[1];
}

Comment