Please convert this TV into TOS (BUY BACK)

Platform
  1. Thinkorswim
Here is the code:


Code:
    // ____  __    ___   ________ ___________  ___________ __  ____ ___ 
   // / __ )/ /   /   | / ____/ //_/ ____/   |/_  __<  / // / / __ |__ \
  // / __  / /   / /| |/ /   / ,< / /   / /| | / /  / / // /_/ / / __/ /
 // / /_/ / /___/ ___ / /___/ /| / /___/ ___ |/ /  / /__  __/ /_/ / __/ 
// /_____/_____/_/  |_\____/_/ |_\____/_/  |_/_/  /_/  /_/  \____/____/                                              
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © blackcat1402
//@version=4
study("[blackcat] L1 Buy Back","Buy Back", overlay=true, max_bars_back=5000, max_labels_count=500)
//functions
xrf(values, length) =>
    r_val = float(na)
    if length >= 1
        for i = 0 to length by 1
            if na(r_val) or not na(values[i])
                r_val  :=  values[i]
                r_val
    r_val
n = input(24 , title = 'period n', minval = 1)
fast = sma(close,n)
slow = sma(fast,12)
cond1 = low<fast
cond2 = close>fast
cond3 = close/xrf(close,1)<fast
cond4 = crossover(close,fast) and volume/xrf(sma(volume,5),1)>1.016
buy = cond1 and cond2 and cond3 and cond4
sell = crossunder(fast, slow)
Plot1 = plot( fast, "fast slope" ,color=color.yellow, linewidth=2) 
Plot2 = plot( slow, "slow slope",color=color.white, linewidth=2 ) 
fill(Plot1, Plot2, color=fast>slow?color.new(color.yellow,60):color.new(color.fuchsia,60))
bs_label = sell ? 
       label.new (bar_index, high, "S", color=color.new(color.lime,20), textcolor=color.white, style=label.style_label_down, yloc=yloc.price, size=size.small) :
       buy ?
           label.new (bar_index, low, "B", color=color.new(color.red, 20), textcolor=color.white, style=label.style_label_up, yloc=yloc.price, size=size.small) :
           na
 

barbaros

Administrator
Staff member
vPLkT4N.png
 
Top