BarRange Percentile Indicator for ThinkorSwim

BenTen

BenTen

Administrative
Staff
VIP
Here is a minimal port of the BarRange Percentile indicator from TradingView. I thought it was very interesting. Paintbars and arrows are being plotted by default. You can easily turn either one off via the indicator's setting—no need to touch the code. The up arrows are there to help you with the scanner and also to help identify the candle in case you don't want the painrbars.

I know a Trader that went 18 months without a losing trade. This Trader averaged trading 700-800 contracts per month in the Futures markets.

The was not his only system but here were his rules.

He looked at the 60 minute bar and calculated the ranges of the bars over the last 3 months. IF the range of the Bar was Greater Than the 99th Percentile, He would Fade that move or take the trade in the opposite direction.

Thought process is If the Price Bar is Greater Than the 99th Percentile then typically the market reverses. This happens a lot of times at news events. If you’ve studied the markets long enough you know if a Nes based event causes a Huge Move, which we define as Greater than the 99th Percentile, the Market typically moves in the opposite direction.

***This is dependent on the Instrument your trading and the time frame your trading. Some Instruments and time frames this signals a continuation move.

I also added in the Low of the Range based on the 99th Percentile. Often times Low Range Bars…especially if they appear at the top of a swing move, or the bottom of a swing move…create a high probability entry once the High or Low of the bar is taken out in the opposite direction of the previous move…The Low Range bars show indecision after a strong move and create great reversal opportunities.

Works on All Time Frames…again depending on the instrument your trading.

On instruments that MOVE or have High Volatility like Crude and Oil you can get great signals on 1 minute bars.


Code:
# BarRange Percentile
# Assembled by BenTen at useThinkScript.com
# Converted from https://www.tradingview.com/script/7yipPVGl-CM-BarRange-Percentile/

input paintbars = yes;
input arrows = yes;

input lb = 60;
input ph = 0.99;
input pl = 1.01;

def range = high - low;

def rangeHigh = (highest(range, lb)) * ph;
def rangeHighPlot = range > rangeHigh;
def rangeHighPlot2 = rangeHighPlot * range;
def rangeLow = (lowest(range, lb)[1]) * pl;
def rangeLowPlot = range < rangeLow;
def rangeLowPlot2 = rangeLowPlot;

# 50% Value of Range
def averageRange = (rangeHigh + rangeLow) / 2;

assignPriceColor(if paintbars and rangeHighPlot then Color.Yellow else if paintbars and rangeLowPlot then Color.MAGENTA else if paintbars then Color.WHITE else color.Current);

# Warning: arrows does not suggest the direction of the move. Solely there to help with using the scanner.

plot rangeHigh_scan = if arrows and rangeHighPlot then rangeHighPlot else double.nan;
rangeHigh_scan.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
rangeHigh_scan.SetDefaultColor(Color.CYAN);

plot rangeLow_scan = if arrows and rangeLowPlot then rangeLowPlot else double.nan;
rangeLow_scan.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
rangeLow_scan.SetDefaultColor(Color.MAGENTA);
 

Top