@SleepyZ - could you also help with a scanner for this (when the price crosses pp, ps1, ps2, ps3, pr1, pr2 or pr2?? ). I tried but it does seem to work. I am trading on 5m timeframe. Tried the following code.
Also see attached thinkorswim scanner setting (Timeframe is set to "Day" since the aggregation time is Day in the code)
##scanner code##
# IB_Fib_Pivots
# Author: Kory Gill,
@korygill
#
# VERSION HISTORY (sortable date and time (your local time is fine), and your initials
# 20190906-1900-KG - Created.
# ...
# ...
declare hide_on_daily;
declare once_per_bar;
input AggregationPeriod = AggregationPeriod.DAY;
#
# logic
#
def nan = Double.NaN;
def isRollover = GetYYYYMMDD() != GetYYYYMMDD()[1];
def beforeStart = GetTime() < RegularTradingStart(GetYYYYMMDD());
def afterEnd = GetTime() > RegularTradingEnd(GetYYYYMMDD());
def firstBarOfDay = if (beforeStart[1] == 1 and beforeStart == 0) or (isRollover and beforeStart == 0) then 1 else 0;
def lastBarOfDay = if
(afterEnd[-1] == 1 and afterEnd == 0) or
(isRollover[-1] and firstBarOfDay[-1])
then 1
else 0;
#
# See this page for how to calculate the indicator
#
https://www.interactivebrokers.com/...k/technicalanalytics/fibonaccipivotpoints.htm
# Pivot Point (P) = (High + Low + Close)/3
# Support 1 (S1) = P - {.382 * (High - Low)}
# Support 2 (S2) = P - {.618 * (High - Low)}
# Support 3 (S3) = P - {1 * (High - Low)}
# Resistance 1 (R1) = P + {.382 * (High - Low)}
# Resistance 2 (R2) = P + {.618 * (High - Low)}
# Resistance 3 (R3) = P + {1 * (High - Low)}
#
def pc = close(period = AggregationPeriod)[1];
def ph = high(period = AggregationPeriod)[1];
def pl = low(period = AggregationPeriod)[1];
#Pivot Point (P) = (High + Low + Close)/3
#Support 1 (S1) = P - {.382 * (High - Low)}
#Support 2 (S2) = P - {.618 * (High - Low)}
#Support 3 (S3) = P - {1 * (High - Low)}
#Resistance 1 (R1) = P + {.382 * (High - Low)}
#Resistance 2 (R2) = P + {.618 * (High - Low)}
#Resistance 3 (R3) = P + {1 * (High - Low)}
def delta = ph - pl;
def pp = if firstBarOfDay then (pc+ph+pl)/3 else if lastBarOfDay then nan else pp[1];
def s1 = if firstBarOfDay then pp - (.382 * delta) else if lastBarOfDay then nan else s1[1];
def s2 = if firstBarOfDay then pp - (.618 * delta) else if lastBarOfDay then nan else s2[1];
def s3 = if firstBarOfDay then pp - (1 * delta) else if lastBarOfDay then nan else s3[1];
def r1 = if firstBarOfDay then pp + (.382 * delta) else if lastBarOfDay then nan else r1[1];
def r2 = if firstBarOfDay then pp + (.618 * delta) else if lastBarOfDay then nan else r2[1];
def r3 = if firstBarOfDay then pp + (1 * delta) else if lastBarOfDay then nan else r3[1];
def ppp = pp;
def ps1 = s1;
def ps2 = s2;
def ps3 = s3;
def pr1 = r1;
def pr2 = r2;
def pr3 = r3;
plot scan = (close crosses pp) or (close crosses s1) or (close crosses s2)
or (close crosses s3) or (close crosses r1) or (close crosses r2)
or (close crosses r3);