NinjaTrader 8 Wick Rejection Quality Indicator: Closed-Bar Tail Ratio and Close-Location Arrows
Beginner Trading Tutorial · NinjaScript C# · price-action diagnostics
A long candle wick can be visually striking, but it is not automatically evidence of a reversal. A wick may mean a rapid rejection of one price area, or it may simply reflect a volatile session. What matters first is how much of the candle's full range the wick occupies, where the candle actually closes, and whether the body points in the proposed direction.
This article develops a practical NinjaTrader 8 custom chart indicator that marks qualifying completed candles with a green or red arrow. It uses no moving averages, ATR, crossovers, or intrabar alerts. That makes it deliberately different from EMA-cross and volatility-regime scripts: the entire decision is based on transparent OHLC geometry of one closed candle. The indicator is for chart review and research, not an order-entry strategy.
1. From appearance to exact arithmetic
Let H, L, O, and C denote a completed candle's high, low, open, and close. First calculate its full range R = H − L. The lower wick is min(O,C) − L; the upper wick is H − max(O,C). Divide each wick length by R to get the fraction of the candle it represents. Finally compute the close-location fraction (C − L) / R, which runs from 0 at the low to 1 at the high.
A bullish rejection candidate needs its lower wick to occupy at least 55% of the entire range, with the close in the top 20% (close location ≥ 0.80). The completed candle should also finish above its open, by default. The bearish conditions are symmetrical: upper wick ≥ 55%, close location ≤ 0.20, and a bearish candle body. A minimum total range of eight instrument ticks screens out extremely small candles.

2. A reproducible worked example
Consider a hypothetical completed bar with high 105.00, low 100.00, open 102.90, close 104.50. The total range is 5.00. The lower wick is 102.90 − 100.00 = 2.90, so its share is 58%. The upper wick is 105.00 − 104.50 = 0.50, or 10%. The close location is (104.50 − 100.00) / 5.00 = 90%. Since C exceeds O, and assuming the instrument's TickSize makes the 5.00 range at least eight ticks, all bullish checks pass.
Now compare two rejected cases. Bar B has H 105.00, L 100.00, O 102.00, C 104.40. Its lower wick is only 40%, though its close location reaches 88%. It fails the tail-share gate. Bar C has H 105.00, L 100.00, O 103.00, C 103.60: its lower wick is 60%, but the close is only 72% up the range, so it fails the high-close gate. These are intentionally different failure modes; changing one parameter affects one class of rejection differently from the other.

