everything that doesn't belong elsewhere cometh here

Moderator: moderators

Dillinger
rank: 50+ posts
Posts: 55
Joined: Fri Feb 17, 2012 1:23 am
Reputation: 36
Gender:

he is one for thinkscript(thinkorswim). borrowed it and edited it like IgazI suggested

Code: Select all

`# Bill Williams Fractal Template#Define "n" as the number of periods and keep a minimum value of 2 for error handling.input n=2;# Williams Fractals are a 5 point lagging indicator that will draw 2 candles behind.# The purpose of the indicator is to plot points of trend reversals.# Often these are paired with trailing stop indicators such as Parabolic SAR, Volatility Stop, and SuperTrend.# Down pointing fractals occur over candles when:#   High(n-2) < High(n)#   High(n-1) < High(n)#   High(n + 1) < High(n)#   High(n + 2) < High(n)#dnFractal = (high[n-2] < high[n]) and (high[n-1] < high[n]) and (high[n+1] < high[n]) and (high[n+2] < high[n])def isupfractal = if open < open[1] and open < open[2] and open < open[-1] and open < open[-2] then open else double.nan;# Up pointing fractals occur under candles when:#   Low(n-2) > Low(n)#   Low(n-1) > Low(n)#   Low(n + 1) > Low(n)#   Low(n + 2) > Low(n)#upFractal = (low[n-2] > low[n]) and (low[n-1] > low[n]) and (low[n+1] > low[n]) and (low[n+2] > low[n])def isdownfractal = if open > open[1] and open > open[2] and open > open[-1] and open > open[-2] then open else double.nan;# Plot the fractals as shapes on the chart.plot upfractal = if( isupfractal, isupfractal+ (1 * tickSize()) , double.nan);upfractal.SetPaintingStrategy(paintingStrategy.ARROW_UP);plot downfractal = if( isdownfractal, isdownfractal - (1 * tickSize()), double.nan);downfractal.SetPaintingStrategy(paintingStrategy.ARROW_DOWN);`
Last edited by Dillinger on Mon May 06, 2019 3:36 pm, edited 1 time in total.
"So pick up your skirt, grab your balls and let's make some money"

Dillinger
rank: 50+ posts
Posts: 55
Joined: Fri Feb 17, 2012 1:23 am
Reputation: 36
Gender:

Thanks for the open idea IgazI. Now i just have to look at it a bit and digest some of the benefits you suggested
"So pick up your skirt, grab your balls and let's make some money"

IgazI
rank: 150+ posts
Posts: 486
Joined: Sat Feb 17, 2018 5:28 pm
Reputation: 444
Gender:

This is what my SL formula currently looks like.

The only thing that you need to know about an rma is that it is more rigid than an sma.

The idea here is that the total range of the smallest bars best represents the normal fluctuations that you can
expect to see on a smaller chart (represented by the green square in the picture).

1. create a series that contains the smallest ranges in the last 11 bars
2. create an 11 bar rma of that series
3. output x% of the largest value in the last 4 data points.
slc.png (13.62 KiB) Viewed 2827 times

Code: Select all

`// Recommended stop loss and stepx = input(0.2025, step = .10125, title = '%R', type = float)// An average of the smallest range in the last 11 barsstop = security(tickerid, '2D', highest(rma(lowest(atr(1)[1], 11), 11), 4)  * x) plot(stop, style = histogram, join= true, color = red, transp = 88, show_last = 200)`
"I had operated simply on the basis of my daily telegram, which gave me my perspective. It showed me the way my stocks were behaving. There were no other influences, because I did not see or hear anything else." - Nicolas Darvas

IgazI
rank: 150+ posts
Posts: 486
Joined: Sat Feb 17, 2018 5:28 pm
Reputation: 444
Gender:

Marks the fractals of the inside curve (highest highs / lowest lows) of a chart:
this is more of a synergy indicator as it requires the use of a smaller chart.

These fractals only require 4 data points, remain fixed after they appear, and are
nearly inescapable.

dark_underbelly.png (51.33 KiB) Viewed 2782 times
"I had operated simply on the basis of my daily telegram, which gave me my perspective. It showed me the way my stocks were behaving. There were no other influences, because I did not see or hear anything else." - Nicolas Darvas

IgazI
rank: 150+ posts
Posts: 486
Joined: Sat Feb 17, 2018 5:28 pm
Reputation: 444
Gender:

If you're wondering where the code is...I'm still working on it;

I'm liking what I see so far:

This is applied to a baseline chart:
Point_to_Chaos.png (79.83 KiB) Viewed 2772 times

Excuse the mess

Code: Select all

`//@version=3study("Point to Chaos", overlay = true)user_1 = input(title = "Reverse Fractals?", type = bool, defval = true )x = open[0]isHI = falseisLO = falsehi = falselo = falseclr = user_1 ? black : blueloca1 = location.abovebarloca2 = location.belowbarisHI := high[1] < high[0] and high[1] < high[2] and high[1] < high[3]isLO := low[1] > low[0] and low[1] > low[2] and low[1] > low[3]hi := isHI //:= x[2] > x[0] and x[2] > x[1] and x[2] > x[3] and x[2] > x[4] // open datalo := isLO //:= x[2] < x[0] and x[2] < x[1] and x[2] < x[3] and x[2] < x[4] // open data    plotchar(hi, location = loca1, char = 'x', color = black, offset = 0, transp = 0, size = size.tiny)plotchar(lo, location = loca2, char = 'x', color = black, offset = 0, transp = 0, size = size.tiny)plotchar(isHI, location = loca1, char = 'o', color = red, offset = -1, transp = 20, size = size.tiny)plotchar(isLO, location = loca2, char = 'o', color = red, offset = -1, transp = 20, size = size.tiny) isUP = open[0] < (high[0] + low[0]) / 2isNT = open[0] == (high[0] + low[0]) / 2op = open[0]h = high[0]l = low[0]plot(h, style = stepline, color = black, linewidth = 1, transp = 88)plot(l, style = stepline, color = black, linewidth = 1, transp = 88)plot(op, style = circles, color = black, linewidth = 2, transp = 50)//plot(op, style = circles, color = blue, linewidth = 2, join = true, transp = 16)//barcolor(isUP and not isNT ? green : red)`
"I had operated simply on the basis of my daily telegram, which gave me my perspective. It showed me the way my stocks were behaving. There were no other influences, because I did not see or hear anything else." - Nicolas Darvas

Leoheart
rank: 150+ posts
Posts: 440
Joined: Thu Feb 23, 2017 10:54 pm
Reputation: 406
Gender:

IgazI wrote:If you're wondering where the code is...I'm still working on it;

I'm liking what I see so far:

This is applied to a baseline chart:
Point_to_Chaos.png

Excuse the mess

Code: Select all

`//@version=3study("Point to Chaos", overlay = true)user_1 = input(title = "Reverse Fractals?", type = bool, defval = true )x = open[0]isHI = falseisLO = falsehi = falselo = falseclr = user_1 ? black : blueloca1 = location.abovebarloca2 = location.belowbarisHI := high[1] < high[0] and high[1] < high[2] and high[1] < high[3]isLO := low[1] > low[0] and low[1] > low[2] and low[1] > low[3]hi := isHI //:= x[2] > x[0] and x[2] > x[1] and x[2] > x[3] and x[2] > x[4] // open datalo := isLO //:= x[2] < x[0] and x[2] < x[1] and x[2] < x[3] and x[2] < x[4] // open data    plotchar(hi, location = loca1, char = 'x', color = black, offset = 0, transp = 0, size = size.tiny)plotchar(lo, location = loca2, char = 'x', color = black, offset = 0, transp = 0, size = size.tiny)plotchar(isHI, location = loca1, char = 'o', color = red, offset = -1, transp = 20, size = size.tiny)plotchar(isLO, location = loca2, char = 'o', color = red, offset = -1, transp = 20, size = size.tiny) isUP = open[0] < (high[0] + low[0]) / 2isNT = open[0] == (high[0] + low[0]) / 2op = open[0]h = high[0]l = low[0]plot(h, style = stepline, color = black, linewidth = 1, transp = 88)plot(l, style = stepline, color = black, linewidth = 1, transp = 88)plot(op, style = circles, color = black, linewidth = 2, transp = 50)//plot(op, style = circles, color = blue, linewidth = 2, join = true, transp = 16)//barcolor(isUP and not isNT ? green : red)`

