Pivot Confirmation Indicator for ThinkorSwim

J007RMC

J007RMC

Active member
VIP
Warehouse
Kind of like this script

Code:
# PivotConfirmationScanPlot_JQ
# based on
# Pivot Confirmation Scan
# Nube 12.26.19
#set scan for PivotConfirmation is true

# 01.02.2020  JQ added the bear side, changed some variable names because he is old and can't remember squat, made the arrows bigger because he can't see, and added alerts just because.

# Universals
def vOpen = open;
def vHigh = high;
def vLow = low;
def vClose = close;
def vVWAP = vwap;
def x = BarNumber();


# Bull Pivot and confirmation
input lowerThanPastBarsLength = 5;#hint n: For pivot


def lowestLow = vLow == Lowest(vLow, lowerThanPastBarsLength);
def lowestLowX = if lowestLow then x else Double.NaN;
def lowestLowBar__ = if !IsNaN(lowestLowX) then x else lowestLowBar__[1];

def lowestPivotBarHigh__ = if !IsNaN(lowestLowX) then vHigh else lowestPivotBarHigh__[1];


def bullConfirmation_Count = if lowestLow then 0 else
                         if  x - lowestLowBar__ <= 4 and
                             vClose crosses above lowestPivotBarHigh__
                         then bullConfirmation_Count[1] + 1
                         else bullConfirmation_Count[1];

plot bullPivotConfirmed = bullConfirmation_Count crosses above 0;
bullPivotConfirmed.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
bullPivotConfirmed.SetDefaultColor(Color.UPTICK);
bullPivotConfirmed.SetLineWeight(2);
alert ( bullPivotConfirmed, " Bull Pivot Confirmed ", alert.BAR, Sound.Chimes);

# Bear Pivot and confirmation
input higherThanPastBarsLength = 5;#hint n: For pivot
def highestHigh = vHigh == Highest(vHigh, higherThanPastBarsLength);
def highestHighX = if highestHigh then x else Double.NaN;
def highestHighBar__ = if !IsNaN(highestHighX) then x else highestHighBar__[1];

def highestPivotBarLow__ = if !IsNaN(highestHighX) then vLow else highestPivotBarLow__[1];

def bearConfirmation_Count = if highestHigh then 0 else
                         if  x - highestHighBar__ <= 4 and
                             vClose crosses below highestPivotBarLow__
                         then bearConfirmation_Count[1] + 1
                         else bearConfirmation_Count[1];

plot bearPivotConfirmed = bearConfirmation_Count crosses above 0;
bearPivotConfirmed.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
bearPivotConfirmed.SetDefaultColor(Color.DOWNTICK);
bearPivotConfirmed.SetLineWeight(2);
alert ( bearPivotConfirmed, " Bear Pivot Confirmed ", alert.BAR, Sound.Chimes);

# That's All Folks !
 
Last edited by a moderator:
Algo Patterns

Algo Patterns

New member
Thank you for your contribution helping those who desire to learn how to help themselves for understanding & coding thinkscript for themselves. Does your sample Pivot confirmation code here alert either a bullish or bearish directional Pivot via sound only; visual only or both?

I'll stop with that basic question; don't want to get to ahead of myself. I learn best taking baby steps. Thank you.
 
S

ssara

New member
Hello Experts - Can we add one text to the pivots please -- Time Summation for the pivot.

Say pivot was made at 9:33 ( Just use hour and minutes) - Then add Hour and minute digits = here example is 9+3+3 = 15 so plot 15 below or above the pivot depending on it if was low or high pivot.
 
D

diazlaz

Well-known member
VIP
Warehouse
Kind of like this script

Code:
# PivotConfirmationScanPlot_JQ
# based on
# Pivot Confirmation Scan
# Nube 12.26.19
#set scan for PivotConfirmation is true

# 01.02.2020  JQ added the bear side, changed some variable names because he is old and can't remember squat, made the arrows bigger because he can't see, and added alerts just because.

# Universals
def vOpen = open;
def vHigh = high;
def vLow = low;
def vClose = close;
def vVWAP = vwap;
def x = BarNumber();


# Bull Pivot and confirmation
input lowerThanPastBarsLength = 5;#hint n: For pivot


def lowestLow = vLow == Lowest(vLow, lowerThanPastBarsLength);
def lowestLowX = if lowestLow then x else Double.NaN;
def lowestLowBar__ = if !IsNaN(lowestLowX) then x else lowestLowBar__[1];

def lowestPivotBarHigh__ = if !IsNaN(lowestLowX) then vHigh else lowestPivotBarHigh__[1];


def bullConfirmation_Count = if lowestLow then 0 else
                         if  x - lowestLowBar__ <= 4 and
                             vClose crosses above lowestPivotBarHigh__
                         then bullConfirmation_Count[1] + 1
                         else bullConfirmation_Count[1];

plot bullPivotConfirmed = bullConfirmation_Count crosses above 0;
bullPivotConfirmed.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
bullPivotConfirmed.SetDefaultColor(Color.UPTICK);
bullPivotConfirmed.SetLineWeight(2);
alert ( bullPivotConfirmed, " Bull Pivot Confirmed ", alert.BAR, Sound.Chimes);

# Bear Pivot and confirmation
input higherThanPastBarsLength = 5;#hint n: For pivot
def highestHigh = vHigh == Highest(vHigh, higherThanPastBarsLength);
def highestHighX = if highestHigh then x else Double.NaN;
def highestHighBar__ = if !IsNaN(highestHighX) then x else highestHighBar__[1];

def highestPivotBarLow__ = if !IsNaN(highestHighX) then vLow else highestPivotBarLow__[1];

def bearConfirmation_Count = if highestHigh then 0 else
                         if  x - highestHighBar__ <= 4 and
                             vClose crosses below highestPivotBarLow__
                         then bearConfirmation_Count[1] + 1
                         else bearConfirmation_Count[1];

plot bearPivotConfirmed = bearConfirmation_Count crosses above 0;
bearPivotConfirmed.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
bearPivotConfirmed.SetDefaultColor(Color.DOWNTICK);
bearPivotConfirmed.SetLineWeight(2);
alert ( bearPivotConfirmed, " Bear Pivot Confirmed ", alert.BAR, Sound.Chimes);

# That's All Folks !
@J007RMC thanks for bring this out to our attention. very nice. anyone what to pair this up with a confirmation or entry indicator?
 
Rojo Grande

Rojo Grande

Member
Thank you for your contribution helping those who desire to learn how to help themselves for understanding & coding thinkscript for themselves. Does your sample Pivot confirmation code here alert either a bullish or bearish directional Pivot via sound only; visual only or both?

I'll stop with that basic question; don't want to get to ahead of myself. I learn best taking baby steps. Thank you.
If you open the study using the the customize icon, you will see it has audible alerts than can be toggled on and off.
 

Top