# The Logical Trader's Pivot Range Indicator for ThinkorSwim

#### BenTen

Staff
VIP
My first attempt to code something. It's Mark Fischer concept of Pivot Range from his book Logical Trader. The strategy for using it is actually from Frank Ochoa's book Secrets of a Pivot Boss. Pivot Range is the "meat of the market" and "the heart beat of the market" according to him.

Here are some interesting details I found about the Pivot Range:
The Pivot Range is a confluence area that identifies where the market is likely to find support or encounter resistance based on the prior day’s trading. The Pivot Range identifies the areas where buyers are likely to show up (which is support) and where sellers are likely to show up (which is resistance). The Pivot Range will also help you to see an area where a significant move could occur if price can break through that area.

The key point to note is that the Pivot Range should give support at this price zone enabling you to take a long position with a defined low risk stop. If price is able to break below the Pivot Range then support would be broken and you would want to exit your trade.

A close above the range is bullish and a close below is bearish • A pivot range above the market is resistance and below the market is support • If the market moves through the pivot range you could expect a significant move in that direction. Trade Against The Pivot—You can use the pivot range to establish a position. The pivot range will act as support/resistance. If a stock opens above the pivot range and sells off to the range you can establish a long at the top of the pivot range. If a stock opens below the pivot range you can establish a short at the bottom of the pivot range. Your stop would be on the other side of the pivot range.

### thinkScript Code

Code:
``````# Logical Trader's Pivot Range
# Assembled by BenTen at useThinkScript.com

input aggregationPeriod = AggregationPeriod.DAY;

def PH = high(period = aggregationPeriod);
def PL = low(period = aggregationPeriod);
def PC = close(period = aggregationPeriod);

def pivot = (PH + PL + PC) / 3.0;
def bc = (PH + PL) / 2.0;
def tc = (pivot - bc) + pivot;

plot l1 = pivot[1];
plot l2 = bc[1];
plot l3 = tc[1];

l1.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
l1.SetDefaultColor(Color.white);
l1.SetLineWeight(1);
l2.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
l2.SetDefaultColor(Color.CYAN);
l2.SetLineWeight(1);
l3.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
l3.SetDefaultColor(Color.MAGENTA);
l3.SetLineWeight(1);``````

#### BuzzKill

##### New member
Thank you @BenTen
I'm getting the correct result for the 1D setting; however, the 3D setting is not plotting correctly--it's presenting much larger/wider (.25 or 41.97 - 40.72) than the data we're getting (.10 or 41.10 - 41.00).
The previous 3 days' (AMD) data: PH = 42.95; PL = 39.04; and PC = 41.15
For the 3D setting my chart is showing 3days (the Script didn't present 3D when the chart is only 1D--logical, right?), the chart is NOT showing Extended-Hours and it is set to start aggregation at OPEN. Suggestions/Thoughts?
Regardless and again, Thank You!

#### BenTen

Staff
VIP
@BuzzKill Any reason why you would adjust to the 3 DAYS setting instead of using the DAY?

#### mc01439

##### Well-known member
2019 Donor
VIP
Nice addition to the tool box. Thank you @BenTen for sharing.

#### BuzzKill

##### New member
I use both the 1D and the 3D during the day.

Without knowing Script would this be correct according to the formula where abs = absolute value?

def pivot1 = (PH + PL + PC) / 3.0;
def pivot2 = (PH + PL) / 2.0;
def pivotT = pivot1 + (abs(pivot2-pivot1))
def pivotB = pivot1 - (abs(pivot2-pivot1))

#### BenTen

Staff
VIP
@BuzzKill Here is the formula from the original script:

Code:
``````def pivot = (PH + PL + PC) / 3.0;
def bc = (PH + PL) / 2.0;
def tc = (pivot - bc) + pivot;``````

#### BuzzKill

##### New member
Understood; and, to your point, 3Day is a non-issue...
THANK YOU!