3. Configuration: five inputs with clear responsibilities
| Input | Default | Purpose |
|---|---|---|
| MinRangeTicks | 8 | Skip candles with a high−low range under eight tick increments. |
| MinDominantWickShare | 0.55 | Require the rejection-side wick to occupy at least 55% of the bar. |
| MinExtremeCloseLocation | 0.80 | Bullish closes must be in the top 20%; bearish closes in the bottom 20%. |
| RequireDirectionalBody | true | Bull requires C > O; bear requires C < O. Rejects doji-like ties. |
| ArrowOffsetTicks | 2 | Moves a signal arrow away from the candle extremity for readability. |
TickSize is supplied by the instrument in NinjaTrader. Eight ticks therefore mean a different price distance for different futures, forex, and equities contracts. Lowering the wick-share threshold can increase the number of arrows; raising it generally produces fewer but more visually extreme tails. These are selection changes, not promises of better predictive performance.
4. Complete NinjaScript C# source code
Create an indicator named PSWickRejectionQuality inside the NinjaScript Editor and replace the generated class with the complete listing below. The code uses OnStateChange() to establish defaults, OnBarUpdate() for completed-bar calculations, and Draw.ArrowUp/Draw.ArrowDown for chart marks. No trade orders are submitted.
// PSWickRejectionQuality.cs | NinjaTrader 8 chart indicator
// Closed-bar wick geometry; does not submit orders.
#region Using declarations
using System;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Windows.Media;
using NinjaTrader.NinjaScript;
using NinjaTrader.NinjaScript.DrawingTools;
#endregion
namespace NinjaTrader.NinjaScript.Indicators
{
public class PSWickRejectionQuality : Indicator
{
protected override void OnStateChange()
{
if (State == State.SetDefaults)
{
Description = "Closed-bar wick rejection quality arrows.";
Name = "PSWickRejectionQuality";
Calculate = Calculate.OnBarClose;
IsOverlay = true;
DrawOnPricePanel = true;
DisplayInDataBox = false;
PaintPriceMarkers = false;
IsSuspendedWhileInactive = true;
MinRangeTicks = 8;
MinDominantWickShare = 0.55;
MinExtremeCloseLocation = 0.80;
RequireDirectionalBody = true;
ArrowOffsetTicks = 2;
}
}
protected override void OnBarUpdate()
{
// The completed OnBarClose bar is at barsAgo = 0.
if (CurrentBar < 1)
return;
double h = High[0];
double l = Low[0];
double o = Open[0];
double c = Close[0];
double range = h - l;
if (range <= 0.0 || range < MinRangeTicks * TickSize)
return;
double upperWick = h - Math.Max(o, c);
double lowerWick = Math.Min(o, c) - l;
double upperShare = upperWick / range;
double lowerShare = lowerWick / range;
double closeLocation = (c - l) / range;
bool bull = lowerShare >= MinDominantWickShare
&& closeLocation >= MinExtremeCloseLocation
&& (!RequireDirectionalBody || c > o);
bool bear = upperShare >= MinDominantWickShare
&& closeLocation <= 1.0 - MinExtremeCloseLocation
&& (!RequireDirectionalBody || c < o);
// The unique bar index avoids overwriting older arrows.
if (bull)
Draw.ArrowUp(this, "PSWickUp_" + CurrentBar,
false, 0, l - ArrowOffsetTicks * TickSize,
Brushes.SeaGreen);
else if (bear)
Draw.ArrowDown(this, "PSWickDown_" + CurrentBar,
false, 0, h + ArrowOffsetTicks * TickSize,
Brushes.IndianRed);
}
[Range(1, 1000)]
[NinjaScriptProperty]
[Display(Name = "Minimum candle range (ticks)",
Order = 1, GroupName = "Filters")]
public int MinRangeTicks { get; set; }
[Range(0.01, 1.0)]
[NinjaScriptProperty]
[Display(Name = "Minimum dominant wick share",
Order = 2, GroupName = "Filters")]
public double MinDominantWickShare { get; set; }
[Range(0.50, 1.0)]
[NinjaScriptProperty]
[Display(Name = "Minimum extreme close location",
Order = 3, GroupName = "Filters")]
public double MinExtremeCloseLocation { get; set; }
[NinjaScriptProperty]
[Display(Name = "Require directional candle body",
Order = 4, GroupName = "Filters")]
public bool RequireDirectionalBody { get; set; }
[Range(0, 100)]
[NinjaScriptProperty]
[Display(Name = "Arrow offset (ticks)",
Order = 5, GroupName = "Display")]
public int ArrowOffsetTicks { get; set; }
}
}
5. Why Calculate.OnBarClose matters
With Calculate = Calculate.OnBarClose, NinjaTrader calls the signal logic when a bar closes rather than on each price change. The script evaluates High[0], Low[0], Open[0], and Close[0] for that completed bar; those indices are correct in an OnBarClose callback and should not be mechanically changed to [1]. A new bar's opening tick may be needed before a prior bar's closing event is delivered in real time, depending on bar type and trading hours. On standard historical series, each bar is processed using completed OHLC data.
The CurrentBar index provides a unique drawing tag for each qualifying bar, so newer arrows do not overwrite earlier ones. Importantly, these drawing objects are chart annotations, not indicator numeric plots for trading strategies. If a future automated strategy requires stable machine-readable series, create explicit indicator output series instead of attempting to infer trading orders from drawn arrows.
6. How to install, compare and test
- Open NinjaTrader 8 Control Center → New → NinjaScript Editor → Indicators, then create
PSWickRejectionQuality. - Paste the entire C# listing and compile. If the editor created a separate skeleton with the same class name, replace that skeleton rather than keeping two duplicate classes.
- From a chart, open Indicators, select the new indicator, and use defaults of 8 ticks, 0.55 wick share and 0.80 extreme-close location.
- Identify a bar with an obvious lower or upper tail. Use the Data Box to record H, L, O, C and recalculate both ratios manually.
- Compare the same chart with 0.50 and 0.65 for minimum wick share, while keeping other inputs fixed. List which arrows appear or disappear and why.
- Repeat on at least two instruments and more than one bar type/timeframe. Check thin hours, session transitions, and historical data revisions.
7. Failure modes and sensible extensions
News-spike candles: extreme tails often occur during rapid price discovery. A long wick does not guarantee that the rejected level will hold. Tick-size mismatch: a minimum range that is reasonable on one contract may be too restrictive on another. Visual selection bias: a few beautiful examples may not survive a full sample that includes failed signals, spread, slippage, and commission. No trend context: an attractive lower-tail reversal against a persistent selloff could fail quickly.
Research extensions could include a higher-timeframe context filter, a minimum body size, a location-based support/resistance reference, or a post-signal outcome table. Introduce one new condition at a time and explicitly retest it. A clean research process records the full sample, not just the winning arrows.
If this free example sparks an idea for an alert, a data-series output, or a custom integration, learn about Custom Trading Software Development Services to discuss a tailored implementation.
Educational code only. This analysis is not investment advice and does not imply trading profitability. The C# source has been checked against the documented NinjaScript API pattern, but it has not been compiled in your NinjaTrader installation; confirm build results and indicator behavior locally before use.