Convert Tradingview indicator

F

FOTM_8888

Member
VIP
this indicator look very good.. i've followed for a while is have a good percent of winning trades.. if someone here can convert it into TOS, will be awesome for everyone here. the indicator is Call it: BREAK OUT TRADE FOLLOWER. here is the Trading View Code:

Code:
//@version=4

// Revision:        1
// Author:          @millerrh
// Strategy:  Enter long when recent swing high breaks out, using recent swing low as stop level.  Move stops up as higher lows print to act
// as trailing stops.  Ride trend as long as it is there and the higher lows aren't breached. 
// Conditions/Variables
//    1. Can place a user-defined percentage below swing low and swing high to use as a buffer for your stop to help avoid stop hunts
//    2. Can add a filter to only take setups that are above a user-defined moving average (helps avoid trading counter trend)
//    3. Manually configure which dates to back test
//    4. Color background of backtested dates - allows for easier measuring buy & hold return of time periods that don't go up to current date   


// === CALL STRATEGY/STUDY, PROGRAMATICALLY ENTER STRATEGY PARAMETERS HERE SO YOU DON'T HAVE TO CHANGE THEM EVERY TIME YOU RUN A TEST ===
// (STRATEGY ONLY) - Comment out srategy() when in a study()
//strategy("Breakout Trend Follower", overlay=true, initial_capital=10000, currency='USD',
//   default_qty_type=strategy.percent_of_equity, default_qty_value=100, commission_type=strategy.commission.percent, commission_value=0.1)
// (STUDY ONLY) - Comment out study() when in a strategy()
study("Breakout Trend Follower", overlay=true)

// === BACKTEST RANGE ===
From_Year  = input(defval = 2019, title = "From Year")
From_Month = input(defval = 1, title = "From Month", minval = 1, maxval = 12)
From_Day   = input(defval = 1, title = "From Day", minval = 1, maxval = 31)
To_Year    = input(defval = 9999, title = "To Year")
To_Month   = input(defval = 1, title = "To Month", minval = 1, maxval = 12)
To_Day     = input(defval = 1, title = "To Day", minval = 1, maxval = 31)
Start  = timestamp(From_Year, From_Month, From_Day, 00, 00)  // backtest start window
Finish = timestamp(To_Year, To_Month, To_Day, 23, 59)        // backtest finish window

// A switch to control background coloring of the test period - Use for easy visualization of backtest range and manual calculation of
// buy and hold (via measurement) if doing prior periods since value in Strategy Tester extends to current date by default
testPeriodBackground = input(title="Color Background - Test Period?", type=input.bool, defval=false)
testPeriodBackgroundColor = testPeriodBackground and (time >= Start) and (time <= Finish) ? #00FF00 : na
bgcolor(testPeriodBackgroundColor, transp=95)

// == FILTERING ==
// Inputs
useMaFilter = input(title = "Use MA for Filtering?", type = input.bool, defval = false)
maType = input(defval="SMA", options=["EMA", "SMA"], title = "MA Type For Filtering")
maLength   = input(defval = 200, title = "MA Period for Filtering", minval = 1)

// Declare function to be able to swap out EMA/SMA
ma(maType, src, length) =>
    maType == "EMA" ? ema(src, length) : sma(src, length) //Ternary Operator (if maType equals EMA, then do ema calc, else do sma calc)
maFilter = ma(maType, close, maLength)
plot(maFilter, title = "Trend Filter MA", color = color.green, linewidth = 3, style = plot.style_line, transp = 50)

// Check to see if the useMaFilter check box is checked, this then inputs this conditional "maFilterCheck" variable into the strategy entry
maFilterCheck = if useMaFilter == true
    maFilter
else
    0

// === PLOT SWING HIGH/LOW AND MOST RECENT LOW TO USE AS STOP LOSS EXIT POINT ===
// Inputs
//pvtLenL       = input(3, minval=1, title="Pivot Length Left Hand Side") //use if you want to change this to an input
//pvtLenR       = input(3, minval=1, title="Pivot Length Right Hand Side") //use if you want to change this to an input
pvtLenL       = 3
pvtLenR       = 3

// Get High and Low Pivot Points
pvthi_ = pivothigh(high, pvtLenL, pvtLenR)
pvtlo_ = pivotlow(low, pvtLenL, pvtLenR)

// Force Pivot completion before plotting.
Shunt = 1 //Wait for close before printing pivot? 1 for true 0 for flase
maxLvlLen = 0 //Maximum Extension Length
pvthi = pvthi_[Shunt]
pvtlo = pvtlo_[Shunt]

// Count How many candles for current Pivot Level, If new reset.
counthi = barssince(not na(pvthi))
countlo = barssince(not na(pvtlo))

pvthis = fixnan(pvthi)
pvtlos = fixnan(pvtlo)
hipc = change(pvthis) != 0 ? na : color.maroon
lopc = change(pvtlos) != 0 ? na : color.green

// Display Pivot lines
plot((maxLvlLen == 0 or counthi < maxLvlLen) ? pvthis : na, color=hipc, transp=0, linewidth=1, offset=-pvtLenR-Shunt, title="Top Levels")
plot((maxLvlLen == 0 or countlo < maxLvlLen) ? pvtlos : na, color=lopc, transp=0, linewidth=1, offset=-pvtLenR-Shunt, title="Bottom Levels")
plot((maxLvlLen == 0 or counthi < maxLvlLen) ? pvthis : na, color=hipc, transp=0, linewidth=1, offset=0, title="Top Levels 2")
plot((maxLvlLen == 0 or countlo < maxLvlLen) ? pvtlos : na, color=lopc, transp=0, linewidth=1, offset=0, title="Bottom Levels 2")

// Stop Levels
stopBuff = input(0.0, minval=-2, title="Stop Loss Buffer off Swing Low (%)")
stopPerc = stopBuff*.01 // Turn stop buffer input into a percentage
stopLevel = valuewhen(pvtlo_, low[pvtLenR], 0) //Stop Level at Swing Low
stopLevel2 = stopLevel - stopLevel*stopPerc  // Stop Level with user-defined buffer to avoid stop hunts and give breathing room
plot(stopLevel2, style=plot.style_line, color=color.orange, show_last=1, linewidth=1, transp=50, trackprice=true)
buyLevel = valuewhen(pvthi_, high[pvtLenR], 0) //Buy level at Swing High
buyLevel2 = buyLevel + buyLevel*stopPerc // Buy-stop level with user-defined buffer to avoid stop hunts and give breathing room
plot(buyLevel2, style=plot.style_line, color=color.aqua, show_last=1, linewidth=1, transp=50, trackprice=true)

// Conditions for entry and exit
buySignal = high > buyLevel2
buy = buySignal and time > Start and time < Finish and buyLevel2 > maFilterCheck // All these conditions need to be met to buy
sellSignal = low < stopLevel2 // Code to act like a stop-loss for the Study

// (STRATEGY ONLY) Comment out for Study
// strategy.entry("Long", strategy.long, stop = buyLevel2, when = time > Start and time < Finish and buyLevel2 > maFilterCheck)
// strategy.exit("Exit Long", from_entry = "Long", stop=stopLevel2)

// == (STUDY ONLY) Comment out for Strategy ==
// Check if in position or not
inPosition = bool(na)
inPosition := buy[1] ? true : sellSignal[1] ? false : inPosition[1]
flat = bool(na)
flat := not inPosition
buyStudy = buy and flat
sellStudy = sellSignal and inPosition
//Plot indicators on chart and set up alerts for Study
plotshape(buyStudy, style = shape.triangleup, location = location.belowbar, color = #1E90FF, text = "Buy")
plotshape(sellStudy, style = shape.triangledown, location = location.abovebar, color = #EE82EE, text = "Sell")
alertcondition(buyStudy, title='Breakout Trend Follower Buy', message='Breakout Trend Follower Buy')
alertcondition(sellStudy, title='Breakout Trend Follower Sell', message='Breakout Trend Follower Sell')

// Color background when trade active (for easier visual on what charts are OK to enter on)
tradeBackground = input(title="Color Background for Trades?", type=input.bool, defval=true)
tradeBackgroundColor = tradeBackground and inPosition ? #00FF00 : na
bgcolor(tradeBackgroundColor, transp=95)
noTradeBackgroundColor = tradeBackground and flat ? #FF0000 : na
bgcolor(noTradeBackgroundColor, transp=90)
 
T

TosTrd

New member
Below is a code of Jurik RSX in tradingview's pinescript. Can some thinkscript TopGun convert it for use in TOS, thx !!

Code:
//@version=3
// Copyright (c) 2019-present, Alex Orekhov (everget)
// Jurik RSX script may be freely distributed under the MIT license.
study("Jurik RSX", shorttitle="RSX")

length = input(title="Length", type=integer, defval=14)
src = input(title="Source", type=source, defval=hlc3)
obLevel = input(title="OB Level", type=integer, defval=70)
osLevel = input(title="OS Level", type=integer, defval=30)
highlightBreakouts = input(title="Highlight Overbought/Oversold Breakouts ?", type=bool, defval=true)

f8 = 100 * src
f10 = nz(f8[1])
v8 = f8 - f10

f18 = 3 / (length + 2)
f20 = 1 - f18

f28 = 0.0
f28 := f20 * nz(f28[1]) + f18 * v8

f30 = 0.0
f30 := f18 * f28 + f20 * nz(f30[1])
vC = f28 * 1.5 - f30 * 0.5

f38 = 0.0
f38 := f20 * nz(f38[1]) + f18 * vC

f40 = 0.0
f40 := f18 * f38 + f20 * nz(f40[1])
v10 = f38 * 1.5 - f40 * 0.5

f48 = 0.0
f48 := f20 * nz(f48[1]) + f18 * v10

f50 = 0.0
f50 := f18 * f48 + f20 * nz(f50[1])
v14 = f48 * 1.5 - f50 * 0.5

f58 = 0.0
f58 := f20 * nz(f58[1]) + f18 * abs(v8)

f60 = 0.0
f60 := f18 * f58 + f20 * nz(f60[1])
v18 = f58 * 1.5 - f60 * 0.5

f68 = 0.0
f68 := f20 * nz(f68[1]) + f18 * v18

f70 = 0.0
f70 := f18 * f68 + f20 * nz(f70[1])
v1C = f68 * 1.5 - f70 * 0.5

f78 = 0.0
f78 := f20 * nz(f78[1]) + f18 * v1C

f80 = 0.0
f80 := f18 * f78 + f20 * nz(f80[1])
v20 = f78 * 1.5 - f80 * 0.5

f88_ = 0.0
f90_ = 0.0

f88 = 0.0
f90_ := nz(f90_[1]) == 0 ? 1 : nz(f88[1]) <= nz(f90_[1]) ? nz(f88[1]) + 1 : nz(f90_[1]) + 1
f88 := nz(f90_[1]) == 0 and (length - 1 >= 5) ? length - 1 : 5

f0 = f88 >= f90_ and f8 != f10 ? 1 : 0
f90 = f88 == f90_ and f0 == 0 ? 0 : f90_

v4_ = f88 < f90 and v20 > 0 ? (v14 / v20 + 1) * 50 : 50
rsx = v4_ > 100 ? 100 : v4_ < 0 ? 0 : v4_

rsxColor = rsx > obLevel ? #0ebb23 : rsx < osLevel ? #ff0000 : #f4b77d
plot(rsx, title="RSX", linewidth=2, color=rsxColor, transp=0)

transparent = color(white, 100)

maxLevelPlot = hline(100, title="Max Level", linestyle=dotted, color=transparent)
obLevelPlot = hline(obLevel, title="Overbought Level", linestyle=dotted)
hline(50, title="Middle Level", linestyle=dotted)
osLevelPlot = hline(osLevel, title="Oversold Level", linestyle=dotted)
minLevelPlot = hline(0, title="Min Level", linestyle=dotted, color=transparent)

fill(obLevelPlot, osLevelPlot, color=purple, transp=95)

obFillColor = rsx > obLevel and highlightBreakouts ? green : transparent
osFillColor = rsx < osLevel and highlightBreakouts ? red : transparent

fill(maxLevelPlot, obLevelPlot, color=obFillColor, transp=90)
fill(minLevelPlot, osLevelPlot, color=osFillColor, transp=90)
 
F

Facundo Loto

New member
Hello, I have this code for an indicator that I like and I always have it on my chart, they are Fibonacci pivots, I wanted to ask you if you could program it for TOS, but not all the history of Pivots should appear on the chart.
The ideal of this indicator is to use it in Monthly or weekly in daily charts
The code is in Trading View
Thank you very much!
(Sorry for my English)

Code:
/@version=4
study(title="Fib Pivot Points Alerts", shorttitle="Fib Pivot Points Alerts", overlay = true)

//
// author: QuantNomad
// date: 2019-07-11
// Fibonacci Pivot Points Alerts
// https://www.tradingview.com/u/QuantNomad/
// https://t.me/quantnomad
//

// Function outputs 1 when it's the first bar of the D/W/M/Y
is_newbar(res) =>
    ch = 0
    if(res == 'Y')
        t  = year(time('D'))
        ch := change(t) != 0 ? 1 : 0
    else
        t = time(res)
        ch := change(t) != 0 ? 1 : 0
    ch

////////////
// INPUTS //
////////////

pp_period = input(title = "Period", type=input.string, defval="Day", options = ['Day', 'Week', 'Month', 'Year'])

pp_res = pp_period == 'Day' ? 'D' : pp_period == 'Week' ? 'W' : pp_period == 'Month' ? 'M' : 'Y'

/////////////////////
// Get HLC from HT //

// Calc High
high_cur = 0.0
high_cur := is_newbar(pp_res) ? high : max(high_cur[1], high)

phigh = 0.0
phigh := is_newbar(pp_res) ? high_cur[1] : phigh[1]

// Calc Low
low_cur = 0.0
low_cur := is_newbar(pp_res) ? low : min(low_cur[1], low)

plow = 0.0
plow := is_newbar(pp_res) ? low_cur[1] : plow[1]

// Calc Close
pclose = 0.0
pclose := is_newbar(pp_res) ? close[1] : pclose[1]

////////////////////////////////
// CALCULATE fibonacci pivots //

vPP = (phigh + plow + pclose) / 3
vR1 = vPP + (phigh - plow) * 0.382
vS1 = vPP - (phigh - plow) * 0.382
vR2 = vPP + (phigh - plow) * 0.618
vS2 = vPP - (phigh - plow) * 0.618
vR3 = vPP + (phigh - plow) * 1.000
vS3 = vPP - (phigh - plow) * 1.000
 
//////////////
// PLOTTING //

bars_sinse = 0
bars_sinse := is_newbar(pp_res) ? 0 : bars_sinse[1] + 1

////////////////////////
// PLOT PIVOTS LEVELS //

vpp_p = line.new(bar_index[bars_sinse], vPP, bar_index, vPP, color=#f57f17, style =  line.style_solid, extend = extend.right)
vs1_p = line.new(bar_index[bars_sinse], vS1, bar_index, vS1, color=#f57f17, style =  line.style_solid, extend = extend.right)
vs2_p = line.new(bar_index[bars_sinse], vS2, bar_index, vS2, color=#f57f17, style =  line.style_solid, extend = extend.right)
vs3_p = line.new(bar_index[bars_sinse], vS3, bar_index, vS3, color=#f57f17, style =  line.style_solid, extend = extend.right)
vr1_p = line.new(bar_index[bars_sinse], vR1, bar_index, vR1, color=#f57f17, style =  line.style_solid, extend = extend.right)
vr2_p = line.new(bar_index[bars_sinse], vR2, bar_index, vR2, color=#f57f17, style =  line.style_solid, extend = extend.right)
vr3_p = line.new(bar_index[bars_sinse], vR3, bar_index, vR3, color=#f57f17, style =  line.style_solid, extend = extend.right)

// delete previous lines in the same period
if (not is_newbar(pp_res))
    line.delete(vpp_p[1])
    line.delete(vs1_p[1])
    line.delete(vs2_p[1]) 
    line.delete(vs3_p[1]) 
    line.delete(vr1_p[1])
    line.delete(vr2_p[1]) 
    line.delete(vr3_p[1])
 
// delete entend for the old lines
if (is_newbar(pp_res))
    line.set_extend(vpp_p[1], extend.none)
    line.set_extend(vs1_p[1], extend.none)
    line.set_extend(vs2_p[1], extend.none) 
    line.set_extend(vs3_p[1], extend.none) 
    line.set_extend(vr1_p[1], extend.none)
    line.set_extend(vr2_p[1], extend.none) 
    line.set_extend(vr3_p[1], extend.none)

// Add labels
if (is_newbar(pp_res)) 
    label_vpp = label.new(bar_index, vPP, text="P",  style= label.style_none)
    label_vs1 = label.new(bar_index, vS1, text="S1", style= label.style_none)
    label_vs2 = label.new(bar_index, vS2, text="S2", style= label.style_none)
    label_vs3 = label.new(bar_index, vS3, text="S3", style= label.style_none)
    label_vr1 = label.new(bar_index, vR1, text="R1", style= label.style_none)
    label_vr2 = label.new(bar_index, vR2, text="R2", style= label.style_none)
    label_vr3 = label.new(bar_index, vR3, text="R3", style= label.style_none)
 
rad14733

rad14733

Active member
VIP
Is that the code for THIS indicator...??? Your link was generic and doesn't point to the actual indicator you are referring to... It appears to be but just want to make sure because people do tend to modify scripts without properly documenting so... I haven't taken the time to compare scripts yet...
 
E

egshih

New member
VIP
@FOTM_8888 Thanks, if you happen to find this, please let me know. Thanks!
 
J

jrob0124

New member
Can anyone please help me turn this TradingView indicator into a TOS indicator? Much appreciated!


Code:
study(title="SQN-ChrisD-Fallible", shorttitle="SQN-ChrisD-Fallible", overlay = false)
Period = input(100, minval=5, title="Period")
close_difference = close/close[1]-1
Stdev = stdev(close_difference,Period)
_sma= sma(close_difference,Period)
SQN=((_sma*sqrt(Period))/Stdev)
c=(SQN < .2 and SQN > -.2)?#FFD700:  (SQN>0.6 and SQN<1.7)?#808000: (SQN>-0.6 and SQN<0.2) ?#FF0000: (SQN>=1.7)?#0000FF:(SQN<-0.6)?#800000: (SQN>.2 and SQN<0.6)? #FFD700FF:gray
plot(SQN, title="SQN", color=c, transp=10,histbase=0,style=area,linewidth=4)
 
BenTen

BenTen

Administrative
Staff
VIP
@jrob0124 Here you go:

Code:
# SQN-ChrisD-Fallible
# Assembled by BenTen at UseThinkScript.com
# Converted from https://www.tradingview.com/script/ZhHf4DFD-SQN-ChrisD-Fallible/

declare lower;

input Period = 100;
def close_difference = close/close[1]-1;
def Stdev = stdev(close_difference,Period);
def underscore_sma = simpleMovingAvg(close_difference,Period);
def SQN=((underscore_sma*sqrt(Period))/Stdev);
plot histogram = SQN;

histogram.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
histogram.AssignValueColor(if (SQN < .2 and SQN > -.2) then color.yellow else if (SQN>0.6 and SQN<1.7) then color.lime else if (SQN>-0.6 and SQN<0.2) then color.red else if (SQN>=1.7) then color.blue else if (SQN<-0.6) then color.dark_red else if (SQN>.2 and SQN<0.6) then color.magenta else color.gray);
 
J

jrob0124

New member
@BenTen,

Here is the code for TradingView traditional pivots. I cannot find any pivots in TOS that map to these. Is it possible to turn these into a TOS indicator as well? Thank you for all your help!

Code:
PP = (HIGHprev + LOWprev + CLOSEprev) / 3
    R1 = PP * 2 - LOWprev
    S1 = PP * 2 - HIGHprev
    R2 = PP + (HIGHprev - LOWprev)
    S2 = PP - (HIGHprev - LOWprev)
    R3 = PP * 2 + (HIGHprev - 2 * LOWprev)
    S3 = PP * 2 - (2 * HIGHprev - LOWprev)
    R4 = PP * 3 + (HIGHprev - 3 * LOWprev)
    S4 = PP * 3 - (3 * HIGHprev - LOWprev)
    R5 = PP * 4 + (HIGHprev - 4 * LOWprev)
    S5 = PP * 4 - (4 * HIGHprev - LOWprev)
 
BenTen

BenTen

Administrative
Staff
VIP
@jrob0124 Here are the built-in pivot indicators in ToS:

 
rad14733

rad14733

Active member
VIP
@jrob0124 Can you provide the entire TradingView script please... There may or may not already be a custom script written fitting the criteria but we can't say without seeing the entire block of code...
 
J

jrob0124

New member
@jrob0124 Can you provide the entire TradingView script please... There may or may not already be a custom script written fitting the criteria but we can't say without seeing the entire block of code...
Thanks for replying @rad14733.

Here is the article I pulled from TradingView describing how they create their pivot points, which includes some of the code I pasted above.

https://www.tradingview.com/support...nts Standard — is a,and resistance (R) levels.

I also found this link, that has some of the code mentioned above, but maybe more complete.

https://getsatisfaction.com/tradingview/topics/traditional_and_classic_pivot_point_formula

Please let me know if this helps and thanks again for your time.
 
B

Beltrame1

New member
VIP
I found this code in Tradingview and it is called Didi Index/Indicator. It seems Didi Aguiar (the Brazilian creator) flattened one of the moving averages (the median one?) and made it the "zero line" if I am not mistaken. I believe the picture above shows it and it would be AWESOME if when they CROSS PERFECTLY to have some sort of alert or ARROW. The original code at the bottom of the link. Could someone recode this for TOS??
He explains in one of his videos that he views the straight line as a fence separating 2 bulls (the other 2 MA`s) and when they run away from each other and there is a perfect cross, price runs big.

https://www.tradingview.com/script/VJgQENze-Didi-Index-Improved-with-QQE-jh/

 
Last edited:
A

amao11

New member
Found this amazing study called "Auto Support" in tradingview from this guy "jmac" and am wondering if someone could make it available for TOS. The script is free. Please and thank you!!

Code:
study("Auto-Support v 0.3", overlay=true)
a = input(title="Sensitivity", type=integer, defval=10, minval=1, maxval=10)
d = input(title="Transparency", type=integer, defval=85, minval=1, maxval=100)
b = #FF0000
c = #0000FF
plot(highest(a*1), title='Resistance 1', color=b, linewidth=2, style=line, transp=d, offset=-9999, trackprice=true)
plot(lowest (a*1), title='Support', color=c, linewidth=2, style=line, transp=d, offset=-9999, trackprice=true)
plot(highest(a*2), title='Resistance', color=b, linewidth=2, style=line, transp=d, offset=-9999, trackprice=true)
plot(lowest (a*2), title='Support', color=c, linewidth=2, style=line, transp=d, offset=-9999, trackprice=true)
plot(highest(a*3), title='Resistance', color=b, linewidth=2, style=line, transp=d, offset=-9999, trackprice=true)
plot(lowest (a*3), title='Support', color=c, linewidth=2, style=line, transp=d, offset=-9999, trackprice=true)
plot(highest(a*4), title='Resistance', color=b, linewidth=2, style=line, transp=d, offset=-9999, trackprice=true)
plot(lowest (a*4), title='Support', color=c, linewidth=2, style=line, transp=d, offset=-9999, trackprice=true)
plot(highest(a*5), title='Resistance', color=b, linewidth=2, style=line, transp=d, offset=-9999, trackprice=true)
plot(lowest (a*5), title='Support', color=c, linewidth=2, style=line, transp=d, offset=-9999, trackprice=true)
plot(highest(a*6), title='Resistance', color=b, linewidth=2, style=line, transp=d, offset=-9999, trackprice=true)
plot(lowest (a*6), title='Support', color=c, linewidth=2, style=line, transp=d, offset=-9999, trackprice=true)
plot(highest(a*7), title='Resistance', color=b, linewidth=2, style=line, transp=d, offset=-9999, trackprice=true)
plot(lowest (a*7), title='Support', color=c, linewidth=2, style=line, transp=d, offset=-9999, trackprice=true)
plot(highest(a*8), title='Resistance', color=b, linewidth=2, style=line, transp=d, offset=-9999, trackprice=true)
plot(lowest (a*8), title='Support', color=c, linewidth=2, style=line, transp=d, offset=-9999, trackprice=true)
plot(highest(a*9), title='Resistance', color=b, linewidth=2, style=line, transp=d, offset=-9999, trackprice=true)
plot(lowest (a*9), title='Support', color=c, linewidth=2, style=line, transp=d, offset=-9999, trackprice=true)
plot(highest(a*10), title='Resistance', color=b, linewidth=2, style=line, transp=d, offset=-9999, trackprice=true)
plot(lowest (a*10), title='Support', color=c, linewidth=2, style=line, transp=d, offset=-9999, trackprice=true)
plot(highest(a*15), title='Resistance', color=b, linewidth=2, style=line, transp=d, offset=-9999, trackprice=true)
plot(lowest (a*15), title='Support', color=c, linewidth=2, style=line, transp=d, offset=-9999, trackprice=true)
plot(highest(a*20), title='Resistance', color=b, linewidth=2, style=line, transp=d, offset=-9999, trackprice=true)
plot(lowest (a*20), title='Support', color=c, linewidth=2, style=line, transp=d, offset=-9999, trackprice=true)
plot(highest(a*25), title='Resistance', color=b, linewidth=2, style=line, transp=d, offset=-9999, trackprice=true)
plot(lowest (a*25), title='Support', color=c, linewidth=2, style=line, transp=d, offset=-9999, trackprice=true)
plot(highest(a*30), title='Resistance', color=b, linewidth=2, style=line, transp=d, offset=-9999, trackprice=true)
plot(lowest (a*30), title='Support', color=c, linewidth=2, style=line, transp=d, offset=-9999, trackprice=true)
plot(highest(a*35), title='Resistance', color=b, linewidth=2, style=line, transp=d, offset=-9999, trackprice=true)
plot(lowest (a*35), title='Support', color=c, linewidth=2, style=line, transp=d, offset=-9999, trackprice=true)
plot(highest(a*40), title='Resistance', color=b, linewidth=2, style=line, transp=d, offset=-9999, trackprice=true)
plot(lowest (a*40), title='Support', color=c, linewidth=2, style=line, transp=d, offset=-9999, trackprice=true)
plot(highest(a*45), title='Resistance', color=b, linewidth=2, style=line, transp=d, offset=-9999, trackprice=true)
plot(lowest (a*45), title='Support', color=c, linewidth=2, style=line, transp=d, offset=-9999, trackprice=true)
plot(highest(a*50), title='Resistance', color=b, linewidth=2, style=line, transp=d, offset=-9999, trackprice=true)
plot(lowest (a*50), title='Support', color=c, linewidth=2, style=line, transp=d, offset=-9999, trackprice=true)
plot(highest(a*75), title='Resistance', color=b, linewidth=2, style=line, transp=d, offset=-9999, trackprice=true)
plot(lowest (a*75), title='Support', color=c, linewidth=2, style=line, transp=d, offset=-9999, trackprice=true)
plot(highest(a*100), title='Resistance', color=b, linewidth=2, style=line, transp=d, offset=-9999, trackprice=true)
plot(lowest (a*100), title='Support', color=c, linewidth=2, style=line, transp=d, offset=-9999, trackprice=true)
plot(highest(a*150), title='Resistance', color=b, linewidth=2, style=line, transp=d, offset=-9999, trackprice=true)
plot(lowest (a*150), title='Support', color=c, linewidth=2, style=line, transp=d, offset=-9999, trackprice=true)
plot(highest(a*200), title='Resistance', color=b, linewidth=2, style=line, transp=d, offset=-9999, trackprice=true)
plot(lowest (a*200), title='Support', color=c, linewidth=2, style=line, transp=d, offset=-9999, trackprice=true)
plot(highest(a*250), title='Resistance', color=b, linewidth=2, style=line, transp=d, offset=-9999, trackprice=true)
plot(lowest (a*250), title='Support', color=c, linewidth=2, style=line, transp=d, offset=-9999, trackprice=true)
plot(highest(a*300), title='Resistance', color=b, linewidth=2, style=line, transp=d, offset=-9999, trackprice=true)
plot(lowest (a*300), title='Support', color=c, linewidth=2, style=line, transp=d, offset=-9999, trackprice=true)
plot(highest(a*350), title='Resistance', color=b, linewidth=2, style=line, transp=d, offset=-9999, trackprice=true)
plot(lowest (a*350), title='Support', color=c, linewidth=2, style=line, transp=d, offset=-9999, trackprice=true)
plot(highest(a*400), title='Resistance', color=b, linewidth=2, style=line, transp=d, offset=-9999, trackprice=true)
plot(lowest (a*400), title='Support', color=c, linewidth=2, style=line, transp=d, offset=-9999, trackprice=true)
plot(highest(a*450), title='Resistance', color=b, linewidth=2, style=line, transp=d, offset=-9999, trackprice=true)
plot(lowest (a*450), title='Support', color=c, linewidth=2, style=line, transp=d, offset=-9999, trackprice=true)
plot(highest(a*500), title='Resistance', color=b, linewidth=2, style=line, transp=d, offset=-9999, trackprice=true)
plot(lowest (a*500), title='Support', color=c, linewidth=2, style=line, transp=d, offset=-9999, trackprice=true)
 
J007RMC

J007RMC

Active member
2019 Donor
VIP
I don't know if we have anything similar to the below code?



Code:
//
// @author LazyBear
//
study("CCI coded OBV", shorttitle="CCIOBV_LB")
src = close
length = input(20, minval=1, title="CCI Length")
threshold=input(0, title="CCI threshold for OBV coding")
lengthema=input(13, title="EMA length")
obv(src) =>
    cum(change(src) > 0 ? volume : change(src) < 0 ? -volume : 0*volume)
  
o=obv(src)
c=cci(src, length)
plot(o, color=c>=threshold?green:red, title="OBV_CCI coded", linewidth=2)
plot(ema(o,lengthema), color=orange, linewidth=2)
 

Similar threads

Top