0% found this document useful (0 votes)
38 views3 pages

Untitled Document

The document is a TradingView Pine Script code for an indicator called 'SAM AUTO SIGNALS' that generates buy and sell signals based on RSI and moving averages. It allows users to customize parameters such as RSI period, moving average types, and visibility of signals. The script includes calculations for moving averages, RSI, and band levels, and plots the results on the chart.

Uploaded by

Aj Deshmukh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
38 views3 pages

Untitled Document

The document is a TradingView Pine Script code for an indicator called 'SAM AUTO SIGNALS' that generates buy and sell signals based on RSI and moving averages. It allows users to customize parameters such as RSI period, moving average types, and visibility of signals. The script includes calculations for moving averages, RSI, and band levels, and plots the results on the chart.

Uploaded by

Aj Deshmukh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

//@version=5

indicator('SAM AUTO SIGNALS', shorttitle='SAM TRADING TIPS', overlay=true)

// Input parameters
RSI_period = input.int(10, "RSI Period", minval=1, maxval=1000)
RSI_average = input.string("SMA", "RSI Average", options=["SMA", "EMA", "WMA"])
RSI_title = input.string("close", "RSI Source", options=["open", "high", "low",
"close"])
RSI_OVB1 = input.float(50, "RSI OVB1", minval=0.01, maxval=100)
RSI_OVB2 = input.float(70, "RSI OVB2", minval=0.01, maxval=100)
RSI_OVS1 = input.float(50, "RSI OVS1", minval=0.01, maxval=100)
RSI_OVS2 = input.float(30, "RSI OVS2", minval=0.01, maxval=100)

MaFast_period = input.int(5, "Ma Fast Period", minval=1, maxval=1000)


MaFast_average = input.string("SMA", "Ma Fast Average", options=["SMA", "EMA",
"WMA"])
MaFast_title = input.string("close", "Ma Fast Source", options=["open", "high",
"low", "close"])

MaSlow_period = input.int(10, "Ma Slow Period", minval=1, maxval=1000)


MaSlow_average = input.string("EMA", "Ma Slow Average", options=["SMA", "EMA",
"WMA"])
MaSlow_title = input.string("close", "Ma Slow Source", options=["open", "high",
"low", "close"])

MaTrend_period = input.int(20, "Ma Trend Period", minval=1, maxval=1000)


MaTrend_average = input.string("EMA", "Ma Trend Average", options=["SMA", "EMA",
"WMA"])
MaTrend_title = input.string("close", "Ma Trend Source", options=["open", "high",
"low", "close"])

// Input groups for colors and visibility


colorFast = input.color(color.new(#ff56e8, 0), "Ma Fast Line Color")
widthFast = input.int(1, "Ma Fast Line Width", minval=1, maxval=5)
visibleFast = input.bool(true, "Show Ma Fast Line")

colorSlow = input.color(color.new(#2d2af7, 0), "Ma Slow Line Color")


widthSlow = input.int(2, "Ma Slow Line Width", minval=1, maxval=5)
visibleSlow = input.bool(true, "Show Ma Slow Line")

colorTrend = input.color(color.new(#f74200, 0), "Ma Trend Line Color")


widthTrend = input.int(3, "Ma Trend Line Width", minval=1, maxval=5)
visibleTrend = input.bool(true, "Show Ma Trend Line")

colorBuy = input.color(color.new(#00e676, 0), "Buy Signal Color")


visibleBuy = input.bool(true, "Show Buy Signals")

colorSell = input.color(color.new(#ff5252, 0), "Sell Signal Color")


visibleSell = input.bool(true, "Show Sell Signals")
shift = input.float(1.0, "Band Shift", minval=0.01, maxval=300, step=0.01)

// Moving Average Function


averageFunction(src, len, avgType) =>
if avgType == "SMA"
ta.sma(src, len)
else if avgType == "EMA"
ta.ema(src, len)
else
ta.wma(src, len)

// Calculating moving averages


avgFast = averageFunction(close, MaFast_period, MaFast_average)
avgSlow = averageFunction(close, MaSlow_period, MaSlow_average)
avgTrend = averageFunction(close, MaTrend_period, MaTrend_average)

// RSI Calculation
delta = ta.change(close)
up = ta.rma(math.max(delta, 0), RSI_period)
down = ta.rma(math.max(-delta, 0), RSI_period)
RS = up / down
RES = 100 - (100 / (1 + RS))

// Bands Calculation
middle = ta.sma(hlc3, MaTrend_period)
offset = ta.rma(ta.tr, MaTrend_period) * shift
upper = middle + offset
lower = middle - offset

// Buy and Sell Conditions


buyCondition1 = RES[1] < RSI_OVB1 and RES > RSI_OVB1 and close > avgFast and
avgFast > avgSlow and avgSlow > avgTrend
sellCondition1 = RES[1] > RSI_OVS1 and RES < RSI_OVS1 and close < avgFast and
avgFast < avgSlow and avgSlow < avgTrend

buyCondition2 = RES[1] < RSI_OVS2 and RES > RSI_OVS2


sellCondition2 = RES[1] > RSI_OVB2 and RES < RSI_OVB2

// Plotting Moving Averages


plot(visibleFast ? avgFast : na, title="Ma Fast", color=colorFast,
linewidth=widthFast)
plot(visibleSlow ? avgSlow : na, title="Ma Slow", color=colorSlow,
linewidth=widthSlow)
plot(visibleTrend ? avgTrend : na, title="Ma Trend", color=colorTrend,
linewidth=widthTrend)

// Plotting Bands
plot(upper, "Upper Band", color=color.new(colorTrend, 80), linewidth=1,
style=plot.style_line)
plot(lower, "Lower Band", color=color.new(colorTrend, 80), linewidth=1,
style=plot.style_line)

// Plotting Buy and Sell Signals


plotshape(series=buyCondition1 and visibleBuy, title="Buy Signal 1",
location=location.belowbar, color=colorBuy, style=shape.triangleup,
size=size.small, text="BUY")
plotshape(series=sellCondition1 and visibleSell, title="Sell Signal 1",
location=location.abovebar, color=colorSell, style=shape.triangledown,
size=size.small, text="SELL")
plotshape(series=buyCondition2 and visibleBuy, title="Buy Signal 2",
location=location.belowbar, color=colorBuy, style=shape.triangleup,
size=size.small, text="BUY")
plotshape(series=sellCondition2 and visibleSell, title="Sell Signal 2",
location=location.abovebar, color=colorSell, style=shape.triangledown,
size=size.small, text="SELL")

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy