Fractals Indicator Of Mike Lapping for ThinkorSwim

Y

ykd2018x

Member
2019 Donor
here is the code for fractals , i hope everybody know what fractals are and importance of fractals in trading

this version of study i use and like the most , i found it somewhere online i don't know now , sharing here as i have mentioned them in another
RSI technique of trading which i use so far and using till the date for my personal trading

if you are trading with RSI TECHNIQUE & USING REVERSAL INDICATOR , AND YOU PLACE THE STOP LOSS AS SUGGESTED IN THE PIC , 99.99% PRICES ARE NEVER GONNA HIT YOUR STOP LOSS , BUT u must take a good care of your exit with a profit , time frame you decide , if the stop hit in trending market it is itself a reverse the position indicator where u can go double opposite side



happy trading
yogesh

Code:
# Bill Williams fractal indicator
# written by Mike Lapping
#
# Make sure that you change the settings for this indicator so that it plots arrows
# up for upfractal plots
# down for downfractal plots
#
# can be used and modified by anyone for any reason. do not sell.

def isupfractal;
def isdownfractal;

# Looking for high and low series of equalities
# checking for possible fractal formation

rec hicount = if (high == high[1], hicount[1] + 1, 0);
# if the last bar high is the same as this bar's high, increment
# otherwise set false(0)

rec hivalid = if ((hicount[1] == 0 and hicount == 1 and high > high[2] and high > high[3]) or (hicount[1] and hicount and hivalid[1] )
or (hicount[2] and hivalid[2] and high == high[2] and high > high[1]), 1, 0) ;
# set hivalid to true(1)
# if we are entering an equality series, check if the 2 bars preceding the first equal bar # are lower than the current bar
# or if the last bar was an equal bar and this bar is an equal bar and the current equal
# series is valid
# or if we skipped over a lower bar but two bars ago we had an equal bar and that was a
# valid fractal
# otherwise it is false

rec locount = if (low == low[1], locount[1] + 1, 0);
rec lovalid = if ((locount[1] == 0 and locount == 1 and low < low[2] and low < low[3])
or (locount[1] and locount and lovalid[1] )
or (locount[2] and lovalid[2] and low == low[2] and low < low[1]), 1, 0) ;



# Checking for a traditional or non-standard up fractal

isupfractal = if(((hicount and hivalid) or (high > high[1] and high > high[2])) and high > high[-1] and high > high[-2], high, 0);
# Ok this is complicated, basically its checking if there were a series of equal bars and
# if the two bars before the first equal bar were lower
# or if the last 2 bars were lower than the current bar
# and if the two following 2 bars are lower than the current bar

# Checking for a traditional or non-standard down fractal

isdownfractal = if(((locount and lovalid) or (low < low[1] and low < low[2])) and low < low[-1] and low < low[-2], low, 0);

plot upfractal = if( isupfractal, isupfractal + (1 * tickSize()), double.nan);
upfractal.SetPaintingStrategy(paintingStrategy.POINTS);

plot downfractal = if( isdownfractal, isdownfractal - (1 * tickSize()), double.nan);
downfractal.SetPaintingStrategy(paintingStrategy.POINTS);

# This business with the tickSize() function is basically putting the arrow further away fro
# from the bar so that the fractal is easier to read
 
Last edited by a moderator:
S

skynetgen

Well-known member
Mind clarifying please which reversal indicator you are using
 
S

skynetgen

Well-known member
Well studying your system. Its promising imho. There are couple of things which make it harder to generate timely reliable signals: Reversal indicator is repainting and Fractal signal is lagging by 2 bars
 
Y

ykd2018x

Member
2019 Donor
Well studying your system. Its promising imho. There are couple of things which make it harder to generate timely reliable signals: Reversal indicator is repainting and Fractal signal is lagging by 2 bars
in longer time frame its okay

also repaiting trend reversal
i mean its stop if hits is itself a reversal indicator


i.e. if the overall trend is up with point high ema and u see a red reversal u can do 2 things avoid it always if doesnt match with RSI or take it always but go long if stop is hit

nothing more can be done abt it by nobody i believe
 
N

Nick

Active member
2019 Donor
VIP
Thanks Yogesh

I am wondering, can anyone out there write me a scan, to tell me which stock has closed above or below its most recent fractal, based on the code kindly provided by Yogesh?

Thanks again.
 
D

diazlaz

Well-known member
2019 Donor
VIP
Thanks Yogesh

I am wondering, can anyone out there write me a scan, to tell me which stock has closed above or below its most recent fractal, based on the code kindly provided by Yogesh?

Thanks again.
Hi @Nick

BW is built into the ToS Platform - no need for a custom indicator or scan.

Patterns, See below:

 
Y

ykd2018x

Member
2019 Donor
Hi @Nick

BW is built into the ToS Platform - no need for a custom indicator or scan.

Patterns, See below:


hi nick

i dont think there should be any such system or way to make such scan

so far fractals are good for below things on charts
1. creating actual and good trendlines those works
2. to see the market trend and movement
3. to understand where the buyers and sellers can be meeting together
4. to see the nature going on , on the charts and how swing highs and swing lows are so easily visible in up and down trend ,

actually they make the picture more clear , i cannot imagine a chart without fractals now

and whenever in intraday there is a move without fractals either up or down side , i try to stay away of it
 

Similar threads

Top