Convert TradingView Indicator to ThinkorSwim

javin82

New member
I need help converting a pine script indicator into a think script study for Thinkorswim. The name of the indicator is called Range. It is a reversal indicator and plots long and short signals. If you can help me with this, please let me know. Thank you!

PineScript code below:
Code:
//////////////
//@version=3
study("Range fv2",overlay=true)
showTrendLine = input(false, title="Show Trend Line")
colorBars = input(true, title="Color Bars?")
filterTrend = input(true, title="Filter Trend?")

//Source
src = close

//Sampling Period
per = input(defval=25, minval=1, title="Sampling Period")

//Range Multiplier
mult = input(defval=2, minval=0, title="Range Multiplier")

//-----------------------------------------------------------------------------------------------------------------------------------------------------------------
//Definitions
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------

//Smooth Average Range
smoothrng(x, t, m)=>
    wper      = (t/3) - 1
    avrng     = sma(abs(x - x[1]), t)
    smoothrng = sma(avrng, wper)*m
    smoothrng
smrng = smoothrng(src, per, mult)

//Range Filter
rngfilt(x, r)=>
    rngfilt  = x
    rngfilt := x > nz(rngfilt[1]) ? ((x - r) < nz(rngfilt[1]) ? nz(rngfilt[1]) : (x - r)) : ((x + r) > nz(rngfilt[1]) ? nz(rngfilt[1]) : (x + r))
    rngfilt
filt = rngfilt(src, smrng)

//Filter Direction
upward   = 0.0
upward  := filt > filt[1] ? nz(upward[1]) + 1 : filt < filt[1] ? 0 : nz(upward[1])
downward = 0.0
downward := filt < filt[1] ? nz(downward[1]) + 1 : filt > filt[1] ? 0 : nz(downward[1])

//Target Bands
hband = filt + smrng
lband = filt - smrng

//Colors
filtcolor = upward > 0 ? lime : downward > 0 ? red : orange
barcolor  = (src > filt) and (src > src[1]) and (upward > 0) ? lime : (src > filt) and (src < src[1]) and (upward > 0) ? green : (src < filt) and (src < src[1]) and (downward > 0) ? red : (src < filt) and (src > src[1]) and (downward > 0) ? maroon : orange
barcolor(colorBars ? barcolor : na)

//-----------------------------------------------------------------------------------------------------------------------------------------------------------------
//Plots
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------

//Range Filter
if filterTrend == true
    showTrendLine := false
filtplot = plot(filterTrend ? filt : na, color=filtcolor, linewidth=4, title="Range Filter")
//
Factor=input(3, minval=1,maxval = 100)
Pd=input(3, minval=1,maxval = 100)

Up=hl2-(Factor*atr(Pd))
Dn=hl2+(Factor*atr(Pd))
TrendUp = 0.0
TrendDown = 0.0
linecolor = na
up = na
down = na
Tsl = 0.0
Trend = 0.0
TrendUp := close[1]>TrendUp[1]? max(Up,TrendUp[1]) : Up
TrendDown := close[1]<TrendDown[1]? min(Dn,TrendDown[1]) : Dn
Trend := close > TrendDown[1] ? 1: close< TrendUp[1]? -1: nz(Trend[1],1)
Tsl := Trend==1? TrendUp: TrendDown
linecolor := Trend == 1 ? green : red
plot(showTrendLine ? Tsl : na, color = linecolor , style = line , linewidth = 3,title = "SuperTrend")

// Strategy


longCond = na
shortCond = na
longCond :=crossunder(Tsl,filt)
shortCond :=crossover(Tsl,filt)

// Count your long short conditions for more control with Pyramiding

sectionLongs = 0
sectionLongs := nz(sectionLongs[1])
sectionShorts = 0
sectionShorts := nz(sectionShorts[1])

if longCond
    sectionLongs := sectionLongs + 1
    sectionShorts := 0

if shortCond
    sectionLongs := 0
    sectionShorts := sectionShorts + 1

// Pyramiding

pyrl = 1


// These check to see your signal and cross references it against the pyramiding settings above

longCondition = longCond and sectionLongs <= pyrl
shortCondition = shortCond and sectionShorts <= pyrl

// Get the price of the last opened long or short

last_open_longCondition = na
last_open_shortCondition = na
last_open_longCondition := longCondition ? open : nz(last_open_longCondition[1])
last_open_shortCondition := shortCondition ? open : nz(last_open_shortCondition[1])

// Check if your last postion was a long or a short

last_longCondition = na
last_shortCondition = na
last_longCondition := longCondition ? time : nz(last_longCondition[1])
last_shortCondition := shortCondition ? time : nz(last_shortCondition[1])

in_longCondition = last_longCondition > last_shortCondition
in_shortCondition = last_shortCondition > last_longCondition

// Take profit

isTPl = input(true, "Take Profit Long")
isTPs = input(true, "Take Profit Short")
tp = input(5, "Take Profit ", type=float)
long_tp = isTPl and crossover(high, (1+(tp/100))*last_open_longCondition) and longCondition == 0 and in_longCondition  == 1
short_tp = isTPs and crossunder(low, (1-(tp/100))*last_open_shortCondition) and shortCondition == 0 and in_shortCondition == 1


// Create a single close for all the different closing conditions.

long_close = long_tp  ? 1 : 0
short_close = short_tp ? 1 : 0

// Get the time of the last close

last_long_close = na
last_short_close = na
last_long_close := long_close ? time : nz(last_long_close[1])
last_short_close := short_close ? time : nz(last_short_close[1])


// Alerts & Signals

bton(b) => b ? 1 : 0
plotshape(longCondition , title="Long", color=green, textcolor=green, transp=0,
          style=shape.triangleup, location=location.belowbar, size=size.small,text="LONG",offset=0)


plotshape(shortCondition, title="Short", color=red, textcolor=red, transp=0,
          style=shape.triangledown, location=location.abovebar, size=size.small,text="SHORT",offset=0)


//plotshape(longCondition, title = "BUY Signal", text = "Buy", style=shape.triangleup, location=location.belowbar, color = blue, editable = false, transp = 0)
//plotshape(shortCondition, title = "SELL Signal", text = "Sell", style=shape.triangledown, location=location.abovebar, color = black, editable = false, transp = 0)

plotshape(long_tp and last_longCondition > nz(last_long_close[1]), text ="TP", title="Take Profit Long", style=shape.triangledown,
   location=location.abovebar, color = red, editable = false, transp = 0)
plotshape(short_tp and last_shortCondition > nz(last_short_close[1]) , text ="TP", title="Take Profit Short", style=shape.triangleup,
   location=location.belowbar, color = lime, editable = false, transp = 0)

alertcondition(bton(longCondition), title="Long Alert")
alertcondition(bton(shortCondition), title="Short Alert")
alertcondition(bton(long_tp and last_longCondition > nz(last_long_close[1])), title="Take Profit Long")
alertcondition(bton(short_tp and last_shortCondition > nz(last_short_close[1])), title="Take Profit Short")

Any help I can get with this will be greatly appreciated! Thank you!

Admin's Notes:

You can now use this thread to make your own request. If there is a TradingView script that you would like to see in ThinkorSwim, please post the source code and link to that script below. We'll try our best to help you with the conversion.

Below are the TradingView scripts that have been converted to TOS.
 
Last edited by a moderator:

New Indicator: Buy the Dip

Check out our Buy the Dip indicator and see how it can help you find profitable swing trading ideas. Scanner, watchlist columns, and add-ons are included.

Download the indicator

CasualPhoenix

New member
Hey everyone, Namely Ben and horserider.

I looked at the list of Supply and Demand indicators and wanted to ask which would be the closet to, and if non are, is there anyway to get a S/D indicator made like this one: https://www.tradingview.com/script/11DK57V9-Demo-Demand-Supply-Zone-Indicator/

Where it does Zones, Based off a Trader named Sam Seiden, who did Odds Enhancers:

Odds Enhancers:
  1. Number of Base Candles when price hits a base (Zone)
  2. How did price leave the level?
  3. How many waves have happened since?
  4. How much time did price spend at the level?
  5. How far did price move from the level before returning?
  6. Has price ever returned to the level?
And 4 Supply/Demand Types
  1. Rally – Base – Drop = Resistance/Supply
  2. Rally – Base – Rally = Bullish Rising Support/Demand Area
  3. Drop – Base – Rally = Support/Demand Area
  4. Drop – Base – Drop = Bearish Falling Resistance/Supply Area
I like how the indicator I linked specifically showed Rally Base Rally for example as (RBR). I am not sure if its capable of distinguishing between pivot points and Supply/Demand Zones.

Also since I've wanted to ask this question for months. I found thinkscript looking for ways to locate dark pools. Is there any indicator that would help mark (I'm sure its wishful thinking), The different Phases of Wyckoff price could be in:
Accumulation/Distribution/Markup/Markdown/Reaccumulation/Redistribution
Phases A-E (The most wishful thinking)
Mark the potential points (Preliminary support, Automatic Really, Secondary Test, Up Thrust, Springs, Terminal Shakeout etc)

Wyckoff to anyone else who doesn't know, is a schematic for analyzing the markets.

https://school.stockcharts.com/doku.php?id=market_analysis:the_wyckoff_method#wyckoff_schematics

Any and all Indicators, input, information and ideas are all welcomed from everyone.

I've been building a checklist of sorts that houses Indicators Combinations based off market conditions, Wyckoff, Supply/Demand and VSA Analysis. Thanks!
 
Last edited by a moderator:

J007RMC

Well-known member
2019 Donor
Can't remember who posted but is it possible to convert this indicator into tos this is an excellent stochastic I also use on trading view?

Code:
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © opiumfive

//@version=4
study("Drake Delay Stochastic")

pds = input(title="pds", type=input.integer, defval=13, minval=1)
slw = input(title="ema", type=input.integer, defval=8, minval=1)
slwsignal = input(title="trigger", type=input.integer, defval=9, minval=1)

MAValue = 0.0
MAValue2 = 0.0
MAValue3 = 0.0

smconst = 2.0 / (1 + slw)
smconst1 = 2.0 / (1 + slwsignal)

prev = na(MAValue2[1]) ? 0.0 : MAValue2[1]

AA = 0.0
tmpDevAA = highest(pds) - lowest(pds)

if tmpDevAA != 0
    AA := 100* ((close - lowest(pds)) / tmpDevAA)
  
MAValue2 := smconst * (AA-prev) + prev


MyHigh = -999999.0
MyLow = 999999.0
for i = 0 to pds
    Price = na(MAValue2) ? 0.0 : MAValue2
    if Price != 0.0
        if Price > MyHigh
            MyHigh := Price
        if pds <= 0
            MyHigh := Price
        if Price < MyLow
            MyLow := Price
        if pds <= 0
            MyLow := Price

prev1 = na(MAValue[1]) ? 0.0 : MAValue[1]
aa1=MAValue2

bb= 0.0
if MyHigh-MyLow != 0
    bb:=100*(aa1-MyLow)/(MyHigh-MyLow)

MAValue := smconst * (bb-prev1) + prev1

MAValue3:= ema(MAValue, slwsignal)

plot(MAValue, color = MAValue >= MAValue3 ? color.lime : color.red, linewidth = 2)
plot(MAValue3, color = color.black)
hline(20, title="Sell", color=color.gray, linestyle=hline.style_dashed)
hline(80, title="Buy", color=color.gray, linestyle=hline.style_dashed)

bgcolor(MAValue >= MAValue3 ? #38a32a : #da680f, transp=80)
me me me lol haha
 

tem2005

Member
VIP
Hello, can anyone convert the below indicator from tradingview? i found it good promising . It's named as Order Block Finder

Code:
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © wugamlo


// This experimental Indicator helps identifying instituational Order Blocks.
// Often these blocks signal the beginning of a strong move, but there is a significant probability that these price levels will be revisited at a later point in time again.
// Therefore these are interesting levels to place limit orders (Buy Orders for Bullish OB / Sell Orders for Bearish OB).
//
// A Bullish Order block is defined as the last down candle before a sequence of up candles. (Relevant price range "Open" to "Low" is marked)  / Optionally full range "High" to "Low"
// A Bearish Order Block is defined as the last up candle before a sequence of down candles. (Relevant price range "Open" to "High" is marked) / Optionally full range "High" to "Low"
//
// In the settings the number of required sequential candles can be adjusted.
// Furthermore a %-threshold can be entered. It defines which %-change the sequential move needs to achieve in order to identify a relevant Order Block.
// Channels for the last Bullish/Bearish Block can be shown/hidden.
//
// In addition to the upper/lower limits of each Order Block, also the equlibrium (average value) is marked as this is an interesting area for price interaction.


//@version=4
study("Order Block Finder", overlay = true)             

periods   = input(5,     "Relevant Periods to identify OB")                // Required number of subsequent candles in the same direction to identify Order Block
threshold = input(0.0,   "Min. Percent move to identify OB", step = 0.1)   // Required minimum % move (from potential OB close to last subsequent candle to identify Order Block)
usewicks  = input(false, "Use whole range [High/Low] for OB marking?" )    // Display High/Low range for each OB instead of Open/Low for Bullish / Open/High for Bearish
showbull  = input(true,  "Show latest Bullish Channel?")                   // Show Channel for latest Bullish OB?
showbear  = input(true,  "Show latest Bearish Channel?")                   // Show Channel for latest Bearish OB?
showdocu  = input(true,  "Show Label for documentation tooltip?")          // Show Label which shows documentation as tooltip?

ob_period = periods + 1                                                    // Identify location of relevant Order Block candle
absmove   = ((abs(close[ob_period] - close[1]))/close[ob_period]) * 100    // Calculate absolute percent move from potential OB to last candle of subsequent candles
relmove   = absmove >= threshold                                           // Identify "Relevant move" by comparing the absolute move to the threshold

// Bullish Order Block Identification
bullishOB = close[ob_period] < open[ob_period]                             // Determine potential Bullish OB candle (red candle)

int upcandles  = 0
for i = 1 to periods
    upcandles := upcandles + (close[i] > open[i]? 1 : 0)                   // Determine color of subsequent candles (must all be green to identify a valid Bearish OB)

OB_bull      = bullishOB and (upcandles == (periods)) and relmove          // Identification logic (red OB candle & subsequent green candles)
OB_bull_high = OB_bull? usewicks? high[ob_period] : open[ob_period] : na   // Determine OB upper limit (Open or High depending on input)
OB_bull_low  = OB_bull? low[ob_period]  : na                               // Determine OB lower limit (Low)
OB_bull_avg  = (OB_bull_high + OB_bull_low)/2                              // Determine OB middle line


// Bearish Order Block Identification
bearishOB = close[ob_period] > open[ob_period]                             // Determine potential Bearish OB candle (green candle)

int downcandles  = 0
for i = 1 to periods
    downcandles := downcandles + (close[i] < open[i]? 1 : 0)               // Determine color of subsequent candles (must all be red to identify a valid Bearish OB)

OB_bear      = bearishOB and (downcandles == (periods)) and relmove        // Identification logic (green OB candle & subsequent green candles)
OB_bear_high = OB_bear? high[ob_period] : na                               // Determine OB upper limit (High)
OB_bear_low  = OB_bear? usewicks? low[ob_period] : open[ob_period] : na    // Determine OB lower limit (Open or Low depending on input)
OB_bear_avg  = (OB_bear_low + OB_bear_high)/2                              // Determine OB middle line


// Plotting

plotshape(OB_bull, title="Bullish OB", style = shape.triangleup,   color = color.white, size = size.tiny, location = location.belowbar, offset = -ob_period, text = "Bullish OB")     // Bullish OB Indicator
bull1 = plot(OB_bull_high, title="Bullish OB open", style = plot.style_linebr, color = color.white, offset = -ob_period, linewidth = 3)                                               // Bullish OB Upper Limit
bull2 = plot(OB_bull_low,  title="Bullish OB low",  style = plot.style_linebr, color = color.white, offset = -ob_period, linewidth = 3)                                               // Bullish OB Lower Limit
fill(bull1, bull2, color=color.white, transp = 0, title = "Bullish OB fill")                                                                                                          // Fill Bullish OB
plotshape(OB_bull_avg, title="Bullish OB Average", style = shape.cross,   color = color.white, size = size.normal, location = location.absolute, offset = -ob_period)                 // Bullish OB Average


plotshape(OB_bear, title="Bearish OB", style = shape.triangledown, color = color.blue,  size = size.tiny, location = location.abovebar, offset = -ob_period, text = "Bearish OB")     // Bearish OB Indicator
bear1 = plot(OB_bear_low,  title="Bearish OB open", style = plot.style_linebr, color = color.blue, offset = -ob_period, linewidth = 3)                                                // Bearish OB Lower Limit
bear2 = plot(OB_bear_high, title="Bearish OB high", style = plot.style_linebr, color = color.blue, offset = -ob_period, linewidth = 3)                                                // Bearish OB Upper Limit
fill(bear1, bear2, color=color.blue, transp = 0, title = "Bearish OB fill")                                                                                                           // Fill Bearish OB
plotshape(OB_bear_avg, title="Bearish OB Average", style = shape.cross,   color = color.blue, size = size.normal, location = location.absolute, offset = -ob_period)                  // Bullish OB Average

var line linebull1 = na       // Bullish OB average
var line linebull2 = na       // Bullish OB open
var line linebull3 = na       // Bullish OB low
var line linebear1 = na       // Bearish OB average
var line linebear2 = na       // Bearish OB high
var line linebear3 = na       // Bearish OB open


if OB_bull and showbull
    line.delete(linebull1)
    linebull1 := line.new(x1 = bar_index, y1 = OB_bull_avg, x2 = bar_index - 1, y2 = OB_bull_avg, extend = extend.left, color = color.white, style = line.style_solid, width = 1)
  
    line.delete(linebull2)
    linebull2 := line.new(x1 = bar_index, y1 = OB_bull_high, x2 = bar_index - 1, y2 = OB_bull_high, extend = extend.left, color = color.white, style = line.style_dashed, width = 1)
  
    line.delete(linebull3)
    linebull3 := line.new(x1 = bar_index, y1 = OB_bull_low, x2 = bar_index - 1, y2 = OB_bull_low, extend = extend.left, color = color.white, style = line.style_dashed, width = 1)

if OB_bear and showbear
    line.delete(linebear1)
    linebear1 := line.new(x1 = bar_index, y1 = OB_bear_avg, x2 = bar_index - 1, y2 = OB_bear_avg, extend = extend.left, color = color.blue,  style = line.style_solid, width = 1)
  
    line.delete(linebear2)
    linebear2 := line.new(x1 = bar_index, y1 = OB_bear_high, x2 = bar_index - 1, y2 = OB_bear_high, extend = extend.left, color = color.blue,  style = line.style_dashed, width = 1)
  
    line.delete(linebear3)
    linebear3 := line.new(x1 = bar_index, y1 = OB_bear_low, x2 = bar_index - 1, y2 = OB_bear_low, extend = extend.left, color = color.blue,  style = line.style_dashed, width = 1)


// === Label for Documentation/Tooltip ===
chper = time - time[1]
chper := change(chper) > 0 ? chper[1] : chper

// === Tooltip text ===

var vartooltip = "Indicator to help identifying instituational Order Blocks. Often these blocks signal the beginning of a strong move, but there is a high probability, that these prices will be revisited at a later point in time again and therefore are interesting levels to place limit orders. \nBullish Order block is the last down candle before a sequence of up candles. \nBearish Order Block is the last up candle before a sequence of down candles. \nIn the settings the number of required sequential candles can be adjusted. \nFurthermore a %-threshold can be entered which the sequential move needs to achieve in order to validate a relevant Order Block. \nChannels for the last Bullish/Bearish Block can be shown/hidden."

// === Print Label ===
var label l_docu = na
label.delete(l_docu)

if showdocu
    l_docu := label.new(x = time + chper * 35, y = close, text = "DOCU OB", color=color.gray, textcolor=color.white, style=label.style_label_center, xloc = xloc.bar_time, yloc=yloc.price, size=size.tiny, textalign = text.align_left, tooltip = vartooltip)

Wanting to bring this up again. Any help?
 
Help converting Bill Williams Zone trading indicator.

https://www.tradingview.com/script/n8bTMJsl-AO-and-AC-Zones-Bill-Williams/

The colored Zones is the combination of the Awesome Oscillator (AO) and Accelerator Oscillator ( AC ) indicator by Bill Williams .
  • If both AO and AC bars are uptrending, the zone is blue
  • If both AO and AC bars are downtrending, the zone is red
  • If AO and AC have different colors, the zone is gray

Blue and red zones
This zones allows you to trade more aggressively, you could also add to current positions

Gray zone
You should avoid those flat (or choppy) market and don't open new positions or add to your current ones
Code:
//HUGE THANKS TO CHAOSTRADER FOR THE ORIGINAL CODE
//Bill Williams Zone and Squat Bars.  See New Trading Dimensions by Bill Williams, PhD.
//Bars are green (green zone) when the Awesome Oscillator and Accelerater/Decelerator are both positive.
//Bars are red (red zone) when the Awesome Oscillator and Accelerater/Decelerator are both negative.
//Bars are blue when a squat bar is formed, these indicate a battle between bulls and bears and often happen near trend continuation or trend changes.
//Caution: Assumes chart is a bar chart - not a candle chart.
//Caution: Squat bars are accurate only with official exchange volume data - BATS data will give false squat bars.
study(title="AO/AC Zones", overlay = true)
ao = sma(hl2,5) - sma(hl2,34)
ac = ao - sma( ao, 5 )
isGreen() => ao > ao[1] and ac > ac[1]
isRed() => ao < ao[1] and ac < ac[1]
isGrey() => ao > ao[1] and ac < ac[1]
isGray() => ao < ao[1] and ac > ac[1]
barcolor(isGrey() ? gray : isGray() ? gray : isGreen() ? #55AE3A : isRed() ? red : black)
 

BenTen

Administrative
Staff
VIP
@alokranjan3 Here you go:

Code:
# Converted from https://www.tradingview.com/script/n8bTMJsl-AO-and-AC-Zones-Bill-Williams/

def ao = simpleMovingAvg(hl2,5) - simpleMovingAvg(hl2,34);
def ac = ao - simpleMovingAvg( ao, 5 );

AssignPriceColor(if ao > ao[1] and ac > ac[1] then color.green else if ao < ao[1] and ac < ac[1] then color.red else if ao > ao[1] and ac < ac[1] then color.gray else color.gray);
 

krodr090

New member
ToS is my maint platform, there is a script from TravingView I would like to import as well. I added my own comments, but the clean version can be found on the following link: (much appreciated if it can be done!)
https://www.tradingview.com/script/vkAechsb/

Code:
//standard comment
//@version=4

//Defines name of the script.
//Function sets a number of study properties.
//title= study title that would be seen in indicators widget.
//overlay=if true the study will be added as an overlay.
//basically names the study and sets it to overlay the current chart.
study("Accurate Swing Trading System",overlay=true)


//this is an identifier.
//this defines the variabe no with a value of 3.
no=input(3,title="Swing")
//declaration of variables.
Barcolor=input(false,title="Barcolor")
Bgcolor=input(false,title="Bgcolor")


//buy or sell when resitance or support are broken.


//Highest value for a given number of bars back.
//Looks at high price the last 3 lines and set as res=resistance.
res=highest(high,no)
//Lowest value for a given number of bars back.
//Looks at the lowest price the last 3 lines and set as sup=support.
sup=lowest(low,no)


// avd is equal to (close > resitance, then 1, else if close < support then -1 else 0.
//Condition, then...else. Possible values are 1, -1 or 0
avd=iff(close>res[1],1,iff(close<sup[1],-1,0))
//avd = 0


//Valuewhen= source series value when the condition was true on the n-th most occurrence
//Condition, when avd is not equal to 0, source: avd, 0 occurrences
avn=valuewhen(avd!=0,avd,0)

//iff avn is 1 then (support value, else resistance value)
tsl=iff(avn==1,sup,res)

//res price 148.29

//buy is equal when close price is greater than tsl.
Buy=crossover(close,tsl)
Sell=crossunder(close,tsl)


//This plots the buy/sell signals, color, arrow, location and text.
plotshape(Buy,title="Buy", color=color.green, style=shape.arrowup,location=location.belowbar, text="Buy")
plotshape(Sell,title="Sell", color=color.red, style=shape.arrowdown,text="Sell")


//draws the line display.
colr = close>=tsl ? color.green : close<=tsl ? color.red : na
plot(tsl, color=colr, linewidth=3, title="TSL")
barcolor(Barcolor ? colr : na)
bgcolor(Bgcolor ? colr :na)
 

J007RMC

Well-known member
2019 Donor
ToS is my maint platform, there is a script from TravingView I would like to import as well. I added my own comments, but the clean version can be found on the following link: (much appreciated if it can be done!)
https://www.tradingview.com/script/vkAechsb/

Code:
//standard comment
//@version=4

//Defines name of the script.
//Function sets a number of study properties.
//title= study title that would be seen in indicators widget.
//overlay=if true the study will be added as an overlay.
//basically names the study and sets it to overlay the current chart.
study("Accurate Swing Trading System",overlay=true)


//this is an identifier.
//this defines the variabe no with a value of 3.
no=input(3,title="Swing")
//declaration of variables.
Barcolor=input(false,title="Barcolor")
Bgcolor=input(false,title="Bgcolor")


//buy or sell when resitance or support are broken.


//Highest value for a given number of bars back.
//Looks at high price the last 3 lines and set as res=resistance.
res=highest(high,no)
//Lowest value for a given number of bars back.
//Looks at the lowest price the last 3 lines and set as sup=support.
sup=lowest(low,no)


// avd is equal to (close > resitance, then 1, else if close < support then -1 else 0.
//Condition, then...else. Possible values are 1, -1 or 0
avd=iff(close>res[1],1,iff(close<sup[1],-1,0))
//avd = 0


//Valuewhen= source series value when the condition was true on the n-th most occurrence
//Condition, when avd is not equal to 0, source: avd, 0 occurrences
avn=valuewhen(avd!=0,avd,0)

//iff avn is 1 then (support value, else resistance value)
tsl=iff(avn==1,sup,res)

//res price 148.29

//buy is equal when close price is greater than tsl.
Buy=crossover(close,tsl)
Sell=crossunder(close,tsl)


//This plots the buy/sell signals, color, arrow, location and text.
plotshape(Buy,title="Buy", color=color.green, style=shape.arrowup,location=location.belowbar, text="Buy")
plotshape(Sell,title="Sell", color=color.red, style=shape.arrowdown,text="Sell")


//draws the line display.
colr = close>=tsl ? color.green : close<=tsl ? color.red : na
plot(tsl, color=colr, linewidth=3, title="TSL")
barcolor(Barcolor ? colr : na)
bgcolor(Bgcolor ? colr :na)
Im curious as to what the study is called
 

TraderZen

New member
VIP
Hi,

Please consider converting this indicator from TV to TOS - https://tr.tradingview.com/script/sU9molfV/ This is called Profit Maximizer PMAX.

@BenTen as per your suggestion, the source code is posted below.

Thank you!

Rich (BB code):
//@version=4
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © KivancOzbilgic
//developer: @KivancOzbilgic
//author: @KivancOzbilgic

study("Profit Maximizer","PMax", overlay=true)
src = input(hl2, title="Source")
Periods = input(title="ATR Length", type=input.integer, defval=10)
Multiplier = input(title="ATR Multiplier", type=input.float, step=0.1, defval=3.0)
mav = input(title="Moving Average Type", defval="EMA", options=["SMA", "EMA", "WMA", "TMA", "VAR", "WWMA", "ZLEMA", "TSF"])
length =input(10, "Moving Average Length", minval=1)
changeATR= input(title="Change ATR Calculation Method ?", type=input.bool, defval=true)
showsupport = input(title="Show Moving Average?", type=input.bool, defval=true)
showsignalsk = input(title="Show Crossing Signals?", type=input.bool, defval=true)
showsignalsc = input(title="Show Price/Pmax Crossing Signals?", type=input.bool, defval=false)
highlighting = input(title="Highlighter On/Off ?", type=input.bool, defval=true)
atr2 = sma(tr, Periods)
atr= changeATR ? atr(Periods) : atr2
valpha=2/(length+1)
vud1=src>src[1] ? src-src[1] : 0
vdd1=src<src[1] ? src[1]-src : 0
vUD=sum(vud1,9)
vDD=sum(vdd1,9)
vCMO=nz((vUD-vDD)/(vUD+vDD))
VAR=0.0
VAR:=nz(valpha*abs(vCMO)*src)+(1-valpha*abs(vCMO))*nz(VAR[1])
wwalpha = 1/ length
WWMA = 0.0
WWMA := wwalpha*src + (1-wwalpha)*nz(WWMA[1])
zxLag = length/2==round(length/2) ? length/2 : (length - 1) / 2
zxEMAData = (src + (src - src[zxLag]))
ZLEMA = ema(zxEMAData, length)
lrc = linreg(src, length, 0)
lrc1 = linreg(src,length,1)
lrs = (lrc-lrc1)
TSF = linreg(src, length, 0)+lrs
getMA(src, length) =>
    ma = 0.0
    if mav == "SMA"
        ma := sma(src, length)
        ma

    if mav == "EMA"
        ma := ema(src, length)
        ma

    if mav == "WMA"
        ma := wma(src, length)
        ma

    if mav == "TMA"
        ma := sma(sma(src, ceil(length / 2)), floor(length / 2) + 1)
        ma

    if mav == "VAR"
        ma := VAR
        ma

    if mav == "WWMA"
        ma := WWMA
        ma

    if mav == "ZLEMA"
        ma := ZLEMA
        ma

    if mav == "TSF"
        ma := TSF
        ma
    ma
  
MAvg=getMA(src, length)
longStop = MAvg - Multiplier*atr
longStopPrev = nz(longStop[1], longStop)
longStop := MAvg > longStopPrev ? max(longStop, longStopPrev) : longStop
shortStop = MAvg + Multiplier*atr
shortStopPrev = nz(shortStop[1], shortStop)
shortStop := MAvg < shortStopPrev ? min(shortStop, shortStopPrev) : shortStop
dir = 1
dir := nz(dir[1], dir)
dir := dir == -1 and MAvg > shortStopPrev ? 1 : dir == 1 and MAvg < longStopPrev ? -1 : dir
PMax = dir==1 ? longStop: shortStop
plot(showsupport ? MAvg : na, color=#0585E1, linewidth=2, title="Moving Avg Line")
pALL=plot(PMax, color=color.red, linewidth=2, title="PMax", transp=0)
alertcondition(cross(MAvg, PMax), title="Cross Alert", message="PMax - Moving Avg Crossing!")
alertcondition(crossover(MAvg, PMax), title="Crossover Alarm", message="Moving Avg BUY SIGNAL!")
alertcondition(crossunder(MAvg, PMax), title="Crossunder Alarm", message="Moving Avg SELL SIGNAL!")
alertcondition(cross(src, PMax), title="Price Cross Alert", message="PMax - Price Crossing!")
alertcondition(crossover(src, PMax), title="Price Crossover Alarm", message="PRICE OVER PMax - BUY SIGNAL!")
alertcondition(crossunder(src, PMax), title="Price Crossunder Alarm", message="PRICE UNDER PMax - SELL SIGNAL!")
buySignalk = crossover(MAvg, PMax)
plotshape(buySignalk and showsignalsk ? PMax*0.995 : na, title="Buy", text="Buy", location=location.absolute, style=shape.labelup, size=size.tiny, color=color.green, textcolor=color.white, transp=0)
sellSignallk = crossunder(MAvg, PMax)
plotshape(sellSignallk and showsignalsk ? PMax*1.005 : na, title="Sell", text="Sell", location=location.absolute, style=shape.labeldown, size=size.tiny, color=color.red, textcolor=color.white, transp=0)
buySignalc = crossover(src, PMax)
plotshape(buySignalc and showsignalsc ? PMax*0.995 : na, title="Buy", text="Buy", location=location.absolute, style=shape.labelup, size=size.tiny, color=#0F18BF, textcolor=color.white, transp=0)
sellSignallc = crossunder(src, PMax)
plotshape(sellSignallc and showsignalsc ? PMax*1.005 : na, title="Sell", text="Sell", location=location.absolute, style=shape.labeldown, size=size.tiny, color=#0F18BF, textcolor=color.white, transp=0)
mPlot = plot(ohlc4, title="", style=plot.style_circles, linewidth=0,display=display.none)
longFillColor = highlighting ? (MAvg>PMax ? color.green : na) : na
shortFillColor = highlighting ? (MAvg<PMax ? color.red : na) : na
fill(mPlot, pALL, title="UpTrend Highligter", color=longFillColor)
fill(mPlot, pALL, title="DownTrend Highligter", color=shortFillColor)
 

mbeig

New member
https://www.tradingview.com/script/TmqiR1jp-RSI-cyclic-smoothed-v2/

Hi - I really like this smoothed RSI with bands and wanted to use it in thinkorswim. Unfortunately, I am really struggling with converting RMA to thinkscript as well as the nz function in tradingview. Hoping one of you guys have done this already or can give me guidance on how to tackle the RMA and the nz issue. Thanks in advance!

Code:
study(title="RSI cyclic smoothed", shorttitle="cRSI")
src = close
domcycle = input(20, minval=10, title="Dominant Cycle Length")
crsi = 0.0
cyclelen = domcycle / 2
vibration = 10
leveling = 10.0
cyclicmemory = domcycle * 2
//set min/max ranges?

h1 = hline(30, color=color.silver, linestyle=hline.style_dashed)
h2 = hline(70, color=color.silver, linestyle=hline.style_dashed)

torque = 2.0 / (vibration + 1)
phasingLag = (vibration - 1) / 2.0

up = rma(max(change(src), 0), cyclelen)
down = rma(-min(change(src), 0), cyclelen)
rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - 100 / (1 + up / down)
crsi := torque * (2 * rsi - rsi[phasingLag]) + (1 - torque) * nz(crsi[1])

lmax = -999999.0
lmin = 999999.0
for i = 0 to cyclicmemory - 1 by 1
    if nz(crsi[i], -999999.0) > lmax
        lmax := nz(crsi[i])
        lmax
    else
        if nz(crsi[i], 999999.0) < lmin
            lmin := nz(crsi[i])
            lmin

mstep = (lmax - lmin) / 100
aperc = leveling / 100

db = 0.0
for steps = 0 to 100 by 1
    testvalue = lmin + mstep * steps
    above = 0
    below = 0
    for m = 0 to cyclicmemory - 1 by 1
        below := below + iff(crsi[m] < testvalue, 1, 0)
        below

    ratio = below / cyclicmemory
    if ratio >= aperc
        db := testvalue
        break
    else
        continue

ub = 0.0
for steps = 0 to 100 by 1
    testvalue = lmax - mstep * steps
    above = 0
    for m = 0 to cyclicmemory - 1 by 1
        above := above + iff(crsi[m] >= testvalue, 1, 0)
        above

    ratio = above / cyclicmemory
    if ratio >= aperc
        ub := testvalue
        break
    else
        continue


lowband = plot(db, "LowBand", color.aqua)
highband = plot(ub, "HighBand", color.aqua)
fill(h1, h2, color=color.silver, transp=90)
fill(lowband, highband, color=color.gray, transp=90)
plot(crsi, "CRSI", color.fuchsia)
 

mmgrode73

New member
Hello Everyone,

I recently came across a pinescript indicator set and have been trying to make it work in thinkscript(thinkorswim) but, frankly, I don't know where to start. Here is the pinescript code:

Code:
study(title="SMA 9/50/180 | EMA 20 | BUY/SELL", overlay=true)

//SMA and EMA code
smaInput1 = input(9, title="SMA1")
smaInput2 = input(50, title="SMA2")
smaInput3 = input(180, title="SMA3")
emaInput1 = input(20, title="EMA1")
sma1 = sma(close, smaInput1)
sma2 = sma(close, smaInput2)
sma3 = sma(close, smaInput3)
EMA1 = ema(close, emaInput1)
plot(sma1, color= color.red , title="SMA1")
plot(sma2, color = color.blue, title="SMA2")
plot(sma3, color= color.white, title="SMA3")
plot(EMA1, color = color.yellow, title="EMA1")

//@version=4
no=input(3,title="BUY/SELL Swing")
Barcolor=input(false,title="BUY/SELL Bar Color")
Bgcolor=input(false,title="BUY/SELL Background Color")
res=highest(high,no)
sup=lowest(low,no)
avd=iff(close>res[1],1,iff(close<sup[1],-1,0))
avn=valuewhen(avd!=0,avd,0)
tsl=iff(avn==1,sup,res)
Buy=crossover(close,tsl)
Sell=crossunder(close,tsl)
plotshape(Buy,title="Buy", color=color.green, style=shape.arrowup,location=location.belowbar, text="Buy")
plotshape(Sell,title="Sell", color=color.red, style=shape.arrowdown,text="Sell")
colr = close>=tsl ? color.green : close<=tsl ? color.red : na
plot(tsl, color=colr, linewidth=3, title="BUY/SELL Chart Line")
barcolor(Barcolor ? colr : na)
bgcolor(Bgcolor ? colr :na)
alertcondition(Buy, title="Buy Signal", message="Buy")
alertcondition(Sell, title="Sell Signal", message="Sell")

Is there any way to convert this? Any help with this would be greatly appreciated.

Cheers,
Matt G
 

CasualPhoenix

New member
Hello everyone.

If Its possible I'd like to learn how to convert Tradingview code to TOS myself so as to not freeload.
But until then, I'd like to Add more Supply/Demand and Wyckoff Indicators to the Thinkscript list. Is anyone able to convert these batches of tradingview scripts to Think or Swim?

I'll try to make them as neat as possible to anyone that wants to convert these and help test them to see how useful they are.
If I display any duplicates of existing converted TOS Indicators please omit.

I included the.
  1. Title
  2. Code
  3. Source of code.
If my codes pasted here are an issue, I linked the original page so you can copy/paste the codes from there.

_______________________________________________________________________________________________________________

Title: Basing Candles
Code:
Code:
//@version=2
study("Basing Candles",overlay=true)
body = (close>open) ? (close-open) : (open-close)
isBaseCandle = body <= (high-low)/2
plot(isBaseCandle ? (open+close)/2 : na, color=white, style=circles, transp=0, linewidth=2, offset=0)
Source: https://www.tradingview.com/script/xfNGZoer-Basing-Candles/

_______________________________________________________________________________________________________________

Volume Based S/R
Code:
//@version=3
study(title="Volume Based S/R", shorttitle="VSR", precision=0, overlay=true)

length = input(20, minval=1)
change = volume/volume[1] - 1
stdev = stdev(change, length)
difference = change / stdev[1]
Treshold = input(5)
zero = 0
signal = abs(difference)

leveluphi = valuewhen(signal > Treshold,high[1],0)
leveluplo = valuewhen(signal > Treshold,low[1],0)

//plot(UpperTreshold, color=black)
p1 = plot(leveluphi,style=circles,color=blue)
p2 = plot(leveluplo,style=circles,color=blue)
fill(p1,p2,color=green,transp=90)
//plot(abs(sigma), color = palette, style=columns, title="Volume", transp=65)
Source: https://www.tradingview.com/script/XchidFiQ-Volume-Based-S-R/

_______________________________________________________________________________________________________________

Title: Dynamic SUPRES Multi Timeframe Update
Works Similarly to Bollinger Bands

Code:
study(title="Dynamic SUPRES",shorttitle="DySR", overlay=true)

multiplier = input(title="M", type=float, defval=1.21, minval=0.5, maxval=1.9)
timeframe = input(title="Timeframe", type=resolution, defval="60")
barsc = input(title="BarsColor", type=bool, defval=true)

o = security(tickerid,timeframe,open)
c = security(tickerid,timeframe,close)
atr = security(tickerid,timeframe,sma(tr,5))

anomalia = abs(o-c) > multiplier*atr ? 1 : 0
barcolor(anomalia==1 and barsc==1?silver:na,0)

dot = (anomalia == 1 and c<o)?o+atr:(anomalia == 1 and c>o)?o-atr:na
plotshape(dot,style=shape.square, color=black, location=location.absolute, transp=0)
Source: https://www.tradingview.com/script/6cunN0GZ-Dynamic-SUPRES-Multi-Timeframe-Update/

_______________________________________________________________________________________________________________
Title: [PX] MTF Standard Deviation Level
Code:
//@version=4
study(title="[PX] Standard Deviation Level", overlay=true)

//{
len = input(20, "Length")
multi = input(2.0, "Sensitivity")
res = input(title="Resolution", type=input.resolution, defval="D")
rProgressColor = input("orange", title="Resistance Color (in progress)", options=["aqua","black","blue","fuchsia","gray","green","lime","maroon","navy","olive","orange","purple","red","silver","teal","white","yellow"])
rSettledColor = input("aqua", title="Resistance Color (settled)", options=["aqua","black","blue","fuchsia","gray","green","lime","maroon","navy","olive","orange","purple","red","silver","teal","white","yellow"])
rStyle = input("solid", title="Resistance style", options=['solid','dotted','dashed'])
rWidth = input(1, title="Resistance Width")
sProgressColor = input("orange", title="Support Color (in progress)", options=["aqua","black","blue","fuchsia","gray","green","lime","maroon","navy","olive","orange","purple","red","silver","teal","white","yellow"])
sSettledColor = input("aqua", title="Support Color (settled)", options=["aqua","black","blue","fuchsia","gray","green","lime","maroon","navy","olive","orange","purple","red","silver","teal","white","yellow"])
sStyle = input("solid", title="Support style", options=['solid','dotted','dashed'])
sWidth = input(1, title="Support Width")
//} --------------- INPUT
//{
var bool overbought_active = false
var bool oversold_active = false
var float resistance = na
var float support = na
var int rFrom = 0
var int rTo = 0
var int sFrom = 0
var int sTo = 0
var rId = line(na)
var sId = line(na)

src = stdev(close, len)
up = close + (src * multi)
dn = close - (src * multi)
upperThreshold = security(syminfo.tickerid, res, up[1], lookahead=barmerge.lookahead_on)
lowerThreshold = security(syminfo.tickerid, res, dn[1], lookahead=barmerge.lookahead_on)

//} --------------- INIT
//{
//{
f_calc_bar_time(offset) => ret = time + ((time-time[1]) * offset)
//} --- f_calc_bar_time()
//{
f_set_color(selection)=>
    ret = color.black
    if selection == "gray"
        ret := color.gray
    if selection == "green"
        ret := color.green
    if selection == "aqua"
        ret := color.aqua
    if selection == "blue"
        ret := color.blue
    if selection == "fuchsia"
        ret := color.fuchsia
    if selection == "lime"
        ret := color.lime
    if selection == "maroon"
        ret := color.maroon
    if selection == "navy"
        ret := color.navy
    if selection == "white"
        ret := color.white
    if selection == "yellow"
        ret := color.yellow
    if selection == "olive"
        ret := color.olive
    if selection == "orange"
        ret := color.orange
    if selection == "purple"
        ret := color.purple
    if selection == "red"
        ret := color.red
    if selection == "silver"
        ret := color.silver
    if selection == "teal"
        ret := color.teal
    ret
//} --- f_set_color()
//{
f_set_style(selection)=>
    ret = line.style_solid
    if selection == "dotted"
        ret := line.style_dotted
    if selection == "dashed"
        ret := line.style_dashed
    ret
//} --- f_set_style()
//} --------------- FUNCTIONS

//{
if high > upperThreshold and not overbought_active[1]
    overbought_active := true
    resistance := high
    rFrom := bar_index[1]
    rTo := bar_index
    rId := line.new(rFrom, resistance, rTo, resistance, color=f_set_color(rProgressColor), extend=extend.right, width=rWidth, style=f_set_style(rStyle))
if overbought_active[1]
    if high >= resistance
        resistance := high
        line.set_x1(rId, bar_index[1])
        line.set_x2(rId, bar_index)
        line.set_y1(rId, high)
        line.set_y2(rId, high)
    else
        overbought_active := false
        line.set_color(rId, f_set_color(rSettledColor))

if low < lowerThreshold and not oversold_active[1]
    oversold_active := true
    support := low
    sFrom := bar_index[1]
    sTo := bar_index
    sId := line.new(sFrom, support, sTo, support, color=f_set_color(sProgressColor), extend=extend.right, width=sWidth, style=f_set_style(sStyle))
if oversold_active[1]
    if low <= support
        support := low
        line.set_x1(sId, bar_index[1])
        line.set_x2(sId, bar_index)
        line.set_y1(sId, low)
        line.set_y2(sId, low)
    else
        oversold_active := false
        line.set_color(sId, f_set_color(sSettledColor))
//} --------------- LOGIC
Source: https://www.tradingview.com/script/LZpXY92Y-PX-MTF-Standard-Deviation-Level/

_______________________________________________________________________________________________________________

Title: Godmode 4.0.2 [Supply/Demand]
Code:
//Massive thank you to LEGION, LazyBear, xSilas, Ni6HTH4wK, sco77m4r7and, SNOW_CITY, oh92,
//... alexgrover, cI8DH, DonovanWall and shtcoinr for doing the initial builds, building
//... indicators that I incorporated into this script or just generally giving me a hand
//... when needed.

//@version=3
tag0 = "Godmode"

study(tag0 + " 4.0.2", tag0 + " Supply/Demand", true)

//Interior
ben0 = input("CRYPTOCAP:BTC", "Benchmark", string)
src0 = input(hlc3, "Source")
len0 = input(9, "Channel Length")
len1 = input(26, "Average Length")
len2 = input(13, "Short length")
cou0 = input(5, "Count")
smo0 = input(false, "Smoothing")

//Engine
src1 = ben0 != tickerid ? security(ben0, period, src0) : security(tickerid, period, src0)

ttsi(_src, _len0, _len1) =>
    pc = change(_src) / avg(_src, _src[1])
    ma0 = ema(pc, _len0)
    ma1 = ema(ma0, _len1)
    apc = abs(_src - _src[1])
    ma2 = ema(apc, _len0)
    ma3 = ema(ma2, _len1)
    ttsi = 100 * (ma1 / ma3)

tci(_src) =>
    ema((_src - ema(_src, len0)) / (0.025 * ema(abs(_src - ema(_src, len0)), len0)), len1) + 50

mf(_src) =>
    rsi(sum(volume * (change(_src) <= 0 ? 0 : _src), len2), sum(volume * (change(_src) >= 0 ? 0 : _src), len2))

willy(_src) =>
    60 * (_src - highest(_src, len1)) / (highest(_src, len1) - lowest(_src, len1)) + 80

csi(_src) =>
    avg(rsi(_src, len2), ttsi(_src, len0, len1) * 50 + 50)

godmode(_src) =>
    avg(tci(_src), csi(_src), mf(_src), willy(_src))

tradition(_src) =>
    avg(tci(_src), mf(_src), rsi(_src, len2))

wt0 = ben0 != tickerid ? godmode(src1) : tradition(src1)
swt0 = sma(wt0, len0)

gm = smo0 ? swt0 : wt0

gr = 0
incrementer_up = gm > 70 ? 1 : 0
if incrementer_up
    gr := nz(gr[1], 0) + incrementer_up
else
    gr = 0
grH = if (gr >= cou0)
    x = high
grL = if (gr >= cou0)
    y = low
grh = fixnan(grH)
grl = fixnan(grL)

gs = 0
incrementer_down = gm < 30 ? 1 : 0
if incrementer_down
    gs := nz(gs[1], 0) + incrementer_down
else
    gs = 0
gsH = if (gs >= cou0)
    x = high
gsL = if (gs >= cou0)
    y = low
gsh = fixnan(gsH)
gsl = fixnan(gsL)

gsdx = 0
incrementer_both = gm > 70 or gm < 30 ? 1 : 0
if incrementer_both
    gsdx := nz(gsdx[1], 0) + incrementer_both
else
    gsdx = 0
gsdH = if (gsdx >= cou0)
    x = high
gsdL = if (gsdx >= cou0)
    y = low
gsdh = fixnan(gsdH)
gsdl = fixnan(gsdL)

//Chassis
p1 = plot(gsh, "High Support", lime, 1, circles)
p2 = plot(gsl, "Low Support", green, 1, circles)
p3 = plot(grh, "High Resistance", red, 1, circles)
p4 = plot(grl, "Low Resistance", fuchsia, 1, circles)
p5 = plot(gsdh, "High Supply Above/Demand Below", orange, 1, circles)
p6 = plot(gsdl, "Low Supply Above/Demand Below", yellow, 1, circles)

fill(p1, p2, olive)
fill(p3, p4, maroon)
fill(p5, p6, blue)
Source: https://www.tradingview.com/script/xP4FsDqA-Godmode-4-0-2-Supply-Demand/
_______________________________________________________________________________________________________________


Title: Demand and Supply Candles-open
Code:
//@version=3
study("Demand and Supply Candles-open", overlay=true, scale=scale.none)
//Input
Sensitivity = input(title="LegoutStrength",type=float,defval=1.5,minval=1.0,maxval=2.0,step=0.5)
//Variable Declaration
Candle_Range = high - low
Body_Range = abs( close - open )
//Boring Candles or Basing Candles Body Range <= 50% of Candle Range
barcolor( (Body_Range <= Candle_Range * 0.5) ? blue : na)
//Explosive Candles Logic
Bar_Lookback = 100
Volatility = atr(Bar_Lookback)
//Sensitivity = 1.5
Strength = Volatility * Sensitivity
barcolor( ( (Body_Range > Candle_Range * 0.6) and (Candle_Range >= Strength) ) ? black : na)

Source: https://www.tradingview.com/script/KRlFYBWy-Demand-and-Supply-Candles-open/

Title: Indicators: Volume Zone Indicator & Price Zone Indicator
Code:
//
// @author LazyBear
//
// If you use this code in its original/modified form, do drop me a note.
//

Code:
study("Volume Zone Oscillator [LazyBear]", shorttitle="VZO_LB")
length=input(20, title="MA Length")

dvol=sign(close-close[1]) * volume
dvma=ema(dvol, length)
vma=ema(volume, length)
vzo=iff(vma != 0, 100 * dvma / vma,0)

hline(60, color=red)
hline(40, color=gray)
hline(20, color=gray)
hline(0, color=gray)
hline(-20, color=gray)
hline(-40, color=gray)
hline(-60, color=green)

plot(vzo, color=maroon, linewidth=2)
Source: https://www.tradingview.com/script/eM057Bu5-Indicators-Volume-Zone-Indicator-Price-Zone-Indicator/

Wyckoff Indicators. Title: JSE Wyckoff Wave Volume Code
Code:
//
// JSE Wyckoff Wave Volume -SteynTrade
//
// The Stock Market Institute (SMI) describes an propriety indicator the "SMI Wyckoff Wave" for US Stocks. This code is an attempt to make a Wyckoff Wave for the Johannesburg Stock Exchange (JSE).
// The JSE Wyckoff Wave is in a separate code. This is the code for the volume of the wave. Please see code for the JSE Wyckoff Wave which goes with this indicator.
//
// The Wave presents a normalized price for the 10 selected stocks (An Index for the 10 stocks).
// The theory is to select stocks that are widely held, market leaders, actively traded and participate in important market moves.
// This is only my attempt to select 10 stocks and a different selection can be made.
// I am not certain how SMI determine their weightings but what I have done it to equalize the Rand value of the stock volume so that moves are of equal magnitude.
// The then provides a view of the overall condition of the market and volume flow in the market.
//
// I have used the September 2018 price to normalize the stock price for the 10 selected stocks based. The stocks and weightings can be changed periodically depending on the performance and leadership.
//
// Please, let me know if there is a better work around this.

study("JSE Wyckoff Wave Volume V 1.0", shorttitle="JSE WW Vol_SteynTrade V1.0")

//Get volume and closing price for stocks and weight them
v=(security("JSE:BTI", period, volume)/0.79+security("JSE:SHP", period, volume)/2.87+
    security("JSE:NPN", period, volume)/0.18+security("JSE:AGL", period, volume)/1.96+security("JSE:SOL", period, volume)+
    security("JSE:CFR", period, volume)/4.42+security("JSE:MND", period, volume)/1.40+security("JSE:MTN", period, volume)/7.63+
    security("JSE:SLM", period, volume)/7.29+security("JSE:FSR", period, volume)/8.25)/10

c=(security("JSE:BTI", period, close)*0.79+security("JSE:SHP", period, close)*2.87+security("JSE:NPN", period, close)*0.18+
    security("JSE:AGL", period, close)*1.96+security("JSE:SOL", period, close)+security("JSE:CFR", period, close)*4.42+
    security("JSE:MND", period, close)*1.40+security("JSE:MTN", period, close)*7.63+security("JSE:SLM", period, close)*7.29+
    security("JSE:FSR", period, close)*8.25)/10

//Determine the color of the bars to help identify high or low volumn
lookback= input(21)
vsma=sma(v,lookback)
vstd=stdev(v,lookback)

col=    iff(c>c[1] and v>(vsma+(2 * vstd)), green,
    iff(c>c[1] and v>vsma, olive,
    iff(c<c[1] and v>(vsma+(2 * vstd)), red,
    iff(c<c[1] and v>vsma, maroon,
    iff (v<(vsma-vstd), fuchsia, gray)))))


plot(v, style=columns, color=col)

Source: https://www.tradingview.com/script/9QRUHhLJ-JSE-Wyckoff-Wave-Volume-Code/

Title: Wyckoff Volume Color

Code:
study("Wyckoff Volume Color", shorttitle="WyckVol")
lookback=input(10)
showMA=input(true)
lengthMA=input(20)
TimesMA=input(2)
p2=close
v2=volume
p1=p2[lookback]
v1=sma(v2, lengthMA)*TimesMA
c=    iff(p2>p1 and v2>v1, green,
    iff(p2>p1 and v2<v1, blue,
    iff(p2<p1 and v2<v1, orange,
    iff(p2<p1 and v2>v1, red, gray))))
plot(v2, style=columns, color=c)
plot(showMA?sma(v2, lengthMA):na, color=black)

Source: https://www.tradingview.com/script/q9vexZTT-Wyckoff-Volume-Color/

Title: JSE Wyckoff Wave
This ones based off Wyckoff method and the 5 Phases of Accumulation and Distribution along with the Mark up and down phases.
I'm unclear how it handles labeling ReAccumulation/ReDistribution

Code:
//
// JSE Wyckoff Wave - SteynTrade V 1.0

// The Stock Market Institute (SMI) describes an propriety indicator the "SMI Wyckoff Wave".
// This is an attempt to make a Wyckoff Wave for the JSE. Please see code for the JSE Wyckoff Wave Volume which goes with this indicator.
// This Wave presents a normalised price for the 10 selected stocks (An Index for the 10 stocks).
// The theory is to select stocks that are widely held, market leaders, actively traded and participate in important market moves.
// The then provides a view of the overall condition of the market and volume flow in the market with the JSE Wyckoff Wave Volume.
//
// This is only my attempt to select 10 stocks and a different selection can be made.
// I am not certain how SMI determine their weightings but what I have done it to equalize the Rand value of the stock so that moves are of equal magnitude.
//
// I have used the September 2018 price to normalize the stock price for the 10 selected stocks based.
// The stocks and weightings can be changed periodically depending on the performance and leadership.
//
// Most Indecies when constructed assume that all high prices and all low prices happen at the same time and therefor inflate the wicks of the bars.
// To make the wave more representatives for the SMI Wyckoff Wave the price is determined on the 5 minute timeframe which removes this bias.
// However, TradingView does not calculate properly when selecting a lower timeframe than in current period.
// A work around is to call the sma of the highs and add these which provides more realistic tails.
// Please, let me know if there is a better work around this.

study("JSE Wyckoff Wave", shorttitle="JSE WW_SteynTrade")

t=iff(isweekly, 720,
    iff(isdaily, 144, 24))

c=(security("JSE:BTI", period, close)*0.79+security("JSE:SHP", period, close)*2.87+security("JSE:NPN", period, close)*0.18+
    security("JSE:AGL", period, close)*1.96+security("JSE:SOL", period, close)+security("JSE:CFR", period, close)*4.42+
    security("JSE:MND", period, close)*1.40+security("JSE:MTN", period, close)*7.63+security("JSE:SLM", period, close)*7.29+
    security("JSE:FSR", period, close)*8.25)/10

h=(security("JSE:BTI", "10", sma(high,t))*0.79+security("JSE:SHP", "10", sma(high,t))*2.87+security("JSE:NPN", "10", sma(high,t))*0.18+
    security("JSE:AGL", "10", sma(high,t))*1.96+security("JSE:SOL", "10", sma(high,t))+security("JSE:CFR", "10", sma(high,t))*4.42+
    security("JSE:MND", "10", sma(high,t))*1.40+security("JSE:MTN", "10", sma(high,t))*7.63+security("JSE:SLM", "10", sma(high,t))*7.29+
    security("JSE:FSR", "10", sma(high,t))*8.25)/10


l=(security("JSE:BTI", "10", sma(low,t))*0.79+security("JSE:SHP", "10", sma(low,t))*2.87+security("JSE:NPN", "10", sma(low,t))*0.18+
    security("JSE:AGL", "10", sma(low,t))*1.96+security("JSE:SOL", "10", sma(low,t))+security("JSE:CFR", "10", sma(low,t))*4.42+
    security("JSE:MND", "10", sma(low,t))*1.40+security("JSE:MTN", "10", sma(low,t))*7.63+security("JSE:SLM", "10", sma(low,t))*7.29+
    security("JSE:FSR", "10", sma(low,t))*8.25)/10

o=(security("JSE:BTI", period, open)*0.79+security("JSE:SHP", period, open)*2.87+security("JSE:NPN", period, open)*0.18+
    security("JSE:AGL", period, open)*1.96+security("JSE:SOL", period, open)+security("JSE:CFR", period, open)*4.42+
    security("JSE:MND", period, open)*1.40+security("JSE:MTN", period, open)*7.63+security("JSE:SLM", period, open)*7.29+
    security("JSE:FSR", period, open)*8.25)/10


// Set the color of the bar
col=iff(c>c[1], green, red)

plotcandle(o, h, l, c, color=col)

Source: https://www.tradingview.com/script/wITsyXKV-JSE-Wyckoff-Wave/

Title: Wyckoff Wave

Code:
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © MartinShkreli

//@version=4
study("Wyckoff Wave")
f_secureSecurity(_symbol, _res, _src) => security(_symbol, _res, _src, lookahead = barmerge.lookahead_on)

o = nz(f_secureSecurity('NYSE:T*79+NYSE:BAC*50+NYSE:BA*39+NYSE:BMY*119+NYSE:CAT*35+NYSE:DOW*24+NYSE:D D*24+NYSE:XOM*32+NYSE:IBM*21+NYSE:GE*90', "D", open))
o := o + nz(f_secureSecurity('NYSE:F*25+NYSE:UNP*60+NYSE:WMT*43+NYSE:CTVA*24', "D", open))
h = nz(f_secureSecurity('NYSE:T*79+NYSE:BAC*50+NYSE:BA*39+NYSE:BMY*119+NYSE:CAT*35+NYSE:DOW*24+NYSE:D
D*24+NYSE:XOM*32+NYSE:IBM*21+NYSE:GE*90', "D", high))
h := h + nz(f_secureSecurity('NYSE:F*25+NYSE:UNP*60+NYSE:WMT*43+NYSE:CTVA*24', "D", high))
l = nz(f_secureSecurity('NYSE:T*79+NYSE:BAC*50+NYSE:BA*39+NYSE:BMY*119+NYSE:CAT*35+NYSE:DOW*24+NYSE:D
D*24+NYSE:XOM*32+NYSE:IBM*21+NYSE:GE*90', "D", low))
l := l + nz(f_secureSecurity('NYSE:F*25+NYSE:UNP*60+NYSE:WMT*43+NYSE:CTVA*24', "D", low))
c = nz(f_secureSecurity('NYSE:T*79+NYSE:BAC*50+NYSE:BA*39+NYSE:BMY*119+NYSE:CAT*35+NYSE:DOW*24+NYSE:D
D*24+NYSE:XOM*32+NYSE:IBM*21+NYSE:GE*90', "D", close))
c := c + nz(f_secureSecurity('NYSE:F*25+NYSE:UNP*60+NYSE:WMT*43+NYSE:CTVA*24', "D", close))

// Set the color of the bar
col=iff(c>c[1], color.green, color.red)

plotcandle(o, h, l, c, color=col)

Source: https://www.tradingview.com/script/WWsqmrNb-Wyckoff-Wave/

Weis Wave Volume
Code:
//@version=4
study("Weis Wave Volume", shorttitle="WWV", overlay=false, resolution="")
method = input(defval="ATR", options=["ATR", "Traditional", "Part of Price"], title="Renko Assignment Method")
methodvalue = input(defval=14.0, type=input.float, minval=0, title="Value")
pricesource = input(defval="Close", options=["Close", "Open / Close", "High / Low"], title="Price Source")
useClose = pricesource == "Close"
useOpenClose = pricesource == "Open / Close" or useClose
useTrueRange = input(defval="Auto", options=["Always", "Auto", "Never"], title="Use True Range instead of Volume")
isOscillating = input(defval=false, type=input.bool, title="Oscillating")
normalize = input(defval=false, type=input.bool, title="Normalize")
vol = useTrueRange == "Always" or useTrueRange == "Auto" and na(volume) ? tr : volume
op = useClose ? close : open
hi = useOpenClose ? close >= op ? close : op : high
lo = useOpenClose ? close <= op ? close : op : low

if method == "ATR"
    methodvalue := atr(round(methodvalue))
if method == "Part of Price"
    methodvalue := close / methodvalue

currclose = float(na)
prevclose = nz(currclose[1])
prevhigh = prevclose + methodvalue
prevlow = prevclose - methodvalue
currclose := hi > prevhigh ? hi : lo < prevlow ? lo : prevclose

direction = int(na)
direction := currclose > prevclose ? 1 : currclose < prevclose ? -1 : nz(direction[1])
directionHasChanged = change(direction) != 0
directionIsUp = direction > 0
directionIsDown = direction < 0

barcount = 1
barcount := not directionHasChanged and normalize ? barcount[1] + barcount : barcount
vol := not directionHasChanged ? vol[1] + vol : vol
res = barcount > 1 ? vol / barcount : vol

plot(isOscillating and directionIsDown ? -res : res, style=plot.style_columns, color=directionIsUp ? color.green : color.red, transp=75, linewidth=3, title="Wave Volume")

Source: https://www.tradingview.com/script/QrCFs0K2-Weis-Wave-Volume/

Title: Money Tree
Code:
//@version=3
//

strategy(title = "Money Tree", shorttitle = "Money Tree", overlay = true,
  pyramiding = 0, default_qty_type = strategy.percent_of_equity, default_qty_value = 100, calc_on_every_tick=true)

//
// Revision:        6
// Original Author: @JayRogers
// Revision Author: JustUncleL revisions 3, 4, 5
// Revison Author: Dozza
//
// * USE AT YOUR OWN RISK *
//  - There are drawing/painting issues in pinescript when working across resolutions/timeframes that I simply
//    cannot fix here.. I will not be putting any further effort into developing this until such a time when
//    workarounds become available.
//    NOTE: Re-painting has been observed infrequently with default settings and seems OK up to Alternate
//          multiplier of 5.
//          Non-repainting mode is available by setting "Delay Open/Close MA" to 1 or more, but the reported
//          performance will drop dramatically.
//
// R6 Changes by Dozza
//  - Add chop indicator to remove false starts and reduce the amount of trades during choppyness. WIP.
//
//
// R5.1 Changes by JustUncleL
//  - Upgraded to Version 3 Pinescript.
//  - Added option to select Trade type (Long, Short, Both or None)
//  - Added bar colouring work around patch.
//  - Small code changes to improve efficiency.
//  - NOTE: To enable non-Repainting mode set "Delay Open/Close MA" to 1 or more.
//  9-Aug-2017
//  - Correction on SuperSmooth MA calculation.
//
// R5 Changes by JustUncleL
//  - Corrected cross over calculations, sometimes gave false signals.
//  - Corrected Alternate Time calculation to allow for Daily,Weekly and Monthly charts.
//  - Open Public release.
// R4 Changes By JustUncleL
//  - Change the way the Alternate resolution in selected, use a Multiplier of the base Time Frame instead,
//    this makes it easy to switch between base time frames.
//  - Added TMA and SSMA moving average options. But DEMA is still giving the best results.
//  - Using "calc_on_every_tick=false" ensures results between backtesting and real time are similar.
//  - Added Option to Disable the coloring of the bars.
//  - Updated default settings.
//
// R3 Changes by JustUncleL:
//  - Returned a simplified version of the open/close channel, it shows strength of current trend.
//  - Added Target Profit Option.
//  - Added option to reduce the number of historical bars, overcomes the too many trades limit error.
//  - Simplified the strategy code.
//  - Removed Trailing Stop option, not required and in my opion does not work well in Trading View,
//    it also gives false and unrealistic performance results in backtesting.
//
// R2 Changes:
//  - Simplified and cleaned up plotting, now just shows a Moving Average derived from the average of open/close.
//  - Tried very hard to alleviate painting issues caused by referencing alternate resolution..
//
// Description:
//  - Strategy based around Open-Close Crossovers.
// Setup:
//  - I have generally found that setting the strategy resolution to 3-4x that of the chart you are viewing
//    tends to yield the best results, regardless of which MA option you may choose (if any) BUT can cause
//    a lot of false positives - be aware of this
//  - Don't aim for perfection. Just aim to get a reasonably snug fit with the O-C band, with good runs of
//    green and red.
//  - Option to either use basic open and close series data, or pick your poison with a wide array of MA types.
//  - Optional trailing stop for damage mitigation if desired (can be toggled on/off)
//  - Positions get taken automagically following a crossover - which is why it's better to set the resolution
//    of the script greater than that of your chart, so that the trades get taken sooner rather than later.
//  - If you make use of the stops, be sure to take your time tweaking the values. Cutting it too fine
//    will cost you profits but keep you safer, while letting them loose could lead to more drawdown than you
//    can handle.
//  - To enable non-Repainting mode set "Delay Open/Close MA" to 1 or more.
//

// === INPUTS ===
useRes      = input(defval = true, title = "Use Alternate Resolution?")
intRes      = input(defval = 5,    title = "Multiplier for Alernate Resolution")
stratRes    = ismonthly? tostring(interval*intRes,"###M") : isweekly? tostring(interval*intRes,"###W") : isdaily?  tostring(interval*intRes,"###D") : isintraday ? tostring(interval*intRes,"####") : '60'
basisType   = input(defval = "DEMA", title = "MA Type: ", options=["SMA", "EMA", "DEMA", "TEMA", "WMA", "VWMA", "SMMA", "HullMA", "LSMA", "ALMA", "SSMA", "TMA"])
basisLen    = input(defval = 8, title = "MA Period", minval = 1)
offsetSigma = input(defval = 6, title = "Offset for LSMA / Sigma for ALMA", minval = 0)
offsetALMA  = input(defval = 0.85, title = "Offset for ALMA", minval = 0, step = 0.01)
scolor      = input(true, title="Show coloured Bars to indicate Trend?")
delayOffset = input(defval = 1, title = "Delay Open/Close MA (Forces Non-Repainting)", minval = 0, step = 1)
tradeType   = input("LONG", title="What trades should be taken : ", options=["LONG", "SHORT", "BOTH", "NONE"])
// === /INPUTS ===

// Constants colours that include fully non-transparent option.
green100 = #008000FF
lime100  = #00FF00FF
red100   = #FF0000FF
blue100  = #0000FFFF
aqua100  = #00FFFFFF
darkred100 = #8B0000FF
gray100 = #808080FF

// === BASE FUNCTIONS ===
// Returns MA input selection variant, default to SMA if blank or typo.
variant(type, src, len, offSig, offALMA) =>
    v1 = sma(src, len)                                                  // Simple
    v2 = ema(src, len)                                                  // Exponential
    v3 = 2 * v2 - ema(v2, len)                                          // Double Exponential
    v4 = 3 * (v2 - ema(v2, len)) + ema(ema(v2, len), len)               // Triple Exponential
    v5 = wma(src, len)                                                  // Weighted
    v6 = vwma(src, len)                                                 // Volume Weighted
    v7 = 0.0
    v7 := na(v7[1]) ? sma(src, len) : (v7[1] * (len - 1) + src) / len    // Smoothed
    v8 = wma(2 * wma(src, len / 2) - wma(src, len), round(sqrt(len)))   // Hull
    v9 = linreg(src, len, offSig)                                       // Least Squares
    v10 = alma(src, len, offALMA, offSig)                               // Arnaud Legoux
    v11 = sma(v1,len)                                                   // Triangular (extreme smooth)
    // SuperSmoother filter
    // © 2013  John F. Ehlers
    a1 = exp(-1.414*3.14159 / len)
    b1 = 2*a1*cos(1.414*3.14159 / len)
    c2 = b1
    c3 = (-a1)*a1
    c1 = 1 - c2 - c3
    v12 = 0.0
    v12 := c1*(src + nz(src[1])) / 2 + c2*nz(v12[1]) + c3*nz(v12[2])
    type=="EMA"?v2 : type=="DEMA"?v3 : type=="TEMA"?v4 : type=="WMA"?v5 : type=="VWMA"?v6 : type=="SMMA"?v7 : type=="HullMA"?v8 : type=="LSMA"?v9 : type=="ALMA"?v10 : type=="TMA"?v11: type=="SSMA"?v12: v1

// security wrapper for repeat calls
reso(exp, use, res) => use ? security(tickerid, res, exp, gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_off) : exp

// === /BASE FUNCTIONS ===

// === SERIES SETUP ===
closeSeries     = variant(basisType, close[delayOffset], basisLen, offsetSigma, offsetALMA)
openSeries      = variant(basisType, open[delayOffset], basisLen, offsetSigma, offsetALMA)
// === /SERIES ===

// === PLOTTING ===

// Get Alternate resolution Series if selected.
closeSeriesAlt = reso(closeSeries, useRes, stratRes)
openSeriesAlt = reso(openSeries, useRes, stratRes)
//
trendColour = (closeSeriesAlt > openSeriesAlt) ? green: red
bcolour    = (closeSeriesAlt > openSeriesAlt) ? green : red
barcolor(scolor?bcolour:na, title = "Bar Colours")
closeP=plot(closeSeriesAlt, title = "Close Series", color = trendColour, linewidth = 2, style = line, transp = 20)
openP=plot(openSeriesAlt, title = "Open Series", color = trendColour, linewidth = 2, style = line, transp = 20)
fill(closeP,openP,color=trendColour,transp=80)

// === /Chop Indicator ===

colorTurquoise = #34dddd
colorDarkGreen = #006400
colorPaleGreen = #98fb98
colorLime = lime
colorDarkRed = #8B0000
colorRed = red
colorOrange = orange
colorLightOrange = #ffc04c
colorYellow = yellow

turquoiseChoppy = input(false, title="Is turquoise considered choppy?")
darkGreenChoppy = input(false, title="Is dark green considered choppy?")
paleGreenChoppy = input(false, title="Is pale green considered choppy?")
limeChoppy = input(false, title="Is lime considered choppy?")
darkRedChoppy = input(true, title="Is dark red considered choppy?")
redChoppy = input(true, title="Is red considered choppy?")
orangeChoppy = input(true, title="Is orange considered choppy?")
lightOrangeChoppy = input(true, title="Is lightOrange considered choppy?")
yellowChoppy = input(true, title="Is yellow considered choppy?")

source = close
avg = hlc3

pi = atan(1) * 4
periods = 30
highestHigh = highest(periods)
lowestLow = lowest(periods)
range = 25 / (highestHigh - lowestLow) * lowestLow

ema34 = ema(source, 34)
x1_ema34 = 0
x2_ema34 = 1
y1_ema34 = 0
y2_ema34 = (ema34[1] - ema34) / avg * range
c_ema34 = sqrt((x2_ema34 - x1_ema34)(x2_ema34 - x1_ema34) + (y2_ema34 - y1_ema34)(y2_ema34 - y1_ema34))
emaAngle_1 = round(180 * acos((x2_ema34 - x1_ema34)/c_ema34) / pi)
emaAngle = iff(y2_ema34 > 0, - emaAngle_1, emaAngle_1)

chopZoneColor = emaAngle >= 5 ? colorTurquoise : emaAngle < 5 and emaAngle >= 3.57 ? colorDarkGreen : emaAngle < 3.57 and emaAngle >= 2.14 ? colorPaleGreen : emaAngle < 2.14 and emaAngle >= .71 ? colorLime : emaAngle <= -1 * 5 ? colorDarkRed : emaAngle > -1 * 5 and emaAngle <= -1 * 3.57 ? colorRed : emaAngle > -1 * 3.57 and emaAngle <= -1 * 2.14 ? colorOrange : emaAngle > -1 * 2.14 and emaAngle <= -1 * .71 ? colorLightOrange : colorYellow

//choppy = chopZoneColor == colorOrange ? true: chopZoneColor == colorDarkRed ? true : chopZoneColor == colorRed ? true : chopZoneColor == colorOrange ? true : false

choppy = chopZoneColor == colorOrange and orangeChoppy ? true : chopZoneColor == colorDarkRed and darkRedChoppy ? true : chopZoneColor == colorRed and redChoppy ? true : chopZoneColor == colorOrange and orangeChoppy ? true : chopZoneColor == colorTurquoise and turquoiseChoppy ? true : chopZoneColor == colorDarkGreen and darkGreenChoppy ? true : chopZoneColor == colorPaleGreen and paleGreenChoppy ? true : chopZoneColor == colorLime and limeChoppy ? true : chopZoneColor == colorLightOrange and lightOrangeChoppy ? true : chopZoneColor == colorYellow and yellowChoppy ? true : false

// plot(1, color=chopZoneColor, linewidth=4, style=columns)


// === /PLOTTING ===
//

//
// === ALERT conditions
xlong       = crossover(closeSeriesAlt, openSeriesAlt)
xshort      = crossunder(closeSeriesAlt, openSeriesAlt)
longCond    = xlong   // alternative: longCond[1]? false : (xlong or xlong[1]) and close>closeSeriesAlt and close>=open
shortCond   = xshort  // alternative: shortCond[1]? false : (xshort or xshort[1]) and close<closeSeriesAlt and close<=open
// === /ALERT conditions.

// === STRATEGY ===
// stop loss
slPoints    = input(defval = 0, title = "Initial Stop Loss Points (zero to disable)", minval = 0)
tpPoints    = input(defval = 0, title = "Initial Target Profit Points (zero for disable)", minval = 0)
// Include bar limiting algorithm
ebar            = input(defval = 8760, title="Number of Bars for Back Testing", minval=0)
dummy           = input(false,        title="- SET to ZERO for Daily or Longer Timeframes" )
//
// Calculate how many mars since last bar
tdays       = (timenow-time)/60000.0  // number of minutes since last bar
tdays       := ismonthly? tdays/1440.0/5.0/4.3/interval : isweekly? tdays/1440.0/5.0/interval : isdaily? tdays/1440.0/interval : tdays/interval // number of bars since last bar
//
//set up exit parameters
TP = tpPoints>0?tpPoints:na
SL = slPoints>0?slPoints:na

// Make sure we are within the bar range, Set up entries and exit conditions
if ((ebar==0 or tdays<=ebar) and tradeType!="NONE")
    strategy.entry("long", strategy.long, when=longCond==true and tradeType!="SHORT" and choppy==false)
    strategy.entry("short", strategy.short, when=shortCond==true and tradeType!="LONG" and choppy==true)
    strategy.close("long", when = shortCond==true and tradeType=="LONG")
    strategy.close("short", when = longCond==true and tradeType=="SHORT")
    strategy.exit("XL", from_entry = "long", profit = TP, loss = SL)
    strategy.exit("XS", from_entry = "short", profit = TP, loss = SL)

// === /STRATEGY ===
// eof

Source: https://www.tradingview.com/script/96Vxbc2C-Money-Tree/

END.

If I need to reformat, repost, or elaborate on anything especially with the code, I'll be glad to. I noticed emojis show up in posting this, but since I'm new I don't know how to remove them in formatting.


Bonus for anyone that knows of any indicators or create indicators that highlight patterns of:
Drop-Base-Rally
Rally-Base-Rally
And marks them as DBR or RBR on a chart. As Demand Zones.

Rally-Base-Drop
Drop-Base-Drop as RBD and DBD on a chart. As Supply Zones.

if I had the knowledge id create an indicator that uses Sam Seidens Odds Enhancers as well.

Thanks for reading all of this seriously, I know its a lot.
 
Last edited by a moderator:

Volatility Trading Range

VTR is a momentum indicator that shows if a stock is overbought or oversold based on its Weekly and Monthly average volatility trading range.

Download the indicator

Similar threads

Top