EMA+UT Bot+CPR

Venkat7070 · study · 193 行 · 点赞 249 · TradingView 原页

本页源码来自 TradingView 公开发布的开源脚本,版权归原作者所有, 请遵循其原始许可(Pine 脚本常见 CC BY-NC-SA / MPL-2.0 / MIT)。 本项目仅用于研究检索与许可范围内的移植。

Pine Script

//@version=5
indicator("41-80 F&O MA Screener", overlay=true)
 
len1 = input.int(9, minval=1, title="MA1")
len2 = input.int(21, minval=1, title="MA2")
len3 = input.int(50, minval=1, title="MA3")
len4 = input.int(200, minval=1, title="MA4")
 
// RSI
rsiLengthInput = input.int(14, minval=1, title="RSI Length", group="RSI Settings")
rsiSourceInput = input.source(close, "Source", group="RSI Settings")
rsiUp = ta.rma(math.max(ta.change(rsiSourceInput), 0), rsiLengthInput)
rsiDown = ta.rma(-math.min(ta.change(rsiSourceInput), 0), rsiLengthInput)
rsi = rsiDown == 0 ? 100 : rsiUp == 0 ? 0 : 100 - (100 / (1 + rsiUp / rsiDown))
 
ma1 = ta.sma(close, len1)
ma2 = ta.sma(close, len2)
ma3 = ta.sma(close, len3)
ma4 = ta.sma(close, len4)
 
 
plot(ma1, title="MA1", color=color.green)
plot(ma2, title="MA2", color=color.red,linewidth=2)
plot(ma3, title="MA3", color=color.orange,linewidth=2)
plot(ma4, title="MA4", color=color.black,linewidth=2)
 
 
longCond = bool(na)
shortCond = bool(na)
longCond := ma1 > ma2 and ma1 > ma3 and rsi>50// and ma2 > ma3 and ma3 > ma4
shortCond :=  ma1 < ma2 and ma1 < ma3 and rsi<50// and ma2 < ma3// and rsi<35// and ma3 < ma4
 
CondIni = 0
CondIni := longCond ? 1 : shortCond ? -1 : CondIni[1]
longCondition = longCond and CondIni[1] == -1
shortCondition = shortCond and CondIni[1] == 1
 
plotshape(longCondition, title="Buy Signal", text="B", textcolor=color.white, style=shape.labelup, size=size.tiny, location=location.belowbar, color=color.green, transp=0)
plotshape(shortCondition, title="Short Signal", text="S", textcolor=color.white, style=shape.labeldown, size=size.tiny, location=location.abovebar, color=color.red, transp=0)
 
barcolor(high <= high[1] ?  low >= low[1] ? close >= open ? color.yellow :na :na : na)
barcolor(high <= high[1] ?  low >= low[1] ? close <= open ? color.black :na :na : na)
 
//////////////////////// Screener Section ////////////////////////////
 
var tableTheme = "========= Table Theme ========="
bgColor = input.color(#d1d4dc, "Background", group = tableTheme, inline = "table")
frameColor = input.color(color.white, "Frame", group = tableTheme, inline = "table")
textColor = input.color(color.rgb(0, 0, 0), "Text", group = tableTheme, inline = "table")
 
textSize = switch input.string("Auto", "Size", options = ['Auto', 'Tiny', 'Small', 'Normal', 'Large', 'Huge'], group = tableTheme)
    "Auto" => size.auto
    "Tiny" => size.tiny
    "Small" => size.small
    "Normal" => size.normal
    "Large" => size.large
    "Huge" => size.huge
 
location = switch input.string("Top Right", "Table Location", 
 options = ['Top Right', 'Top Center', 'Top Left', 'Middle Right', 'Middle Center', 'Middle Left', 'Bottom Right', 'Bottom Center', 'Bottom Left'], group = tableTheme)
    "Top Right" => position.top_right
    "Top Center" => position.top_center
    "Top Left" => position.top_left
    "Middle Right" => position.middle_right
    "Middle Center" => position.middle_center
    "Middle Left" => position.middle_left
    "Bottom Right" => position.bottom_right
    "Bottom Center" => position.bottom_center
    "Bottom Left" => position.bottom_left
 
/////////////////// Screener ////////////////////////
getSignal(symbol, longArray, shortArray)=>
    [long, short] = request.security(symbol, "", [longCondition, shortCondition])
 
    if long
        longArray.push(symbol)
 
    if short
        shortArray.push(symbol)
 
gticker = '=============== Watchlist ==============='
symbol41 = input.symbol(defval = "NSE:CHOLAFIN", title="symbol41", group=gticker)
symbol42 = input.symbol(defval = "NSE:CIPLA", title="symbol42", group=gticker)
symbol43 = input.symbol(defval = "NSE:COALINDIA", title="symbol43", group=gticker)
symbol44 = input.symbol(defval = "NSE:COFORGE", title="symbol44", group=gticker)
symbol45 = input.symbol(defval = "NSE:COLPAL", title="symbol45", group=gticker)
symbol46 = input.symbol(defval = "NSE:CONCOR", title="symbol46", group=gticker)
symbol47 = input.symbol(defval = "NSE:COROMANDEL", title="symbol47", group=gticker)
symbol48 = input.symbol(defval = "NSE:CROMPTON", title="symbol48", group=gticker)
symbol49 = input.symbol(defval = "NSE:CUB", title="symbol49", group=gticker)
symbol50 = input.symbol(defval = "NSE:CUMMINSIND", title="symbol50", group=gticker)
symbol51 = input.symbol(defval = "NSE:DABUR", title="symbol51", group=gticker)
symbol52 = input.symbol(defval = "NSE:DALBHARAT", title="symbol52", group=gticker)
symbol53 = input.symbol(defval = "NSE:DEEPAKNTR", title="symbol53", group=gticker)
symbol54 = input.symbol(defval = "NSE:DELTACORP", title="symbol54", group=gticker)
symbol55 = input.symbol(defval = "NSE:DIVISLAB", title="symbol55", group=gticker)
symbol56 = input.symbol(defval = "NSE:DIXON", title="symbol56", group=gticker)
symbol57 = input.symbol(defval = "NSE:DLF", title="symbol57", group=gticker)
symbol58 = input.symbol(defval = "NSE:DRREDDY", title="symbol58", group=gticker)
symbol59 = input.symbol(defval = "NSE:EICHERMOT", title="symbol59", group=gticker)
symbol60 = input.symbol(defval = "NSE:ESCORTS", title="symbol60", group=gticker)
symbol61 = input.symbol(defval = "NSE:EXIDEIND", title="symbol61", group=gticker)
symbol62 = input.symbol(defval = "NSE:FEDERALBNK", title="symbol62", group=gticker)
symbol63 = input.symbol(defval = "NSE:GAIL", title="symbol63", group=gticker)
symbol64 = input.symbol(defval = "NSE:GLENMARK", title="symbol64", group=gticker)
symbol65 = input.symbol(defval = "NSE:GMRINFRA", title="symbol65", group=gticker)
symbol66 = input.symbol(defval = "NSE:GNFC", title="symbol66", group=gticker)
symbol67 = input.symbol(defval = "NSE:GODREJCP", title="symbol67", group=gticker)
symbol68 = input.symbol(defval = "NSE:GODREJPROP", title="symbol68", group=gticker)
symbol69 = input.symbol(defval = "NSE:GRANULES", title="symbol69", group=gticker)
symbol70 = input.symbol(defval = "NSE:GRASIM", title="symbol70", group=gticker)
symbol71 = input.symbol(defval = "NSE:GUJGASLTD", title="symbol71", group=gticker)
symbol72 = input.symbol(defval = "NSE:HAL", title="symbol72", group=gticker)
symbol73 = input.symbol(defval = "NSE:HAVELLS", title="symbol73", group=gticker)
symbol74 = input.symbol(defval = "NSE:HCLTECH", title="symbol74", group=gticker)
symbol75 = input.symbol(defval = "NSE:HDFCAMC", title="symbol75", group=gticker)
symbol76 = input.symbol(defval = "NSE:HDFCBANK", title="symbol76", group=gticker)
symbol77 = input.symbol(defval = "NSE:HDFCLIFE", title="symbol77", group=gticker)
symbol78 = input.symbol(defval = "NSE:HEROMOTOCO", title="symbol78", group=gticker)
symbol79 = input.symbol(defval = "NSE:HINDALCO", title="symbol79", group=gticker)
symbol80 = input.symbol(defval = "NSE:HINDCOPPER", title="symbol80", group=gticker)
 
 
longArray = array.new_string(na)
shortArray = array.new_string(na)
 
getSignal(symbol41,longArray, shortArray)
getSignal(symbol42,longArray, shortArray)
getSignal(symbol43,longArray, shortArray)
getSignal(symbol44,longArray, shortArray)
getSignal(symbol45,longArray, shortArray)
getSignal(symbol46,longArray, shortArray)
getSignal(symbol47,longArray, shortArray)
getSignal(symbol48,longArray, shortArray)
getSignal(symbol49,longArray, shortArray)
getSignal(symbol50,longArray, shortArray)
getSignal(symbol51,longArray, shortArray)
getSignal(symbol52,longArray, shortArray)
getSignal(symbol53,longArray, shortArray)
getSignal(symbol54,longArray, shortArray)
getSignal(symbol55,longArray, shortArray)
getSignal(symbol56,longArray, shortArray)
getSignal(symbol57,longArray, shortArray)
getSignal(symbol58,longArray, shortArray)
getSignal(symbol59,longArray, shortArray)
getSignal(symbol60,longArray, shortArray)
getSignal(symbol61,longArray, shortArray)
getSignal(symbol62,longArray, shortArray)
getSignal(symbol63,longArray, shortArray)
getSignal(symbol64,longArray, shortArray)
getSignal(symbol65,longArray, shortArray)
getSignal(symbol66,longArray, shortArray)
getSignal(symbol67,longArray, shortArray)
getSignal(symbol68,longArray, shortArray)
getSignal(symbol69,longArray, shortArray)
getSignal(symbol70,longArray, shortArray)
getSignal(symbol71,longArray, shortArray)
getSignal(symbol72,longArray, shortArray)
getSignal(symbol73,longArray, shortArray)
getSignal(symbol74,longArray, shortArray)
getSignal(symbol75,longArray, shortArray)
getSignal(symbol76,longArray, shortArray)
getSignal(symbol77,longArray, shortArray)
getSignal(symbol78,longArray, shortArray)
getSignal(symbol79,longArray, shortArray)
getSignal(symbol80,longArray, shortArray)
 
 
getSym(sym)=>
    str.tostring(array.get(str.split(sym, ":"), 1))
    
if barstate.islast
    rowSize = math.max(longArray.size(), shortArray.size())
    dashboard = table.new(location, 2, rowSize + 3, border_color = frameColor, border_width = 1)
    dashboard.cell(0, 0, text = "Screener", bgcolor = bgColor, text_size = textSize, text_color = textColor)
    dashboard.merge_cells(0, 0, 1, 0)
 
    dashboard.cell(0, 1, text = "Long Signal", bgcolor = color.lime, text_size = textSize, text_color = color.black)
    dashboard.cell(1, 1, text = "Short Signal", bgcolor = color.red, text_size = textSize, text_color = color.white)
 
    if longArray.size() > 0
        for i = 0 to longArray.size() - 1
            dashboard.cell(0, i + 2, getSym(longArray.get(i)), text_color = textColor, bgcolor = color.lime, text_size = textSize)
    else
        dashboard.cell(0, 2, text = "No Signal", bgcolor = color.yellow, text_size = textSize, text_color = color.black)
 
    if shortArray.size() > 0
        for i = 0 to shortArray.size() - 1
            dashboard.cell(1, i + 2, getSym(shortArray.get(i)), text_color = textColor, bgcolor = color.red, text_size = textSize)
    else
        dashboard.cell(1, 2, text = "No Signal", bgcolor = color.yellow, text_size = textSize, text_color = color.black)
 
//open source acknolwedgements - Linear Regression Candles indicator by ugurvu, UT Bot Alerts indicator by QuantNomad

← 返回列表