# shared_WP_VL_BW_Fractals
# Created by WP on 8/30/2024
# Variable MA lenght fractals based on the concepts below
# reddit.com - custom_fractal_indicator_for_thinkorswim
# https://usethinkscript.com/threads/bill-williams-fractal-indicator-for-thinkorswim.600/page-2
# the red green arrows signify bill-williams fractal signal (needs more testing to show that they are reliable to make any profits)
# Looks promising but still needs more testing to verify its reliability of correct signals. Fractals have generally a poor reputation..
# 9/2/24, added RTH and volume filter
input fractal_length = 8;
DefineGlobalColor("UFR", CreateColor(161,0,102)); # red
DefineGlobalColor("DFR", CreateColor(0,153,153)); # green
def up_cond1 = high == Highest(high, fractal_length);
def up_cond2 = high > Highest(high, fractal_length)[fractal_length];
def up_cond3 = if close[-fractal_length] then high > Highest(high, fractal_length)[-fractal_length] else high > Highest(high, fractal_length);
def frac_up = up_cond1 && up_cond2 && up_cond3;
def down_cond1 = low == Lowest(low, fractal_length);
def down_cond2 = low < Lowest(low, fractal_length)[fractal_length];
def down_cond3 = if close[-fractal_length] then low < Lowest(low, fractal_length)[-fractal_length] else low < Lowest(low, fractal_length);
def frac_down = down_cond1 && down_cond2 && down_cond3;
# RTH and Volume filter
def myRTH = secondsFromTime(0945) >= 0 and SecondsTillTime(1545) >= 0;
input length = 12; #1.5 * fractal_length for now
def Vol = volume;
def VolAvg = Average(volume, length);
def abVol = Vol > VolAvg;
plot upF = if frac_up and myRTH and abVol then high + (25*TickSize()) else double.NaN;
plot downF = if frac_down and myRTH and abVol then low - (25*TickSize()) else double.nan;
upF.SetPaintingStrategy(paintingStrategy.ARROW_DOWN);
upF.SetDefaultColor(GlobalColor("UFR"));
upF.SetLineWeight(4);
downF.SetPaintingStrategy(paintingStrategy.ARROW_UP);
downF.SetDefaultColor(GlobalColor("DFR"));
downF.SetLineWeight(4);
Last edited: