All things TradingView

everything that doesn't belong elsewhere cometh here

Moderator: moderators

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

Re: All things TradingView

Postby Dillinger » Mon May 06, 2019 3:31 pm

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"

Please add www.kreslik.com to your ad blocker white list.
Thank you for your support.

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

Re: All things TradingView

Postby Dillinger » Mon May 06, 2019 3:36 pm

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"

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

Re: All things TradingView

Postby IgazI » Tue May 07, 2019 1:25 am

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
slc.png (13.62 KiB) Viewed 2827 times


Code: Select all

// Recommended stop loss and step
x = input(0.2025, step = .10125, title = '%R', type = float)

// An average of the smallest range in the last 11 bars
stop = 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

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

Re: All things TradingView

Postby IgazI » Tue May 07, 2019 5:02 pm

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

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

Re: All things TradingView

Postby IgazI » Tue May 07, 2019 6:59 pm

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
Point_to_Chaos.png (79.83 KiB) Viewed 2772 times


Excuse the mess :(

Code: Select all

//@version=3
study("Point to Chaos", overlay = true)
user_1 = input(title = "Reverse Fractals?", type = bool, defval = true )

x = open[0]
isHI = false
isLO = false
hi = false
lo = false
clr = user_1 ? black : blue
loca1 = location.abovebar
loca2 = location.belowbar


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 //:= x[2] > x[0] and x[2] > x[1] and x[2] > x[3] and x[2] > x[4] // open data
lo := 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]) / 2
isNT = open[0] == (high[0] + low[0]) / 2
op = 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

Please add www.kreslik.com to your ad blocker white list.
Thank you for your support.

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

Re: All things TradingView

Postby Leoheart » Tue May 07, 2019 7:47 pm

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=3
study("Point to Chaos", overlay = true)
user_1 = input(title = "Reverse Fractals?", type = bool, defval = true )

x = open[0]
isHI = false
isLO = false
hi = false
lo = false
clr = user_1 ? black : blue
loca1 = location.abovebar
loca2 = location.belowbar


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 //:= x[2] > x[0] and x[2] > x[1] and x[2] > x[3] and x[2] > x[4] // open data
lo := 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]) / 2
isNT = open[0] == (high[0] + low[0]) / 2
op = 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.

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

Re: All things TradingView

Postby IgazI » Tue May 07, 2019 8:30 pm

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! :lol:

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

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

Re: All things TradingView

Postby IgazI » Wed May 08, 2019 7:21 am

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

baseline_charts.png
baseline_charts.png (74.4 KiB) Viewed 2698 times


Code: Select all

//@version=3
study("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.abovebar
loca2 = location.belowbar
isTru = input(true, 'XO?', type = bool)
if not isTru
    hi := na
    lo := na
    isHI := na
    isLO := na
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)

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

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

The Quest for Cleaner Signals

Postby IgazI » Mon May 13, 2019 4:31 pm

fracHK.png
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

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

Re: All things TradingView

Postby IgazI » Mon May 13, 2019 5:21 pm

If you are stopped then you can just reenter at the lowest high so long as there is not a '-OHLC'

strat.png
strat.png (36.57 KiB) Viewed 2576 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

Please add www.kreslik.com to your ad blocker white list.
Thank you for your support.


Return to “general”