Fractals Indicator Of Mike Lapping for ThinkorSwim

Y

ykd2018x

Member
VIP
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

Member
Warehouse
Mind clarifying please which reversal indicator you are using
 
S

skynetgen

Member
Warehouse
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
VIP
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
 

Top