If you are bored and want to play tic-tac-toe, just ask.
Soon all of this will be a long time ago. Be Humble, Be Playful.

IgazI
rank: 150+ posts
Posts: 486
Joined: Sat Feb 17, 2018 5:28 pm
Reputation: 444
Gender:

Leoheart wrote:
If you are bored and want to play tic-tac-toe, just ask.

It has taken several days of drawing pictures, testing logic, and rewriting code to get to this point; I'm definitely not bored!

In P&F, 'x' is an up column and 'o' is a down column so I marked 'x' as the direction and 'o' as the reversal so as not to confuse myself (happens often)
1. if there is an 'o' then there is an 'x'
2. 'o' is a reversal trade
3. a new open makes 'x' a valid trade signal.

Sometimes you have to think outside the box to get the desired results:
underbelly.png (6.4 KiB) Viewed 2754 times
"I had operated simply on the basis of my daily telegram, which gave me my perspective. It showed me the way my stocks were behaving. There were no other influences, because I did not see or hear anything else." - Nicolas Darvas

IgazI
rank: 150+ posts
Posts: 486
Joined: Sat Feb 17, 2018 5:28 pm
Reputation: 444
Gender:

Cleaned up the code a bit and added the option to turn off the points.

baseline_charts.png (74.4 KiB) Viewed 2698 times

Code: Select all

`//@version=3study("Point to Chaos", overlay = true)x = open[0]isHI = high[1] < high[0] and high[1] < high[2] and high[1] < high[3]isLO = low[1] > low[0] and low[1] > low[2] and low[1] > low[3]hi = isHI lo = isLO op = open[0]h = high[0]l = low[0]loca1 = location.abovebarloca2 = location.belowbarisTru = input(true, 'XO?', type = bool)if not isTru    hi := na    lo := na    isHI := na    isLO := naplotchar(hi, location = loca1, char = 'x', color = black, offset = 0, transp = 0, size = size.tiny)plotchar(lo, location = loca2, char = 'x', color = black, offset = 0, transp = 0, size = size.tiny)plotchar(isHI, location = loca1, char = 'o', color = red, offset = -1, transp = 20, size = size.tiny)plotchar(isLO, location = loca2, char = 'o', color = red, offset = -1, transp = 20, size = size.tiny) plot(h, style = stepline, color = black, linewidth = 1, transp = 40)plot(l, style = stepline, color = black, linewidth = 1, transp = 40)//plot(op, style = circles, color = black, linewidth = 2, transp = 50)`
"I had operated simply on the basis of my daily telegram, which gave me my perspective. It showed me the way my stocks were behaving. There were no other influences, because I did not see or hear anything else." - Nicolas Darvas

IgazI
rank: 150+ posts
Posts: 486
Joined: Sat Feb 17, 2018 5:28 pm
Reputation: 444
Gender:

### The Quest for Cleaner Signals

fracHK.png (34.34 KiB) Viewed 2578 times
"I had operated simply on the basis of my daily telegram, which gave me my perspective. It showed me the way my stocks were behaving. There were no other influences, because I did not see or hear anything else." - Nicolas Darvas

IgazI
rank: 150+ posts
Posts: 486
Joined: Sat Feb 17, 2018 5:28 pm
Reputation: 444
Gender: