Unrequited Conversion Requests To ThinkOrSwim

vandell001

New member
2019 Donor
Hey Gang, There is an interesting MT4 indicator out there called 3 level ZZ semafor. There is one site that has it converted to TOS, they call it 3 Level Zigzag. The site patternsmart.com requires a VIP sign up (one month trial $30.00) and then an additional $99 for the indicator. I have the MT4 code. Is there anyone who can/would be interested in converting it.
 

irishgold

Member
@MerryDay thanks for the input, I have most of the indicators in NT but need to understand the strategy using them to convert to an NT strategy. Also your recent post of the 3 Mobius indicators might also be some good food for thought in forming a strategy. Thanks. I'm working with a SSL strategy that has promise right now.
This by the way is not the original thread that I commented on for @Rraannddyy . It seems if you mention NT the postings seem to disappear. But I believe a good interchange of ideas even though this is a TOS focused site can lead to effective trading. Which in the end everyone here is trying to achieve. TOS has no ability to program trades. And the backtest of TOS is a joke and unrealistic.
 

MerryDay

Administrative
Staff member
Staff
VIP
@irishgold No postings disappear. The NT conversion requests that are not met end up here in the graveyard. Substantive discussions of trading and backtesting on Tradestation, Ninja Trader, and there was another platform recently remain as their own threads in the playground forum.

Seeing that ToS is based on a single-threaded application, I am assuming that it is not long for this world in its current form. We have no idea what Scwab will eventually do with this platform, so these are important discussions and are welcomed.

I have been hedging my bet and programming over on TradeStation during the summer doldrums. We have several threads ongoing over there about the various platforms. But I haven't seen any robust conversations on this forum.
 
Last edited:

JMath3

New member
Code:
#HALF GAP (DAILY)

def aggregationPeriod = AggregationPeriod.DAY;
def prevPrice = open(period = aggregationPeriod)[-1];
def price = open(period = aggregationPeriod);
def DailyOpen = price;
def PrevClose = close(period = aggregationPeriod)[1];
plot AvgPrevcloseDailyopen = (DailyOpen + Prevclose) / 2;
Code:
#MidPoint

input aggregationPeriod = AggregationPeriod.Day;
def Low = low(period = aggregationPeriod);
def High = high(period = aggregationPeriod);

plot DayMidPoint = (Low[1] + High[1]) / 2;
def bullishmidpoint = open > daymidpoint;
def bearishmidpoint = open < daymidpoint;


Could someone help me convert this to Trading view script? All in one Script? I would appreciate it.
 

TieJiaoJie

New member
i just made this upper chart study for someone. will post it today
ref this
https://www.tradingview.com/script/uYiilgYb-TW-Golden-Indicators/

Ruby:
# golden_01b

# https://www.tradingview.com/script/uYiilgYb-TW-Golden-Indicators/
# convert tradingview study
#// TW Golden Indicators Package
#// This package features BB (with 20 ma), inside bar color change (white), outside bar color change (black), and holy grail 2-candle pattern background higlhlight (yellow)

def lastbar = !isnan(close[0]) and isnan(close[-1]);
def src = close;
input length = 20;
input mult = 2.0;
def mult2 = if mult > 50 then 50 else if mult < 0.001 then 0.001 else mult;

# https://tlc.thinkorswim.com/center/reference/thinkScript/Constants/AverageType
#  EXPONENTIAL, HULL, SIMPLE, WEIGHTED, WILDERS
input avg1_type =  AverageType.simple;
def basis = MovingAverage(avg1_type, src, length);
def dev = mult2 * StDev( src , length );
def upper = basis + dev;
def lower = basis - dev;

# horz lines
plot basisLine = highestAll(if isNaN(close[-1]) then basis else Double.NaN);
basisline.SetDefaultColor(Color.red);
basisline.SetStyle(Curve.SHORT_DASH);
plot upperLine = highestAll(if isNaN(close[-1]) then upper else Double.NaN);
upperline.SetDefaultColor(Color.magenta);
plot lowerLine = highestAll(if isNaN(close[-1]) then lower else Double.NaN);
lowerline.SetDefaultColor(Color.magenta);

# inside and outside bars
def inBar = low > low[1] and high < high[1];
def outBar = low < low[1] and high > high[1];
def holyGrail = low[1] < low[2] and high[1] > high[2] and low > low[1] and high < high[1];

input bubble_ht_offset = 0.0006;
addchartbubble(inbar, (high * (1 + bubble_ht_offset)), "IB", color.yellow, yes);
addchartbubble(outbar, (low * (1 - bubble_ht_offset)), "OB", color.blue, no);

def off = 1;
addchartbubble(lastbar[off] and holyGrail[off] and inbar[off], close, "Holy Grail" + "\nInbar", color.yellow, yes);
addchartbubble(lastbar[off] and holyGrail[off] and outbar[off], close, "Holy Grail" + "\nOutbar", color.yellow, yes);

plot hg2 = holygrail;
hg2.SetPaintingStrategy(PaintingStrategy.BOOLEAN_wedge_up);
hg2.SetDefaultColor(Color.white);
hg2.setlineweight(3);
#
Hi,

Can I have please the pine script for Outside followed Inside Bar for Tradingview? It would be great to add that to the existing TW Golden Indicator that you have posted. Thank you very much.
 

mnzzz

New member
VIX Roll Yield Indicator
This indicator calculates the VIX roll yield. It's a useful metric when looking to trade vol ETPs. Can someone help convert this indicator to ThinkorSwim?
https://www.tradingview.com/script/RwmvhT5T-vix-roll-yield/
Shows the roll yield of the VX futures , which is the ratio of a continuously weighted average of the front two months to the VIX . The VX ( VIX futures ) contract expires on the third Tuesday of each month. On the next trading day, the front month will have full weighting, and the second month will have no weight. On the expiration day, the back month will have full weighting and the front month will have no weight. In between, the weight gradually shifts.

This weighted average is similar to the SPVIXSTR index that UVXY and several other funds track. When the average is below the VIX , the indicator is negative, and the front month contract will tend to gain value relatively more rapidly than the back month as it converges upward to the VIX spot price. Because funds whose NAV is tied up in VX contracts continuously roll from the (typically cheaper) front month to the back, in situations where the front month is more expensive than usual--or even more expensive than the back month--these products may have a "tailwind". In this case, they are selling expensive front month contracts to purchase cheap back month contracts.

Ordinarily, VIX funds have a "headwind." The roll yield is positive, the front month is cheap, and the back month is expensive. Day by day the funds sell cheap front month contracts and buy expensive back month contracts, which, in turn and over time, become the front month and converge with the VIX , losing value rapidly. This is a brief explanation about the decay of these products.
wMkjc0A.png

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

//@version=4
study("vix_roll_yield", overlay = false)

periods = input(title = "periods", type = input.integer, defval = 252)

vix = security("VIX", "D", close)
vx1 = security("VX1!", "D", close)
vx2 = security("VX2!", "D", close)

one_day = 24 * 60 * 60 * 1000
month_start = time - dayofmonth * one_day

var int this_exp = na
for i = 0 to 8
    d = month_start + i * one_day
    if dayofweek(d) == 3
        this_exp := d + 14 * one_day
        break
       
var int next_exp = na
for i = 1 to 39
    d = time + i * one_day
    if month(d) != month and dayofweek(d) == 3
        next_exp := d + 14 * one_day
        break

var int period = na
var int dte = na
if time <= this_exp
    dte := (this_exp - time) / one_day
    period := (this_exp - this_exp[32]) / one_day
else
    dte := (next_exp - time) / one_day
    period := (next_exp - this_exp) / one_day
   
vx30 = (vx1 * dte / period)  + (vx2 * (1 - dte / period))
ry = (vx30 - vix) / vix
rank = percentrank(ry, periods)

if barstate.islast
    label.new(bar_index + 10, ry, style = label.style_none, text = tostring(rank, "#.##") + "%")


plot(ry, style = plot.style_histogram)
plot(0, color = color.red)
 
Last edited by a moderator:

kwakuamuti

New member
Hey all!

New to posting in the community but have used some of the custom indicators many of you have posted here! Glad to be a part of the community now.

I use Tradingview and have an invite-only script that I use religiously. It has a really cool feature that when it indicates BUY or SELL (I think that this is using a supertrend indicator), it does a nifty job of giving you a suggested ENTRY, STOP LOSS, and recommended TAKE PROFIT LEVELS (T1, T2, T3, T4). It also repaints whenever the trend changes.

I've been trying to find a script that recreates this in ThinkorSwim but have not located it. I've attached a screenshot to show what the levels look like.

Is this something that can be recreated in ThinkorSwim?

Thanks so much in advance for anyone who can answer this!

Screen-Shot-2021-10-10-at-12-19-10-PM.png
 
Last edited by a moderator:

Cmeeker778

New member
Divergence for Many Indicators v4
Could anyone convert this from Pine (TradingView) to TOS?
t6fapmy.png

https://www.tradingview.com/script/n8AGnIZd-Divergence-for-Many-Indicators-v4/
How it works?
  • On each candle it checks divergences between current and any of last 16 Pivot Points for the indicators.
  • it search divergence on choisen indicators => RSI , MACD , MACD Histogram, Stochastic , CCI , Momentum, OBV, VWMACD, CMFand any External Indicator!
  • it checks following divergences for 16 pivot points that is in last 100 bars for each Indicator.
--> Regular Positive Digergences
--> Regular Negative Digergences
--> Hidden Positive Digergences
--> Hidden Negative Digergences
  • for positive divergences first it checks if closing price is higher than last closing price and indicator value is higher than perious value, then start searching divergence
  • for negative divergences first it checks if closing price is lower than last closing price and indicator value is lower than perious value, then start searching divergence


Some Options:

Pivot Period: you set Pivot Period as you wish. you can see Pivot Points using "Show Pivot Points" option
Source for Pivot Points: you can use Close or High/Low as source
Divergence Type: you can choose Divergence type to be shown => "Regular", "Hidden", "Regular/Hidden"
Show Indicator Names: you have different options to show indicator names => "Full", "First Letter", "Don't Show"
Show Divergence Number: option to see number of indicators which has Divergence
Show Only Last Divergence: if you enable this option then it shows only last Positive and Negative Divergences
you can include any External Indicator to see if there is divergence
  • enable "Check External Indicator"
  • and then choose External indicator name in the list, "External Indicator"
  • External indicator name is shown as Extrn
  • related external indicator must be added before enabling this option
Ruby:
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © LonesomeTheBlue

//@version=4
study("Divergence for Many Indicators v4", overlay = true, max_bars_back = 1000, max_lines_count = 400, max_labels_count = 400)
prd = input(defval = 5, title = "Pivot Period", minval = 1, maxval = 50)
source = input(defval = "Close", title = "Source for Pivot Points", options = ["Close", "High/Low"])
searchdiv = input(defval = "Regular", title = "Divergence Type", options = ["Regular", "Hidden", "Regular/Hidden"])
showindis = input(defval = "Full", title = "Show Indicator Names", options = ["Full", "First Letter", "Don't Show"])
showlimit = input(1, title="Minimum Number of Divergence", minval = 1, maxval = 11)
maxpp = input(defval = 10, title = "Maximum Pivot Points to Check", minval = 1, maxval = 20)
maxbars = input(defval = 100, title = "Maximum Bars to Check", minval = 30, maxval = 200)
shownum = input(defval = true, title = "Show Divergence Number")
showlast = input(defval = false, title = "Show Only Last Divergence")
dontconfirm = input(defval = false, title = "Don't Wait for Confirmation")
showlines = input(defval = true, title = "Show Divergence Lines")
showpivot = input(defval = false, title = "Show Pivot Points")
calcmacd = input(defval = true, title = "MACD")
calcmacda = input(defval = true, title = "MACD Histogram")
calcrsi = input(defval = true, title = "RSI")
calcstoc = input(defval = true, title = "Stochastic")
calccci = input(defval = true, title = "CCI")
calcmom = input(defval = true, title = "Momentum")
calcobv = input(defval = true, title = "OBV")
calcvwmacd = input(true, title = "VWmacd")
calccmf = input(true, title = "Chaikin Money Flow")
calcmfi = input(true, title = "Money Flow Index")
calcext = input(false, title = "Check External Indicator")
externalindi = input(defval = close, title = "External Indicator")
pos_reg_div_col = input(defval = color.yellow, title = "Positive Regular Divergence")
neg_reg_div_col = input(defval = color.navy, title = "Negative Regular Divergence")
pos_hid_div_col = input(defval = color.lime, title = "Positive Hidden Divergence")
neg_hid_div_col = input(defval = color.red, title = "Negative Hidden Divergence")
pos_div_text_col = input(defval = color.black, title = "Positive Divergence Text Color")
neg_div_text_col = input(defval = color.white, title = "Negative Divergence Text Color")
reg_div_l_style_ = input(defval = "Solid", title = "Regular Divergence Line Style", options = ["Solid", "Dashed", "Dotted"])
hid_div_l_style_ = input(defval = "Dashed", title = "Hdden Divergence Line Style", options = ["Solid", "Dashed", "Dotted"])
reg_div_l_width = input(defval = 2, title = "Regular Divergence Line Width", minval = 1, maxval = 5)
hid_div_l_width = input(defval = 1, title = "Hidden Divergence Line Width", minval = 1, maxval = 5)
showmas = input(defval = false, title = "Show MAs 50 & 200", inline = "ma12")
cma1col = input(defval = color.lime, title = "", inline = "ma12")
cma2col = input(defval = color.red, title = "", inline = "ma12")

plot(showmas ? sma(close, 50) : na, color = showmas ? cma1col : na)
plot(showmas ? sma(close, 200) : na, color = showmas ? cma2col: na)

// set line styles
var reg_div_l_style = reg_div_l_style_ == "Solid" ? line.style_solid :
                       reg_div_l_style_ == "Dashed" ? line.style_dashed :
                       line.style_dotted
var hid_div_l_style = hid_div_l_style_ == "Solid" ? line.style_solid :
                       hid_div_l_style_ == "Dashed" ? line.style_dashed :
                       line.style_dotted


// get indicators
rsi = rsi(close, 14) // RSI
[macd, signal, deltamacd] = macd(close, 12, 26, 9) // MACD
moment = mom(close, 10) // Momentum
cci = cci(close, 10) // CCI
Obv = obv // OBV
stk = sma(stoch(close, high, low, 14), 3) // Stoch
maFast = vwma(close, 12), maSlow = vwma(close, 26), vwmacd = maFast - maSlow // volume weighted macd
Cmfm = ((close-low) - (high-close)) / (high - low), Cmfv = Cmfm * volume, cmf = sma(Cmfv, 21) / sma(volume,21) // Chaikin money flow
Mfi = mfi(close, 14) // Moneyt Flow Index

// keep indicators names and colors in arrays
var indicators_name = array.new_string(11)
var div_colors = array.new_color(4)
if barstate.isfirst
    // names
    array.set(indicators_name, 0, showindis == "Full" ? "MACD" : "M")
    array.set(indicators_name, 1, showindis == "Full" ? "Hist" : "H")
    array.set(indicators_name, 2, showindis == "Full" ? "RSI" : "E")
    array.set(indicators_name, 3, showindis == "Full" ? "Stoch" : "S")
    array.set(indicators_name, 4, showindis == "Full" ? "CCI" : "C")
    array.set(indicators_name, 5, showindis == "Full" ? "MOM" : "M")
    array.set(indicators_name, 6, showindis == "Full" ? "OBV" : "O")
    array.set(indicators_name, 7, showindis == "Full" ? "VWMACD" : "V")
    array.set(indicators_name, 8, showindis == "Full" ? "CMF" : "C")
    array.set(indicators_name, 9, showindis == "Full" ? "MFI" : "M")
    array.set(indicators_name,10, showindis == "Full" ? "Extrn" : "X")
    //colors
    array.set(div_colors, 0, pos_reg_div_col)
    array.set(div_colors, 1, neg_reg_div_col)
    array.set(div_colors, 2, pos_hid_div_col)
    array.set(div_colors, 3, neg_hid_div_col)

// Check if we get new Pivot High Or Pivot Low
float ph = pivothigh((source == "Close" ? close : high), prd, prd)
float pl = pivotlow((source == "Close" ? close : low), prd, prd)
plotshape(ph and showpivot, text = "H",  style = shape.labeldown, color = color.new(color.white, 100), textcolor = color.red, location = location.abovebar, offset = -prd)
plotshape(pl and showpivot, text = "L",  style = shape.labelup, color = color.new(color.white, 100), textcolor = color.lime, location = location.belowbar, offset = -prd)

// keep values and positions of Pivot Highs/Lows in the arrays
var int maxarraysize = 20
var ph_positions = array.new_int(maxarraysize, 0)
var pl_positions = array.new_int(maxarraysize, 0)
var ph_vals = array.new_float(maxarraysize, 0.)
var pl_vals = array.new_float(maxarraysize, 0.)

// add PHs to the array
if ph
    array.unshift(ph_positions, bar_index)
    array.unshift(ph_vals, ph)
    if array.size(ph_positions) > maxarraysize
        array.pop(ph_positions)
        array.pop(ph_vals)

// add PLs to the array
if pl
    array.unshift(pl_positions, bar_index)
    array.unshift(pl_vals, pl)
    if array.size(pl_positions) > maxarraysize
        array.pop(pl_positions)
        array.pop(pl_vals)

// functions to check Regular Divergences and Hidden Divergences

// function to check positive regular or negative hidden divergence
// cond == 1 => positive_regular, cond == 2=> negative_hidden
positive_regular_positive_hidden_divergence(src, cond)=>
    divlen = 0
    prsc = source == "Close" ? close : low
    // if indicators higher than last value and close price is higher than las close
    if dontconfirm or src > src[1] or close > close[1]
        startpoint = dontconfirm ? 0 : 1 // don't check last candle
        // we search last 15 PPs
        for x = 0 to maxpp - 1
            len = bar_index - array.get(pl_positions, x) + prd
            // if we reach non valued array element or arrived 101. or previous bars then we don't search more
            if array.get(pl_positions, x) == 0 or len > maxbars
                break
            if len > 5 and
               ((cond == 1 and src[startpoint] > src[len] and prsc[startpoint] < nz(array.get(pl_vals, x))) or
               (cond == 2 and src[startpoint] < src[len] and prsc[startpoint] > nz(array.get(pl_vals, x))))
                slope1 = (src[startpoint] - src[len]) / (len - startpoint)
                virtual_line1 = src[startpoint] - slope1
                slope2 = (close[startpoint] - close[len]) / (len - startpoint)
                virtual_line2 = close[startpoint] - slope2
                arrived = true
                for y = 1 + startpoint to len - 1
                    if src[y] < virtual_line1 or nz(close[y]) < virtual_line2
                        arrived := false
                        break
                    virtual_line1 := virtual_line1 - slope1
                    virtual_line2 := virtual_line2 - slope2
                
                if arrived
                    divlen := len
                    break
    divlen

// function to check negative regular or positive hidden divergence
// cond == 1 => negative_regular, cond == 2=> positive_hidden
negative_regular_negative_hidden_divergence(src, cond)=>
    divlen = 0
    prsc = source == "Close" ? close : high
    // if indicators higher than last value and close price is higher than las close
    if dontconfirm or src < src[1] or close < close[1]
        startpoint = dontconfirm ? 0 : 1 // don't check last candle
        // we search last 15 PPs
        for x = 0 to maxpp - 1
            len = bar_index - array.get(ph_positions, x) + prd
            // if we reach non valued array element or arrived 101. or previous bars then we don't search more
            if array.get(ph_positions, x) == 0 or len > maxbars
                break
            if len > 5 and
               ((cond == 1 and src[startpoint] < src[len] and prsc[startpoint] > nz(array.get(ph_vals, x))) or
               (cond == 2 and src[startpoint] > src[len] and prsc[startpoint] < nz(array.get(ph_vals, x))))
                slope1 = (src[startpoint] - src[len]) / (len - startpoint)
                virtual_line1 = src[startpoint] - slope1
                slope2 = (close[startpoint] - nz(close[len])) / (len - startpoint)
                virtual_line2 = close[startpoint] - slope2
                arrived = true
                for y = 1 + startpoint to len - 1
                    if src[y] > virtual_line1 or nz(close[y]) > virtual_line2
                        arrived := false
                        break
                    virtual_line1 := virtual_line1 - slope1
                    virtual_line2 := virtual_line2 - slope2
                
                if arrived
                    divlen := len
                    break
    divlen

// calculate 4 types of divergence if enabled in the options and return divergences in an array
calculate_divs(cond, indicator)=>
    divs = array.new_int(4, 0)
    array.set(divs, 0, cond and (searchdiv == "Regular" or searchdiv == "Regular/Hidden") ? positive_regular_positive_hidden_divergence(indicator, 1) : 0)
    array.set(divs, 1, cond and (searchdiv == "Regular" or searchdiv == "Regular/Hidden") ? negative_regular_negative_hidden_divergence(indicator, 1) : 0)
    array.set(divs, 2, cond and (searchdiv == "Hidden" or searchdiv == "Regular/Hidden")  ? positive_regular_positive_hidden_divergence(indicator, 2) : 0)
    array.set(divs, 3, cond and (searchdiv == "Hidden" or searchdiv == "Regular/Hidden")  ? negative_regular_negative_hidden_divergence(indicator, 2) : 0)
    divs

// array to keep all divergences
var all_divergences = array.new_int(44) // 11 indicators * 4 divergence = 44 elements
// set related array elements
array_set_divs(div_pointer, index)=>
    for x = 0 to 3
        array.set(all_divergences, index * 4 + x, array.get(div_pointer, x))

// set divergences array
array_set_divs(calculate_divs(calcmacd, macd), 0)
array_set_divs(calculate_divs(calcmacda, deltamacd), 1)
array_set_divs(calculate_divs(calcrsi, rsi), 2)
array_set_divs(calculate_divs(calcstoc, stk), 3)
array_set_divs(calculate_divs(calccci, cci), 4)
array_set_divs(calculate_divs(calcmom, moment), 5)
array_set_divs(calculate_divs(calcobv, Obv), 6)
array_set_divs(calculate_divs(calcvwmacd, vwmacd), 7)
array_set_divs(calculate_divs(calccmf, cmf), 8)
array_set_divs(calculate_divs(calcmfi, Mfi), 9)
array_set_divs(calculate_divs(calcext, externalindi), 10)

// check minimum number of divergence, if less than showlimit then delete all divergence
total_div = 0
for x = 0 to array.size(all_divergences) - 1
    total_div := total_div + round(sign(array.get(all_divergences, x)))

if total_div < showlimit
    array.fill(all_divergences, 0)

// keep line in an array
var pos_div_lines = array.new_line(0)
var neg_div_lines = array.new_line(0)
var pos_div_labels = array.new_label(0)
var neg_div_labels = array.new_label(0)

// remove old lines and labels if showlast option is enabled
delete_old_pos_div_lines()=>
    if array.size(pos_div_lines) > 0   
        for j = 0 to array.size(pos_div_lines) - 1
            line.delete(array.get(pos_div_lines, j))
        array.clear(pos_div_lines)

delete_old_neg_div_lines()=>
    if array.size(neg_div_lines) > 0   
        for j = 0 to array.size(neg_div_lines) - 1
            line.delete(array.get(neg_div_lines, j))
        array.clear(neg_div_lines)

delete_old_pos_div_labels()=>
    if array.size(pos_div_labels) > 0
        for j = 0 to array.size(pos_div_labels) - 1
            label.delete(array.get(pos_div_labels, j))
        array.clear(pos_div_labels)

delete_old_neg_div_labels()=>
    if array.size(neg_div_labels) > 0   
        for j = 0 to array.size(neg_div_labels) - 1
            label.delete(array.get(neg_div_labels, j))
        array.clear(neg_div_labels)

// delete last creted lines and labels until we met new PH/PV
delete_last_pos_div_lines_label(n)=>
    if n > 0 and array.size(pos_div_lines) >= n   
        asz = array.size(pos_div_lines)
        for j = 1 to n
            line.delete(array.get(pos_div_lines, asz - j))
            array.pop(pos_div_lines)
        if array.size(pos_div_labels) > 0 
            label.delete(array.get(pos_div_labels, array.size(pos_div_labels) - 1))
            array.pop(pos_div_labels)

delete_last_neg_div_lines_label(n)=>
    if n > 0 and array.size(neg_div_lines) >= n   
        asz = array.size(neg_div_lines)
        for j = 1 to n
            line.delete(array.get(neg_div_lines, asz - j))
            array.pop(neg_div_lines)
        if array.size(neg_div_labels) > 0 
            label.delete(array.get(neg_div_labels, array.size(neg_div_labels) - 1))
            array.pop(neg_div_labels)
            
// variables for Alerts
pos_reg_div_detected = false
neg_reg_div_detected = false
pos_hid_div_detected = false
neg_hid_div_detected = false

// to remove lines/labels until we met new // PH/PL
var last_pos_div_lines = 0
var last_neg_div_lines = 0
var remove_last_pos_divs = false
var remove_last_neg_divs = false
if pl
    remove_last_pos_divs := false
    last_pos_div_lines := 0
if ph
    remove_last_neg_divs := false
    last_neg_div_lines := 0

// draw divergences lines and labels
divergence_text_top = ""
divergence_text_bottom = ""
distances = array.new_int(0)
dnumdiv_top = 0
dnumdiv_bottom = 0
top_label_col = color.white
bottom_label_col = color.white
old_pos_divs_can_be_removed = true
old_neg_divs_can_be_removed = true
startpoint = dontconfirm ? 0 : 1 // used for don't confirm option

for x = 0 to 10
    div_type = -1
    for y = 0 to 3
        if array.get(all_divergences, x * 4 + y) > 0 // any divergence?
            div_type := y
            if (y % 2) == 1
                dnumdiv_top := dnumdiv_top + 1
                top_label_col := array.get(div_colors, y)
            if (y % 2) == 0
                dnumdiv_bottom := dnumdiv_bottom + 1
                bottom_label_col := array.get(div_colors, y)
            if not array.includes(distances, array.get(all_divergences, x * 4 + y))  // line not exist ?
                array.push(distances, array.get(all_divergences, x * 4 + y))
                new_line = showlines ? line.new(x1 = bar_index - array.get(all_divergences, x * 4 + y),
                          y1 = (source == "Close" ? close[array.get(all_divergences, x * 4 + y)] :
                                           (y % 2) == 0 ? low[array.get(all_divergences, x * 4 + y)] :
                                                          high[array.get(all_divergences, x * 4 + y)]),
                          x2 = bar_index - startpoint,
                          y2 = (source == "Close" ? close[startpoint] :
                                           (y % 2) == 0 ? low[startpoint] :
                                                          high[startpoint]),
                          color = array.get(div_colors, y),
                          style = y < 2 ? reg_div_l_style : hid_div_l_style,
                          width = y < 2 ? reg_div_l_width : hid_div_l_width
                          )
                          : na
                if (y % 2) == 0
                    if old_pos_divs_can_be_removed
                        old_pos_divs_can_be_removed := false
                        if not showlast and remove_last_pos_divs
                            delete_last_pos_div_lines_label(last_pos_div_lines)
                            last_pos_div_lines := 0
                        if showlast
                            delete_old_pos_div_lines()
                    array.push(pos_div_lines, new_line)
                    last_pos_div_lines := last_pos_div_lines + 1
                    remove_last_pos_divs := true
                    
                if (y % 2) == 1
                    if old_neg_divs_can_be_removed
                        old_neg_divs_can_be_removed := false
                        if not showlast and remove_last_neg_divs
                            delete_last_neg_div_lines_label(last_neg_div_lines)
                            last_neg_div_lines := 0
                        if showlast
                            delete_old_neg_div_lines()
                    array.push(neg_div_lines, new_line)
                    last_neg_div_lines := last_neg_div_lines + 1
                    remove_last_neg_divs := true
                    
            // set variables for alerts
            if y == 0
                pos_reg_div_detected := true
            if y == 1
                neg_reg_div_detected := true
            if y == 2
                pos_hid_div_detected := true
            if y == 3
                neg_hid_div_detected := true
    // get text for labels
    if div_type >= 0
        divergence_text_top    := divergence_text_top    + ((div_type % 2) == 1 ? (showindis != "Don't Show" ? array.get(indicators_name, x) + "\n" : "") : "")
        divergence_text_bottom := divergence_text_bottom + ((div_type % 2) == 0 ? (showindis != "Don't Show" ? array.get(indicators_name, x) + "\n" : "") : "")


// draw labels
if showindis != "Don't Show" or shownum
    if shownum and dnumdiv_top > 0
        divergence_text_top := divergence_text_top + tostring(dnumdiv_top)
    if shownum and dnumdiv_bottom > 0
        divergence_text_bottom := divergence_text_bottom + tostring(dnumdiv_bottom)
    if divergence_text_top != ""
        if showlast
            delete_old_neg_div_labels()
        array.push(neg_div_labels,
                      label.new( x = bar_index,
                                 y = max(high, high[1]),
                                 text = divergence_text_top,
                                 color = top_label_col,
                                 textcolor = neg_div_text_col,
                                 style = label.style_label_down
                                 ))
                                
    if divergence_text_bottom != ""
        if showlast
            delete_old_pos_div_labels()
        array.push(pos_div_labels,
                      label.new( x = bar_index,
                                 y = min(low, low[1]),
                                 text = divergence_text_bottom,
                                 color = bottom_label_col,
                                 textcolor = pos_div_text_col,
                                 style = label.style_label_up
                                 ))
                                
    
alertcondition(pos_reg_div_detected, title='Positive Regular Divergence Detected', message='Positive Regular Divergence Detected')
alertcondition(neg_reg_div_detected, title='Negative Regular Divergence Detected', message='Negative Regular Divergence Detected')
alertcondition(pos_hid_div_detected, title='Positive Hidden Divergence Detected', message='Positive Hidden Divergence Detected')
alertcondition(neg_hid_div_detected, title='Negative Hidden Divergence Detected', message='Negative Hidden Divergence Detected')

alertcondition(pos_reg_div_detected or pos_hid_div_detected, title='Positive Divergence Detected', message='Positive Divergence Detected')
alertcondition(neg_reg_div_detected or neg_hid_div_detected, title='Negative Divergence Detected', message='Negative Divergence Detected')
 
Last edited by a moderator:

QUIKTDR1

Member
VIP
Is there a ThinkScript version of Trading Views RSI Divergence Indicator strategy? https://www.tradingview.com/script/qSLcZSyw-RSI-Divergence-Indicator-strategy/
Code:
/@version=4
//study(title="Divergence Indicator", format=format.price)
//GOOGL setting 5 , close, 3 , 1 profitLevel at 75 shows win rate 87.21 % profit factor 7.059
//GOOGL setting 8 , close, 3 , 1 profitLevel at 80 shows win rate 86.57 % profit factor 18.96
//SPY setting 5, close , 3, 3 profitLevel at 70 , shows win rate 80.34% profit factor 2.348
strategy(title="RSI Divergence Indicator", overlay=false,pyramiding=2, default_qty_value=2, default_qty_type=strategy.fixed, initial_capital=10000, currency=currency.USD)

len = input(title="RSI Period", minval=1, defval=9)
src = input(title="RSI Source", defval=close)
lbR = input(title="Pivot Lookback Right", defval=3)
lbL = input(title="Pivot Lookback Left", defval=1)
takeProfitRSILevel = input(title="Take Profit at RSI Level", minval=70, defval=80)

rangeUpper = input(title="Max of Lookback Range", defval=60)
rangeLower = input(title="Min of Lookback Range", defval=5)
plotBull = input(title="Plot Bullish", defval=true)
plotHiddenBull = input(title="Plot Hidden Bullish", defval=true)
plotBear = input(title="Plot Bearish", defval=true)
plotHiddenBear = input(title="Plot Hidden Bearish", defval=false)

//useTrailStopLoss = input(false, title="Use Trailing Stop Loss")

sl_type = input("NONE", title="Trailing StopLoss Type", options=['ATR','PERC', 'NONE'])

stopLoss = input(title="Stop Loss%", defval=5, minval=1)

atrLength=input(14, title="ATR Length (for Trailing stop loss)")
atrMultiplier=input(3.5, title="ATR Multiplier (for Trailing stop loss)")


bearColor = color.purple
bullColor = color.green
hiddenBullColor = color.new(color.green, 80)
hiddenBearColor = color.new(color.red, 80)
textColor = color.white
noneColor = color.new(color.white, 100)

osc = rsi(src, len)

plot(osc, title="RSI", linewidth=2, color=#8D1699)
hline(50, title="Middle Line", linestyle=hline.style_dotted)
obLevel = hline(70, title="Overbought", linestyle=hline.style_dotted)
osLevel = hline(30, title="Oversold", linestyle=hline.style_dotted)
fill(obLevel, osLevel, title="Background", color=#9915FF, transp=90)

plFound = na(pivotlow(osc, lbL, lbR)) ? false : true
phFound = na(pivothigh(osc, lbL, lbR)) ? false : true

_inRange(cond) =>
bars = barssince(cond == true)
rangeLower <= bars and bars <= rangeUpper

//------------------------------------------------------------------------------
// Regular Bullish

// Osc: Higher Low
oscHL = osc[lbR] > valuewhen(plFound, osc[lbR], 1) and _inRange(plFound[1])

// Price: Lower Low
priceLL = low[lbR] < valuewhen(plFound, low[lbR], 1)

bullCond = plotBull and priceLL and oscHL and plFound

plot(
plFound ? osc[lbR] : na,
offset=-lbR,
title="Regular Bullish",
linewidth=2,
color=(bullCond ? bullColor : noneColor),
transp=0
)


plotshape(
bullCond ? osc[lbR] : na,
offset=-lbR,
title="Regular Bullish Label",
text=" Bull ",
style=shape.labelup,
location=location.absolute,
color=bullColor,
textcolor=textColor,
transp=0
)

//------------------------------------------------------------------------------
// Hidden Bullish

// Osc: Lower Low
oscLL = osc[lbR] < valuewhen(plFound, osc[lbR], 1) and _inRange(plFound[1])

// Price: Higher Low
priceHL = low[lbR] > valuewhen(plFound, low[lbR], 1)

hiddenBullCond = plotHiddenBull and priceHL and oscLL and plFound
plot(
plFound ? osc[lbR] : na,
offset=-lbR,
title="Hidden Bullish",
linewidth=2,
color=(hiddenBullCond ? hiddenBullColor : noneColor),
transp=0
)

plotshape(
hiddenBullCond ? osc[lbR] : na,
offset=-lbR,
title="Hidden Bullish Label",
text=" H Bull ",
style=shape.labelup,
location=location.absolute,
color=bullColor,
textcolor=textColor,
transp=0
)

longCondition=bullCond or hiddenBullCond
//? osc[lbR] : na
//hiddenBullCond
strategy.entry(id="RSIDivLE", long=true, when=longCondition)


//Trailing StopLoss
////// Calculate trailing SL
/////////////////////////////////////////////////////
sl_val = sl_type == "ATR" ? stopLoss * atr(atrLength) :
sl_type == "PERC" ? close * stopLoss / 100 : 0.00

trailing_sl = 0.0
trailing_sl := strategy.position_size>=1 ? max(low - sl_val, nz(trailing_sl[1])) : na

//draw initil stop loss
//plot(strategy.position_size>=1 ? trailing_sl : na, color = color.blue , style=plot.style_linebr, linewidth = 2, title = "stop loss")
//plot(trailing_sl, title="ATR Trailing Stop Loss", style=plot.style_linebr, linewidth=1, color=color.purple, transp=30)
//Trailing StopLoss
////// Calculate trailing SL
/////////////////////////////////////////////////////


//------------------------------------------------------------------------------
// Regular Bearish

// Osc: Lower High
oscLH = osc[lbR] < valuewhen(phFound, osc[lbR], 1) and _inRange(phFound[1])

// Price: Higher High
priceHH = high[lbR] > valuewhen(phFound, high[lbR], 1)

bearCond = plotBear and priceHH and oscLH and phFound

plot(
phFound ? osc[lbR] : na,
offset=-lbR,
title="Regular Bearish",
linewidth=2,
color=(bearCond ? bearColor : noneColor),
transp=0
)

plotshape(
bearCond ? osc[lbR] : na,
offset=-lbR,
title="Regular Bearish Label",
text=" Bear ",
style=shape.labeldown,
location=location.absolute,
color=bearColor,
textcolor=textColor,

transp=0
)

//------------------------------------------------------------------------------
// Hidden Bearish

// Osc: Higher High
oscHH = osc[lbR] > valuewhen(phFound, osc[lbR], 1) and _inRange(phFound[1])

// Price: Lower High
priceLH = high[lbR] < valuewhen(phFound, high[lbR], 1)

hiddenBearCond = plotHiddenBear and priceLH and oscHH and phFound

plot(
phFound ? osc[lbR] : na,
offset=-lbR,
title="Hidden Bearish",
linewidth=2,
color=(hiddenBearCond ? hiddenBearColor : noneColor),
transp=0
)

plotshape(
hiddenBearCond ? osc[lbR] : na,
offset=-lbR,
title="Hidden Bearish Label",
text=" H Bear ",
style=shape.labeldown,
location=location.absolute,
color=bearColor,
textcolor=textColor,
transp=0
)
longCloseCondition=crossover(osc,takeProfitRSILevel) or bearCond
strategy.close(id="RSIDivLE", comment="Close All="+tostring(close - strategy.position_avg_price, "####.##"), when= abs(strategy.position_size)>=1 and sl_type == "NONE" and longCloseCondition)

//close all on stop loss
strategy.close(id="RSIDivLE", comment="TSL="+tostring(close - strategy.position_avg_price, "####.##"), when=abs(strategy.position_size)>=1 and (sl_type == "PERC" or sl_type == "ATR" ) and crossunder(close, trailing_sl) ) //close<ema55 and rsi5Val<20 //ema34<ema55 //close<ema89
 

cswu1211

Member
VIP
Found the Follow Line Indicator on Tradingview. Could anyone help with translate it into TOS.
Didn't find one on our platform, maybe there is any that work similar to it?!

The FollowLine indicator is a trend following indicator. The blue/red lines are activated when the price closes above the upper Bollinger band or below the lower one.
Once the trigger of the trend direction is made, the FollowLine will be placed at High or Low (depending of the trend).
An ATR filter can be selected to place the line at a more distance level than the normal mode settled at candles Highs/Lows.
jG2uts3.png

The original script is as follows:
Ruby:
// © Dreadblitz
//@version=4
study(shorttitle="FLI", title="Follow Line Indicator", overlay=true)
//
BBperiod = input(defval = 21, title = "BB Period", type = input.integer, minval = 1)
BBdeviations = input(defval = 1.00, title = "BB Deviations", type = input.float, minval = 0.1, step=0.05)
UseATRfilter = input(defval = true, title = "ATR Filter", type = input.bool)
ATRperiod = input(defval = 5, title = "ATR Period", type = input.integer, minval = 1)
hl = input(defval = false, title = "Hide Labels", type = input.bool)
//
BBUpper=sma (close,BBperiod)+stdev(close, BBperiod)*BBdeviations
BBLower=sma (close,BBperiod)-stdev(close, BBperiod)*BBdeviations
//
TrendLine = 0.0
iTrend = 0.0
buy = 0.0
sell = 0.0
//
BBSignal = close>BBUpper? 1 : close<BBLower? -1 : 0
//
if BBSignal == 1 and UseATRfilter == 1
TrendLine:=low-atr(ATRperiod)
if TrendLine<TrendLine[1]
TrendLine:=TrendLine[1]
if BBSignal == -1 and UseATRfilter == 1
TrendLine:=high+atr(ATRperiod)
if TrendLine>TrendLine[1]
TrendLine:=TrendLine[1]
if BBSignal == 0 and UseATRfilter == 1
TrendLine:=TrendLine[1]
//
if BBSignal == 1 and UseATRfilter == 0
TrendLine:=low
if TrendLine<TrendLine[1]
TrendLine:=TrendLine[1]
if BBSignal == -1 and UseATRfilter == 0

TrendLine:=high
if TrendLine>TrendLine[1]
TrendLine:=TrendLine[1]
if BBSignal == 0 and UseATRfilter == 0
TrendLine:=TrendLine[1]
//
iTrend:=iTrend[1]
if TrendLine>TrendLine[1]
iTrend:=1
if TrendLine<TrendLine[1]
iTrend:=-1
//
buy:=iTrend[1]==-1 and iTrend==1 ? 1 : na
sell:=iTrend[1]==1 and iTrend==-1? 1 : na
//
plot(TrendLine, color=iTrend > 0?color.blue:color.red ,style=plot.style_line,linewidth=2,transp=0,title="Trend Line")
plotshape(buy == 1 and hl == false? TrendLine-atr(8) :na, text='💣', style= shape.labelup, location=location.absolute, color=color.blue, textcolor=color.white, offset=0, transp=0,size=size.auto)
plotshape(sell == 1 and hl == false ?TrendLine+atr(8):na, text='🔨', style=shape.labeldown, location=location.absolute, color=color.red, textcolor=color.white, offset=0, transp=0,size=size.auto)
//
alertcondition(sell == 1 ,title="Sell",message="Sell")
alertcondition(buy == 1 ,title="Buy",message="Buy")
alertcondition(buy == 1 or sell == 1 ,title="Buy/Sell",message="Buy/Sell")
 
Last edited by a moderator:

kcj5103

New member
I need help creating a buy signal scan in think or swim for the below Tradingview indicator called SSL Hybrid.

I do not need the entire script, I mainly just need the blue LONG buy signal/arrow that appears under a candle in Tradingview.

I would like to set up a scan query and find stocks that have the blue buy arrow underneath the candle. TOS does not have this feature. I think the indicator uses the Jurik 5 Period Moving Average (Please see the code) to trigger the blue arrow long buy signal.

Wishfully, I would like the entire SSL Hybrid indicator created in TOS to be used as a scanner, but I just mainly need the long buy signal code to use in a scanner. When using SSL Hybrid in Tradingview, the alert it uses to notify you of the blue arrow buy signal is called "Exit Sell". This is the code I need, the code that scans for "Exit Sell". If too complicated, can someone just please create a study to scan for Jurik Moving Average 5 day in Think of Swim? I can't find a Jurik moving average in TOS.


The Tradingview indicator is called SSL hybrid https://www.tradingview.com/script/C3MlAWCw-SSL-Hybrid/ (see the code below. A lot of the code can be ignored because it is just giving the user the option to change their indicator preferences, I would like to stay with the default settings)


HOW TO USE THE INDICATOR:
You buy LONG once a blue arrow appears under the candle AND only after the Tradingview Indicator called QQE MOD by
Mihkel00 turns blue.


The SSL hybrid is also extremely accurate when used with

Squeeze Momentum Indicator [LazyBear] Version2 by KıvanÇ fr3762​

(when you see the blue line cross the red line it's a confirmation of the buy signal)


I also use it with the Tradingview Indicator by Rooster100 called

R100 Wave Volume v2 (v)​

If you have a blue buy arrow and the R100 Wave is GREEN or turns green shortly afterwards. You have another confirmation


These indicators in combination have over a 90% success rate for me. Higher success if you wait for a TEMA 9 moving average (indicator) to cross the blue SSL Hybrid Baseline. (the blue and Red line on the chart, because this is where most candles start to shoot up. I think this line is the 1 Hour TEMA or similar. See photo below) If you wait until the TEMA 9 crosses the SSL Hybrid baseline it's mostly likely a solid win, but the move will be smaller before it turns around so it's best to buy after confirmation of the blue arrow, where you can profit more, although a more risky trade.


This script is designed for the NNFX Method, so it is recommended for Daily charts only.
Tried to implement a few VP NNFX Rules
This script has a SSL / Baseline (you can choose between the SSL or MA), a secondary SSL for continiuation trades and a third SSL for exit trades.
Alerts added for Baseline entries, SSL2 continuations, Exits.
Baseline has a Keltner Channel setting for "in zone" Gray Candles
Added "Candle Size > 1 ATR" Diamonds from my old script with the criteria of being within Baseline ATR range.
a3.png


Ruby:
//@version=4
//By Mihkel00
// This script is designed for the NNFX Method, so it is recommended for Daily charts only.
// Tried to implement a few VP NNFX Rules
// This script has a SSL / Baseline (you can choose between the SSL or MA), a secondary SSL for continiuation trades and a third SSL for exit trades.
// Alerts added for Baseline entries, SSL2 continuations, Exits.
// Baseline has a Keltner Channel setting for "in zone" Gray Candles
// Added "Candle Size > 1 ATR" Diamonds from my old script with the criteria of being within Baseline ATR range.
// Credits
// Strategy causecelebre https://www.tradingview.com/u/causecelebre/
// SSL Channel ErwinBeckers https://www.tradingview.com/u/ErwinBeckers/
// Moving Averages jiehonglim https://www.tradingview.com/u/jiehonglim/
// Moving Averages everget https://www.tradingview.com/u/everget/
// "Many Moving Averages" script Fractured https://www.tradingview.com/u/Fractured/
study("SSL Hybrid", overlay=true)
show_Baseline = input(title="Show Baseline", type=input.bool, defval=true)
show_SSL1 = input(title="Show SSL1", type=input.bool, defval=false)
show_atr = input(title="Show ATR bands", type=input.bool, defval=true)
//ATR
atrlen = input(14, "ATR Period")
mult = input(1, "ATR Multi", step=0.1)
smoothing = input(title="ATR Smoothing", defval="WMA", options=["RMA", "SMA", "EMA", "WMA"])

ma_function(source, atrlen) =>
if smoothing == "RMA"
rma(source, atrlen)
else
if smoothing == "SMA"
sma(source, atrlen)
else
if smoothing == "EMA"
ema(source, atrlen)
else
wma(source, atrlen)
atr_slen = ma_function(tr(true), atrlen)
////ATR Up/Low Bands
upper_band = atr_slen * mult + close
lower_band = close - atr_slen * mult

////BASELINE / SSL1 / SSL2 / EXIT MOVING AVERAGE VALUES
maType = input(title="SSL1 / Baseline Type", type=input.string, defval="HMA", options=["SMA","EMA","DEMA","TEMA","LSMA","WMA","MF","VAMA","TMA","HMA", "JMA", "Kijun v2", "EDSMA","McGinley"])
len = input(title="SSL1 / Baseline Length", defval=60)

SSL2Type = input(title="SSL2 / Continuation Type", type=input.string, defval="JMA", options=["SMA","EMA","DEMA","TEMA","WMA","MF","VAMA","TMA","HMA", "JMA","McGinley"])
len2 = input(title="SSL 2 Length", defval=5)
//
SSL3Type = input(title="EXIT Type", type=input.string, defval="HMA", options=["DEMA","TEMA","LSMA","VAMA","TMA","HMA","JMA", "Kijun v2", "McGinley", "MF"])
len3 = input(title="EXIT Length", defval=15)
src = input(title="Source", type=input.source, defval=close)

//
tema(src, len) =>
ema1 = ema(src, len)
ema2 = ema(ema1, len)
ema3 = ema(ema2, len)
(3 * ema1) - (3 * ema2) + ema3
kidiv = input(defval=1,maxval=4, title="Kijun MOD Divider")

jurik_phase = input(title="* Jurik (JMA) Only - Phase", type=input.integer, defval=3)
jurik_power = input(title="* Jurik (JMA) Only - Power", type=input.integer, defval=1)
volatility_lookback = input(10, title="* Volatility Adjusted (VAMA) Only - Volatility lookback length")
//MF
beta = input(0.8,minval=0,maxval=1,step=0.1, title="Modular Filter, General Filter Only - Beta")
feedback = input(false, title="Modular Filter Only - Feedback")
z = input(0.5,title="Modular Filter Only - Feedback Weighting",step=0.1, minval=0, maxval=1)
//EDSMA
ssfLength = input(title="EDSMA - Super Smoother Filter Length", type=input.integer, minval=1, defval=20)
ssfPoles = input(title="EDSMA - Super Smoother Filter Poles", type=input.integer, defval=2, options=[2, 3])

//----

//EDSMA
get2PoleSSF(src, length) =>
PI = 2 * asin(1)
arg = sqrt(2) * PI / length
a1 = exp(-arg)
b1 = 2 * a1 * cos(arg)
c2 = b1
c3 = -pow(a1, 2)
c1 = 1 - c2 - c3

ssf = 0.0
ssf := c1 * src + c2 * nz(ssf[1]) + c3 * nz(ssf[2])

get3PoleSSF(src, length) =>
PI = 2 * asin(1)

arg = PI / length
a1 = exp(-arg)
b1 = 2 * a1 * cos(1.738 * arg)
c1 = pow(a1, 2)

coef2 = b1 + c1
coef3 = -(c1 + b1 * c1)
coef4 = pow(c1, 2)
coef1 = 1 - coef2 - coef3 - coef4

ssf = 0.0
ssf := coef1 * src + coef2 * nz(ssf[1]) + coef3 * nz(ssf[2]) + coef4 * nz(ssf[3])

ma(type, src, len) =>
float result = 0
if type=="TMA"
result := sma(sma(src, ceil(len / 2)), floor(len / 2) + 1)
if type=="MF"
ts=0.,b=0.,c=0.,os=0.
//----
alpha = 2/(len+1)
a = feedback ? z*src + (1-z)*nz(ts[1],src) : src
//----
b := a > alpha*a+(1-alpha)*nz(b[1],a) ? a : alpha*a+(1-alpha)*nz(b[1],a)
c := a < alpha*a+(1-alpha)*nz(c[1],a) ? a : alpha*a+(1-alpha)*nz(c[1],a)
os := a == b ? 1 : a == c ? 0 : os[1]
//----
upper = beta*b+(1-beta)*c
lower = beta*c+(1-beta)*b
ts := os*upper+(1-os)*lower
result := ts
if type=="LSMA"
result := linreg(src, len, 0)
if type=="SMA" // Simple
result := sma(src, len)
if type=="EMA" // Exponential
result := ema(src, len)
if type=="DEMA" // Double Exponential
e = ema(src, len)
result := 2 * e - ema(e, len)
if type=="TEMA" // Triple Exponential
e = ema(src, len)
result := 3 * (e - ema(e, len)) + ema(ema(e, len), len)
if type=="WMA" // Weighted
result := wma(src, len)
if type=="VAMA" // Volatility Adjusted
/// Copyright © 2019 to present, Joris Duyck (JD)
mid=ema(src,len)
dev=src-mid
vol_up=highest(dev,volatility_lookback)
vol_down=lowest(dev,volatility_lookback)
result := mid+avg(vol_up,vol_down)
if type=="HMA" // Hull
result := wma(2 * wma(src, len / 2) - wma(src, len), round(sqrt(len)))
if type=="JMA" // Jurik
/// Copyright © 2018 Alex Orekhov (everget)
/// Copyright © 2017 Jurik Research and Consulting.
phaseRatio = jurik_phase < -100 ? 0.5 : jurik_phase > 100 ? 2.5 : jurik_phase / 100 + 1.5
beta = 0.45 * (len - 1) / (0.45 * (len - 1) + 2)
alpha = pow(beta, jurik_power)
jma = 0.0
e0 = 0.0
e0 := (1 - alpha) * src + alpha * nz(e0[1])
e1 = 0.0
e1 := (src - e0) * (1 - beta) + beta * nz(e1[1])
e2 = 0.0
e2 := (e0 + phaseRatio * e1 - nz(jma[1])) * pow(1 - alpha, 2) + pow(alpha, 2) * nz(e2[1])
jma := e2 + nz(jma[1])
result := jma
if type=="Kijun v2"
kijun = avg(lowest(len), highest(len))//, (open + close)/2)
conversionLine = avg(lowest(len/kidiv), highest(len/kidiv))
delta = (kijun + conversionLine)/2
result :=delta
if type=="McGinley"
mg = 0.0
mg := na(mg[1]) ? ema(src, len) : mg[1] + (src - mg[1]) / (len * pow(src/mg[1], 4))
result :=mg
if type=="EDSMA"

zeros = src - nz(src[2])
avgZeros = (zeros + zeros[1]) / 2

// Ehlers Super Smoother Filter
ssf = ssfPoles == 2
? get2PoleSSF(avgZeros, ssfLength)
: get3PoleSSF(avgZeros, ssfLength)

// Rescale filter in terms of Standard Deviations
stdev = stdev(ssf, len)
scaledFilter = stdev != 0
? ssf / stdev
: 0

alpha = 5 * abs(scaledFilter) / len

edsma = 0.0
edsma := alpha * src + (1 - alpha) * nz(edsma[1])
result := edsma
result

///SSL 1 and SSL2
emaHigh = ma(maType, high, len)
emaLow = ma(maType, low, len)

maHigh = ma(SSL2Type, high, len2)
maLow = ma(SSL2Type, low, len2)

///EXIT
ExitHigh = ma(SSL3Type, high, len3)
ExitLow = ma(SSL3Type, low, len3)

///Keltner Baseline Channel
BBMC = ma(maType, close, len)
useTrueRange = input(true)
multy = input(0.2, step=0.05, title="Base Channel Multiplier")
Keltma = ma(maType, src, len)
range = useTrueRange ? tr : high - low
rangema = ema(range, len)
upperk =Keltma + rangema * multy
lowerk = Keltma - rangema * multy

//Baseline Violation Candle
open_pos = open*1
close_pos = close*1
difference = abs(close_pos-open_pos)
atr_violation = difference > atr_slen
InRange = upper_band > BBMC and lower_band < BBMC
candlesize_violation = atr_violation and InRange
plotshape(candlesize_violation, color=color.white, size=size.tiny,style=shape.diamond, location=location.top, transp=0,title="Candle Size > 1xATR")


//SSL1 VALUES
Hlv = int(na)
Hlv := close > emaHigh ? 1 : close < emaLow ? -1 : Hlv[1]
sslDown = Hlv < 0 ? emaHigh : emaLow

//SSL2 VALUES
Hlv2 = int(na)
Hlv2 := close > maHigh ? 1 : close < maLow ? -1 : Hlv2[1]
sslDown2 = Hlv2 < 0 ? maHigh : maLow

//EXIT VALUES
Hlv3 = int(na)
Hlv3 := close > ExitHigh ? 1 : close < ExitLow ? -1 : Hlv3[1]
sslExit = Hlv3 < 0 ? ExitHigh : ExitLow
base_cross_Long = crossover(close, sslExit)
base_cross_Short = crossover(sslExit, close)
codiff = base_cross_Long ? 1 : base_cross_Short ? -1 : na

//COLORS
show_color_bar = input(title="Color Bars", type=input.bool, defval=true)
color_bar = close > upperk ? #00c3ff : close < lowerk ? #ff0062 : color.gray
color_ssl1 = close > sslDown ? #00c3ff : close < sslDown ? #ff0062 : na

//PLOTS
plotarrow(codiff, colorup=#00c3ff, colordown=#ff0062,title="Exit Arrows", transp=20, maxheight=20, offset=0)
p1 = plot(show_Baseline ? BBMC : na, color=color_bar, linewidth=4,transp=0, title='MA Baseline')
DownPlot = plot( show_SSL1 ? sslDown : na, title="SSL1", linewidth=3, color=color_ssl1, transp=10)
barcolor(show_color_bar ? color_bar : na)
up_channel = plot(show_Baseline ? upperk : na, color=color_bar, title="Baseline Upper Channel")
low_channel = plot(show_Baseline ? lowerk : na, color=color_bar, title="Basiline Lower Channel")
fill(up_channel, low_channel, color=color_bar, transp=90)

////SSL2 Continiuation from ATR
atr_crit = input(0.9, step=0.1, title="Continuation ATR Criteria")
upper_half = atr_slen * atr_crit + close
lower_half = close - atr_slen * atr_crit
buy_inatr = lower_half < sslDown2
sell_inatr = upper_half > sslDown2
sell_cont = close < BBMC and close < sslDown2
buy_cont = close > BBMC and close > sslDown2
sell_atr = sell_inatr and sell_cont
buy_atr = buy_inatr and buy_cont
atr_fill = buy_atr ? color.green : sell_atr ? color.purple : color.white
LongPlot = plot(sslDown2, title="SSL2", linewidth=2, color=atr_fill, style=plot.style_circles, transp=0)
u = plot(show_atr ? upper_band : na, "+ATR", color=color.white, transp=80)
l = plot(show_atr ? lower_band : na, "-ATR", color=color.white, transp=80)

//ALERTS
alertcondition(crossover(close, sslDown), title='SSL Cross Alert', message='SSL1 has crossed.')
alertcondition(crossover(close, sslDown2), title='SSL2 Cross Alert', message='SSL2 has crossed.')
alertcondition(sell_atr, title='Sell Continuation', message='Sell Continuation.')
alertcondition(buy_atr, title='Buy Continuation', message='Buy Continuation.')
alertcondition(crossover(close, sslExit), title='Exit Sell', message='Exit Sell Alert.')
alertcondition(crossover(sslExit, close), title='Exit Buy', message='Exit Buy Alert.')
alertcondition(crossover(close, upperk ), title='Baseline Buy Entry', message='Base Buy Alert.')
alertcondition(crossover(lowerk, close ), title='Baseline Sell Entry', message='Base Sell Alert.')
 

hjc5812

New member
VIP
I searched the forum and it seems we do not have SSL hybrid from Tradingview converted yet.
Below is the code. If somebody can covert this I would greatly appreciate it.

------------------------------------------------------------------------------------------------------

//@version=4
//By Mihkel00
// This script is designed for the NNFX Method, so it is recommended for Daily charts only.
// Tried to implement a few VP NNFX Rules
// This script has a SSL / Baseline (you can choose between the SSL or MA), a secondary SSL for continiuation trades and a third SSL for exit trades.
// Alerts added for Baseline entries, SSL2 continuations, Exits.
// Baseline has a Keltner Channel setting for "in zone" Gray Candles
// Added "Candle Size > 1 ATR" Diamonds from my old script with the criteria of being within Baseline ATR range.
// Credits
// Strategy causecelebre https://www.tradingview.com/u/causecelebre/
// SSL Channel ErwinBeckers https://www.tradingview.com/u/ErwinBeckers/
// Moving Averages jiehonglim https://www.tradingview.com/u/jiehonglim/
// Moving Averages everget https://www.tradingview.com/u/everget/
// "Many Moving Averages" script Fractured https://www.tradingview.com/u/Fractured/
study("SSL Hybrid", overlay=true)
show_Baseline = input(title="Show Baseline", type=input.bool, defval=true)
show_SSL1 = input(title="Show SSL1", type=input.bool, defval=false)
show_atr = input(title="Show ATR bands", type=input.bool, defval=true)
//ATR
atrlen = input(14, "ATR Period")
mult = input(1, "ATR Multi", step=0.1)
smoothing = input(title="ATR Smoothing", defval="WMA", options=["RMA", "SMA", "EMA", "WMA"])

ma_function(source, atrlen) =>
if smoothing == "RMA"
rma(source, atrlen)
else
if smoothing == "SMA"
sma(source, atrlen)
else
if smoothing == "EMA"
ema(source, atrlen)
else
wma(source, atrlen)
atr_slen = ma_function(tr(true), atrlen)
////ATR Up/Low Bands
upper_band = atr_slen * mult + close
lower_band = close - atr_slen * mult

////BASELINE / SSL1 / SSL2 / EXIT MOVING AVERAGE VALUES
maType = input(title="SSL1 / Baseline Type", type=input.string, defval="HMA", options=["SMA","EMA","DEMA","TEMA","LSMA","WMA","MF","VAMA","TMA","HMA", "JMA", "Kijun v2", "EDSMA","McGinley"])
len = input(title="SSL1 / Baseline Length", defval=60)

SSL2Type = input(title="SSL2 / Continuation Type", type=input.string, defval="JMA", options=["SMA","EMA","DEMA","TEMA","WMA","MF","VAMA","TMA","HMA", "JMA","McGinley"])
len2 = input(title="SSL 2 Length", defval=5)
//
SSL3Type = input(title="EXIT Type", type=input.string, defval="HMA", options=["DEMA","TEMA","LSMA","VAMA","TMA","HMA","JMA", "Kijun v2", "McGinley", "MF"])
len3 = input(title="EXIT Length", defval=15)
src = input(title="Source", type=input.source, defval=close)

//
tema(src, len) =>
ema1 = ema(src, len)
ema2 = ema(ema1, len)
ema3 = ema(ema2, len)
(3 * ema1) - (3 * ema2) + ema3
kidiv = input(defval=1,maxval=4, title="Kijun MOD Divider")

jurik_phase = input(title="* Jurik (JMA) Only - Phase", type=input.integer, defval=3)
jurik_power = input(title="* Jurik (JMA) Only - Power", type=input.integer, defval=1)
volatility_lookback = input(10, title="* Volatility Adjusted (VAMA) Only - Volatility lookback length")
//MF
beta = input(0.8,minval=0,maxval=1,step=0.1, title="Modular Filter, General Filter Only - Beta")
feedback = input(false, title="Modular Filter Only - Feedback")
z = input(0.5,title="Modular Filter Only - Feedback Weighting",step=0.1, minval=0, maxval=1)
//EDSMA
ssfLength = input(title="EDSMA - Super Smoother Filter Length", type=input.integer, minval=1, defval=20)
ssfPoles = input(title="EDSMA - Super Smoother Filter Poles", type=input.integer, defval=2, options=[2, 3])

//----

//EDSMA
get2PoleSSF(src, length) =>
PI = 2 * asin(1)
arg = sqrt(2) * PI / length
a1 = exp(-arg)
b1 = 2 * a1 * cos(arg)
c2 = b1
c3 = -pow(a1, 2)
c1 = 1 - c2 - c3

ssf = 0.0
ssf := c1 * src + c2 * nz(ssf[1]) + c3 * nz(ssf[2])

get3PoleSSF(src, length) =>
PI = 2 * asin(1)

arg = PI / length
a1 = exp(-arg)
b1 = 2 * a1 * cos(1.738 * arg)
c1 = pow(a1, 2)

coef2 = b1 + c1
coef3 = -(c1 + b1 * c1)
coef4 = pow(c1, 2)
coef1 = 1 - coef2 - coef3 - coef4

ssf = 0.0
ssf := coef1 * src + coef2 * nz(ssf[1]) + coef3 * nz(ssf[2]) + coef4 * nz(ssf[3])

ma(type, src, len) =>
float result = 0
if type=="TMA"
result := sma(sma(src, ceil(len / 2)), floor(len / 2) + 1)
if type=="MF"
ts=0.,b=0.,c=0.,os=0.
//----
alpha = 2/(len+1)
a = feedback ? z*src + (1-z)*nz(ts[1],src) : src
//----
b := a > alpha*a+(1-alpha)*nz(b[1],a) ? a : alpha*a+(1-alpha)*nz(b[1],a)
c := a < alpha*a+(1-alpha)*nz(c[1],a) ? a : alpha*a+(1-alpha)*nz(c[1],a)
os := a == b ? 1 : a == c ? 0 : os[1]
//----
upper = beta*b+(1-beta)*c
lower = beta*c+(1-beta)*b
ts := os*upper+(1-os)*lower
result := ts
if type=="LSMA"
result := linreg(src, len, 0)
if type=="SMA" // Simple
result := sma(src, len)
if type=="EMA" // Exponential
result := ema(src, len)
if type=="DEMA" // Double Exponential
e = ema(src, len)
result := 2 * e - ema(e, len)
if type=="TEMA" // Triple Exponential
e = ema(src, len)
result := 3 * (e - ema(e, len)) + ema(ema(e, len), len)
if type=="WMA" // Weighted
result := wma(src, len)
if type=="VAMA" // Volatility Adjusted
/// Copyright © 2019 to present, Joris Duyck (JD)
mid=ema(src,len)
dev=src-mid
vol_up=highest(dev,volatility_lookback)
vol_down=lowest(dev,volatility_lookback)
result := mid+avg(vol_up,vol_down)
if type=="HMA" // Hull
result := wma(2 * wma(src, len / 2) - wma(src, len), round(sqrt(len)))
if type=="JMA" // Jurik
/// Copyright © 2018 Alex Orekhov (everget)
/// Copyright © 2017 Jurik Research and Consulting.
phaseRatio = jurik_phase < -100 ? 0.5 : jurik_phase > 100 ? 2.5 : jurik_phase / 100 + 1.5
beta = 0.45 * (len - 1) / (0.45 * (len - 1) + 2)
alpha = pow(beta, jurik_power)
jma = 0.0
e0 = 0.0
e0 := (1 - alpha) * src + alpha * nz(e0[1])
e1 = 0.0
e1 := (src - e0) * (1 - beta) + beta * nz(e1[1])
e2 = 0.0
e2 := (e0 + phaseRatio * e1 - nz(jma[1])) * pow(1 - alpha, 2) + pow(alpha, 2) * nz(e2[1])
jma := e2 + nz(jma[1])
result := jma
if type=="Kijun v2"
kijun = avg(lowest(len), highest(len))//, (open + close)/2)
conversionLine = avg(lowest(len/kidiv), highest(len/kidiv))
delta = (kijun + conversionLine)/2
result :=delta
if type=="McGinley"
mg = 0.0
mg := na(mg[1]) ? ema(src, len) : mg[1] + (src - mg[1]) / (len * pow(src/mg[1], 4))
result :=mg
if type=="EDSMA"

zeros = src - nz(src[2])
avgZeros = (zeros + zeros[1]) / 2

// Ehlers Super Smoother Filter
ssf = ssfPoles == 2
? get2PoleSSF(avgZeros, ssfLength)
: get3PoleSSF(avgZeros, ssfLength)

// Rescale filter in terms of Standard Deviations
stdev = stdev(ssf, len)
scaledFilter = stdev != 0
? ssf / stdev
: 0

alpha = 5 * abs(scaledFilter) / len

edsma = 0.0
edsma := alpha * src + (1 - alpha) * nz(edsma[1])
result := edsma
result

///SSL 1 and SSL2
emaHigh = ma(maType, high, len)
emaLow = ma(maType, low, len)

maHigh = ma(SSL2Type, high, len2)
maLow = ma(SSL2Type, low, len2)

///EXIT
ExitHigh = ma(SSL3Type, high, len3)
ExitLow = ma(SSL3Type, low, len3)

///Keltner Baseline Channel
BBMC = ma(maType, close, len)
useTrueRange = input(true)
multy = input(0.2, step=0.05, title="Base Channel Multiplier")
Keltma = ma(maType, src, len)
range = useTrueRange ? tr : high - low
rangema = ema(range, len)
upperk =Keltma + rangema * multy
lowerk = Keltma - rangema * multy

//Baseline Violation Candle
open_pos = open*1
close_pos = close*1
difference = abs(close_pos-open_pos)
atr_violation = difference > atr_slen
InRange = upper_band > BBMC and lower_band < BBMC
candlesize_violation = atr_violation and InRange
plotshape(candlesize_violation, color=color.white, size=size.tiny,style=shape.diamond, location=location.top, transp=0,title="Candle Size > 1xATR")


//SSL1 VALUES
Hlv = int(na)
Hlv := close > emaHigh ? 1 : close < emaLow ? -1 : Hlv[1]
sslDown = Hlv < 0 ? emaHigh : emaLow

//SSL2 VALUES
Hlv2 = int(na)
Hlv2 := close > maHigh ? 1 : close < maLow ? -1 : Hlv2[1]
sslDown2 = Hlv2 < 0 ? maHigh : maLow

//EXIT VALUES
Hlv3 = int(na)
Hlv3 := close > ExitHigh ? 1 : close < ExitLow ? -1 : Hlv3[1]
sslExit = Hlv3 < 0 ? ExitHigh : ExitLow
base_cross_Long = crossover(close, sslExit)
base_cross_Short = crossover(sslExit, close)
codiff = base_cross_Long ? 1 : base_cross_Short ? -1 : na

//COLORS
show_color_bar = input(title="Color Bars", type=input.bool, defval=true)
color_bar = close > upperk ? #00c3ff : close < lowerk ? #ff0062 : color.gray
color_ssl1 = close > sslDown ? #00c3ff : close < sslDown ? #ff0062 : na

//PLOTS
plotarrow(codiff, colorup=#00c3ff, colordown=#ff0062,title="Exit Arrows", transp=20, maxheight=20, offset=0)
p1 = plot(show_Baseline ? BBMC : na, color=color_bar, linewidth=4,transp=0, title='MA Baseline')
DownPlot = plot( show_SSL1 ? sslDown : na, title="SSL1", linewidth=3, color=color_ssl1, transp=10)
barcolor(show_color_bar ? color_bar : na)
up_channel = plot(show_Baseline ? upperk : na, color=color_bar, title="Baseline Upper Channel")
low_channel = plot(show_Baseline ? lowerk : na, color=color_bar, title="Basiline Lower Channel")
fill(up_channel, low_channel, color=color_bar, transp=90)

////SSL2 Continiuation from ATR
atr_crit = input(0.9, step=0.1, title="Continuation ATR Criteria")
upper_half = atr_slen * atr_crit + close
lower_half = close - atr_slen * atr_crit
buy_inatr = lower_half < sslDown2
sell_inatr = upper_half > sslDown2
sell_cont = close < BBMC and close < sslDown2
buy_cont = close > BBMC and close > sslDown2
sell_atr = sell_inatr and sell_cont
buy_atr = buy_inatr and buy_cont
atr_fill = buy_atr ? color.green : sell_atr ? color.purple : color.white
LongPlot = plot(sslDown2, title="SSL2", linewidth=2, color=atr_fill, style=plot.style_circles, transp=0)
u = plot(show_atr ? upper_band : na, "+ATR", color=color.white, transp=80)
l = plot(show_atr ? lower_band : na, "-ATR", color=color.white, transp=80)

//ALERTS
alertcondition(crossover(close, sslDown), title='SSL Cross Alert', message='SSL1 has crossed.')
alertcondition(crossover(close, sslDown2), title='SSL2 Cross Alert', message='SSL2 has crossed.')
alertcondition(sell_atr, title='Sell Continuation', message='Sell Continuation.')
alertcondition(buy_atr, title='Buy Continuation', message='Buy Continuation.')
alertcondition(crossover(close, sslExit), title='Exit Sell', message='Exit Sell Alert.')
alertcondition(crossover(sslExit, close), title='Exit Buy', message='Exit Buy Alert.')
alertcondition(crossover(close, upperk ), title='Baseline Buy Entry', message='Base Buy Alert.')
alertcondition(crossover(lowerk, close ), title='Baseline Sell Entry', message='Base Sell Alert.')

------------------------------------------------------------------------------------------------------
 

mrclark1777

New member
Hello! I am trying to implement this QQE signals by Colin on Trading view to use on Think or swim.
This can be used on Crypto, Stocks, Forex, etc. and can be very useful for analyzing an investment alongside other indicators.

https://www.tradingview.com/script/7R6ZxyZu-QQE-signals/ is the link to the indicator on Tradingview

This is the code used on TradingView
Code:
("QQE signals", overlay=true)



RSI_Period = input(14, title='RSI Length')

SF = input(5, title='RSI Smoothing')

QQE = input(4.238, title='Fast QQE Factor')

ThreshHold = input(10, title="Thresh-hold")



src = close

Wilders_Period = RSI_Period * 2 - 1



Rsi = rsi(src, RSI_Period)

RsiMa = ema(Rsi, SF)

AtrRsi = abs(RsiMa[1] - RsiMa)

MaAtrRsi = ema(AtrRsi, Wilders_Period)

dar = ema(MaAtrRsi, Wilders_Period) * QQE



longband = 0.0

shortband = 0.0

trend = 0



DeltaFastAtrRsi = dar

RSIndex = RsiMa

newshortband = RSIndex + DeltaFastAtrRsi

newlongband = RSIndex - DeltaFastAtrRsi

longband := RSIndex[1] > longband[1] and RSIndex > longband[1] ? max(longband[1], newlongband) : newlongband

shortband := RSIndex[1] < shortband[1] and RSIndex < shortband[1] ? min(shortband[1], newshortband) : newshortband

cross_1 = cross(longband[1], RSIndex)

trend := cross(RSIndex, shortband[1]) ? 1 : cross_1 ? -1 : nz(trend[1], 1)

FastAtrRsiTL = trend == 1 ? longband : shortband



// Find all the QQE Crosses



QQExlong = 0

QQExlong := nz(QQExlong[1])

QQExshort = 0

QQExshort := nz(QQExshort[1])

QQExlong := FastAtrRsiTL < RSIndex ? QQExlong + 1 : 0

QQExshort := FastAtrRsiTL > RSIndex ? QQExshort + 1 : 0



//Conditions



qqeLong = QQExlong == 1 ? FastAtrRsiTL[1] - 50 : na

qqeShort = QQExshort == 1 ? FastAtrRsiTL[1] - 50 : na



// Plotting



plotshape(qqeLong, title="QQE long", text="Long", textcolor=color.white, style=shape.labelup, location=location.belowbar, color=color.green, transp=0, size=size.tiny)

plotshape(qqeShort, title="QQE short", text="Short", textcolor=color.white, style=shape.labeldown, location=location.abovebar, color=color.red, transp=0, size=size.tiny)



// Alerts



alertcondition(qqeLong, title="Long", message="Long")

alertcondition(qqeShort, title="Short", message="Short")

7R6ZxyZu_mid.png
 
Last edited:

mrclark1777

New member
This request has been made before, and no enterprising member took it on. :(
To garner interest in your indicator:
  • Provide a link to the TradingView Indicator.
  • Provide at least one image of the whole chart and then any close-up screenshots of details you want to highlight.
Unsure of how to upload screenshots to the forum, Here are directions.
  • Explain in detail why you think this one is superior to the existing indicators.
  • Illustrate with screenshots: the comparisons, and differences.
Putting in the effort to provide the images and the explanations shows your level of interest in working on this conversion as a collaboration. The more abundant the information you provide, the better chance that some enterprising poster might become interested in making enhancements to an existing TOS indicator or even creating one from scratch.

When you are posting your question, please follow the guidelines found here:
https://usethinkscript.com/threads/answers-to-commonly-asked-questions.6006/#post-58016

When posting your question, make sure to include what aggregations you trade, examples of equities/futures.
Lastly, to generate enough interest for a poster to work on this, make sure you explain how this will enhance our trading.
Thankyou for all of the suggestions and help!
 

cdgardner

New member


https://www.tradingview.com/script/U1SJ8ubc-HalfTrend/

Here is an image (hopefully) of the chart along with a link which contains the TradingView code for the upper and lower buy/sell bands I was asking about. These appear to be an ATR calculation added and subtracted from the Half Trend Indicator, very similar to how Keltner Channel Bands bracket a moving average. The code for the actual HalfTrend indicator was downloaded from this forum and is plotting correctly so hopefully the upper and lower bands may only require some additional code to the existing indicator. Whether this is true or not is beyond me.

I began using TOS less than two months ago and have virtually no experience coding indictors so any help is greatly appreciated.
 

Youcefteck90

New member
The VWAP Z SCORE STRINGS Indicator uses in TradingVeiw with Pine Script language. //Therefore, I need to use the same Indicator but by using Python with visual studio //Could please anyone help to create the code by using Python

Code:
;;
///INDICATOR WBORSA - V1 - COMPLEX -
study("WBORSA", shorttitle="BEFORE ITS TOO LATE")



//area 2
a2_top =input(4.5)
a2=input(4)
li1=plot(a2_top,"Area 2 High",color=black)
li2=plot(a2, "Area 2 Low",color=black)
fill(li1,li2, color=white)

//area 1
a1_top=input(3.5)
a1 = input(2.5)
li1_a1=plot(a1_top,"Area 2 High",color=black)
li2_a1=plot(a1, "Area 2 Low",color=black)
fill(li1_a1,li2_a1, color=#f44336)

//area -1
am1_top = input(-2.5)
am1 =  input(-3.5)
li1_m1=plot(am1_top,"Area 2 High",color=black)
li2_m1=plot(am1, "Area 2 Low",color=black)
fill(li1_m1,li2_m1, color=#09fa28)

//area -2
am2_top =  input(-4)
am2 = input(-4.5)
li1_m2=plot(am2_top,"Area 2 High",color=black)
li2_m2=plot(am2, "Area 2 Low",color=black)
fill(li1_m2,li2_m2, color=white)

// Math fomrula  / VWAP Z-SCORE
vwapScore(pds) =>
    mean = sum(volume*close,pds)/sum(volume,pds)
    vwapsd = sqrt(sma(pow(close-mean, 2), pds) )
    (close-mean)/vwapsd

plot(vwapScore(48),title="ZVWAP2-2",color=#ffe0b2, linewidth=2,transp=0.75)
plot(vwapScore(199),title="ZVWAP2-2",color=#cfb9ff, linewidth=2,style=circles,transp=0.75)
plot(vwapScore(484),title="ZVWAP2-3",color=#ffe0b2, linewidth=2,style=circles,transp=0.75)
 

MerryDay

Administrative
Staff member
Staff
VIP
The VWAP Z SCORE STRINGS Indicator uses in TradingVeiw with Pine Script language. //Therefore, I need to use the same Indicator but by using Python with visual studio //Could please anyone help to create the code by using Python

Code:
;;
///INDICATOR WBORSA - V1 - COMPLEX -
study("WBORSA", shorttitle="BEFORE ITS TOO LATE")



//area 2
a2_top =input(4.5)
a2=input(4)
li1=plot(a2_top,"Area 2 High",color=black)
li2=plot(a2, "Area 2 Low",color=black)
fill(li1,li2, color=white)

//area 1
a1_top=input(3.5)
a1 = input(2.5)
li1_a1=plot(a1_top,"Area 2 High",color=black)
li2_a1=plot(a1, "Area 2 Low",color=black)
fill(li1_a1,li2_a1, color=#f44336)

//area -1
am1_top = input(-2.5)
am1 =  input(-3.5)
li1_m1=plot(am1_top,"Area 2 High",color=black)
li2_m1=plot(am1, "Area 2 Low",color=black)
fill(li1_m1,li2_m1, color=#09fa28)

//area -2
am2_top =  input(-4)
am2 = input(-4.5)
li1_m2=plot(am2_top,"Area 2 High",color=black)
li2_m2=plot(am2, "Area 2 Low",color=black)
fill(li1_m2,li2_m2, color=white)

// Math fomrula  / VWAP Z-SCORE
vwapScore(pds) =>
    mean = sum(volume*close,pds)/sum(volume,pds)
    vwapsd = sqrt(sma(pow(close-mean, 2), pds) )
    (close-mean)/vwapsd

plot(vwapScore(48),title="ZVWAP2-2",color=#ffe0b2, linewidth=2,transp=0.75)
plot(vwapScore(199),title="ZVWAP2-2",color=#cfb9ff, linewidth=2,style=circles,transp=0.75)
plot(vwapScore(484),title="ZVWAP2-3",color=#ffe0b2, linewidth=2,style=circles,transp=0.75)
This is a ThinkScript Forum. We do not code in pinescript or python.
 

mbrandau

New member
I found a video on youtube from Alex's Options. All his links are not working now but his video was pertaining to #TheStrat trading bot and he was using NinjaTrader 8. Anyone know anything about a potential trading bot on NT8?
 

MerryDay

Administrative
Staff member
Staff
VIP
I found a video on youtube from Alex's Options. All his links are not working now but his video was pertaining to #TheStrat trading bot and he was using NinjaTrader 8. Anyone know anything about a potential trading bot on NT8?
This is a ThinkScript forum. You would need to address your question to an NT site
 

Similar threads

Top