Nayrafa AlgoTrade-vick-V3: A Comprehensive Multi-Asset Trading Strategy
January 24, 2025 | by admin

Navigating financial markets successfully requires robust strategies that adapt to different market conditions. The Nayrafa AlgoTrade-vick-V3 script offers an automated solution tailored for various assets, including cryptocurrencies, forex pairs, and equities. This strategy integrates trend-following indicators, risk management tools, and multi-timeframe analysis to provide traders with a comprehensive trading edge.
⚠ Disclaimer: No indicator or strategy guarantees profits. The Nayrafa AlgoTrade-vick-V3 should be used alongside sound trading practices and proper risk management techniques.
🛠 Key Features of the Nayrafa AlgoTrade-vick-V3 Indicator
📊 Multi-Asset Compatibility:
- Supports a wide range of assets, including BTC/USDT, ETH/USDT, stocks like TSLA, AAPL, and forex pairs.
- Optimized settings for different market conditions and timeframes.
📈 Supertrend-Based Trading Logic:
- Implements a Supertrend indicator with dynamic ATR-based stop levels.
- Provides entry and exit points based on trend reversals and volatility conditions.
🕒 Timeframe Optimization:
- Designed for scalping (5m, 15m), day trading (30m, 1H), and swing trading (4H, daily) to fit various trading styles.
🎯 Take Profit and Stop Loss Levels:
- Multiple take profit (TP1, TP2, TP3, TP4) and stop loss options available.
- Customizable ATR and percentage-based exit strategies.
📌 Support and Resistance Zones:
- Automatically detects market reaction areas based on price pivots.
- Helps traders identify crucial zones for entry and exit decisions.
🔔 Real-Time Alerts:
- Integrated with TradingView alerts for buy/sell signals.
- Telegram and webhook notifications available for automated trading.
📈 Multi-Timeframe Analysis (MTF):
- Tracks price action across 15m, 30m, 1H, and 4H charts for comprehensive analysis.
- Provides an overall market outlook before entering trades.
⚡ Dynamic Trend Detection:
- Leverages Bollinger Bands and RSI filtering to identify sideways and trending markets.
- Reduces false signals by filtering out low-probability trades.
💼 Risk Management Options:
- Adjustable leverage and position sizing for futures trading.
- Built-in dynamic SL feature for minimizing drawdowns.
🔍 Script Evaluation
Functionality: 4.5/5
A well-rounded strategy covering multiple aspects of trading, from trend analysis to position management.
Ease of Use: 4.0/5
Complex customization options might require learning for beginners.
Accuracy: 4.3/5
Effective in trending markets but may require additional filters in sideways conditions.
Repainting Analysis:
After a thorough review, the script does not repaint. It uses confirmed price data and ATR-based levels, making it suitable for live trading and backtesting.
Optimal Timeframes:
- Scalping: 5m – 15m
- Day Trading: 30m – 1H
- Swing Trading: 4H – Daily
Overall Score: 4.4/5
An excellent choice for traders seeking an adaptable and automated trading strategy.
//@version=5
strategy('Nayrafa_AlgoTrade-vick-V3', overlay=true, default_qty_type=strategy.cash, default_qty_value=10000, initial_capital=10000, currency='USD', commission_type=strategy.commission.percent, commission_value=0, max_bars_back=3000, max_lines_count=100, calc_on_every_tick=false, max_labels_count=100)
//User has to agree to have the indi loading on the chart.
var user_consensus = input.string(defval="939325", title="Please enter code", confirm = true, group="CODE")
var icc = false
if user_consensus == "939325"
icc := true
else
icc := false
var initialcapital = strategy.equity
// ------------------------------------------
asset = input.string(title = "Strategies", defval = " ### Dev Mode (FREE SETTING sensitivity AND offset) ### ", options=[" ### Dev Mode (FREE SETTING sensitivity AND offset) ### ",
" ",
"BTC/D - 15m | Mid-Term",
"ETH/USDT - 15m | Short-Term",
"BTC/USDT - 30m | Mid-Term",
"BTC/USDT - 1h | Long-Term",
"BTC/USDT - 15m | Short-Term",
"QTUM/USDT - 15m | Short-Term",
"ZIL/USDT - 30m | Mid-Term",
"ZIL/USDT - 15m | Short-Term",
"AUDIO/USDT - 15m | Short-Term",
"AXS/USDT - 15m | Short-Term",
"BAND/USDT - 30m | Mid-Term",
"BAND/USDT - 15m | Short-Term",
"TRX/USDT - 30m | Mid-Term" ,
"OP/USDT - 15m | Short-Term",
"OP/USDT - 30m | Mid-Term",
"APE/USDT - 15m | Short-Term",
"APE/USDT - 30m | Mid-Term",
"ENS/USDT - 15m | Short-Term",
"BAKE/USDT - 30m | Mid-Term",
"CELR/USDT - 30m | Mid-Term",
"1000PEPE/USDT - 15m | Short-Term",
"1000SHIB/USDT - 45m | Mid-Term",
"CHR/USDT - 15m | Short-Term",
"CHR/USDT - 45m | Mid-Term",
"HNT/USDT - 15m | Short-Term",
"BLZ/USDT - 15m | Short-Term",
"EGLD/USDT - 15m | Short-Term",
"KAVA/USDT - 15m | Short-Term",
"ZEN/USDT - 15m | Short-Term",
"FLOW/USDT - 30m | Mid-Term",
"YFI/USDT - 15m | Short-Term",
"LDO/USDT - 15m | Short-Term",
"MATIC/USDT - 15m | Short-Term",
"ANKR/USDT - 15m | Mid-Term",
"TOMO/USDT - 15m | Short-Term",
"DOT/USDT - 15m | Short-Term",
"DASH/USDT - 30m | Mid-Term",
"JASMY/USDT - 15m | Short-Term",
"WOO/USDT - 15m | Short-Term",
"SUSHI/USDT - 30m | Mid-Term",
"SUSHI/USDT - 15m | Short-Term",
"NEAR/USDT - 30m | Mid-Term",
"SKL/USDT - 15m | Short-Term",
"UNFI/USDT - 15m | Short-Term",
"FTM/USDT - 15m | Short-Term",
"SFP/USDT - 15m | Short-Term",
'BNB/USDT - 30m | Mid-Term',
'AUD/EUR - 15m | Short-Term',
'CAD/JPY - 15m | Short-Term',
'TSLA/TESLA - 15m | Short-Term',
'AAPL/APLE - 15m | Short-Term',
'AAPL/APLE - 5m | Short-Term',
'TSLA/TESLA - 5m | Short-Term',
'GOOG/GOOGLE - 15m | Short-Term',
'SILVER/XAGUSD - 15m | Short-Term',
'PLATINUM - 15m | Short-Term',
'XAU/USD - 15m | Mid-Term',
'AUD/EUR - 30m | Mid-Term',
'XAU/USD - 30m | Mid-Term',
'CHF/JPY - 15m | Short-Term',
'USD/JPY - 15m | Short-Term',
'USD/CAD - 15m | Short-Term',
'GBP/USD - 15m | Short-Term',
'EUR/USD - 15m | Short-Term',
'AUD/USD - 15m | Short-Term',
'GBP/JPY - 15m | Short-Term'
])
//Supertrend Indicator
amplitude = input(title='Amplitude', defval=45, group = "Trendline")
channelDeviation = input(title='Channel Deviation', defval=2, group = "Trendline")
showArrows = input(title='Show Arrows', defval=true, group = "Trendline")
showChannels = input(title='Show Channels', defval=false, group = "Trendline")
tpLevel = input.int(title='Take Profit Level', defval=1, minval=1, maxval=4, group = "Trendline")
slLevel = input.int(title='Stop Loss Level', defval=1, minval=1, maxval=4, group = "Trendline")
var int trend2 = 0
var int nextTrend = 0
var float maxLowPrice = nz(low[1], low)
var float minHighPrice = nz(high[1], high)
var float up2 = 0.0
var float down = 0.0
float atrHigh = 0.0
float atrLow = 0.0
float arrowUp = na
float arrowDown = na
atr3 = ta.atr(100) / 2
dev = channelDeviation * atr3
highPrice = high[math.abs(ta.highestbars(amplitude))]
lowPrice = low[math.abs(ta.lowestbars(amplitude))]
highma = ta.sma(high, amplitude)
lowma = ta.sma(low, amplitude)
if nextTrend == 1
maxLowPrice := math.max(lowPrice, maxLowPrice)
if highma < maxLowPrice and close < nz(low[1], low)
trend2 := 1
nextTrend := 0
minHighPrice := highPrice
minHighPrice
else
minHighPrice := math.min(highPrice, minHighPrice)
if lowma > minHighPrice and close > nz(high[1], high)
trend2 := 0
nextTrend := 1
maxLowPrice := lowPrice
maxLowPrice
if trend2 == 0
if not na(trend2[1]) and trend2[1] != 0
up2 := na(down[1]) ? down : down[1]
arrowUp := up2 - atr3
arrowUp
else
up2 := na(up2[1]) ? maxLowPrice : math.max(maxLowPrice, up2[1])
up2
atrHigh := up2 + dev
atrLow := up2 - dev
atrLow
else
if not na(trend2[1]) and trend2[1] != 1
down := na(up2[1]) ? up2 : up2[1]
arrowDown := down + atr3
arrowDown
else
down := na(down[1]) ? minHighPrice : math.min(minHighPrice, down[1])
down
atrHigh := down + dev
atrLow := down - dev
atrLow
ht = trend2 == 0 ? up2 : down
var color buyColor = color.green
var color sellColor = color.red
htColor = trend2 == 0 ? buyColor : sellColor
htPlot = plot(ht, title='Ashish indicator', linewidth=2, color=htColor)
atrHighPlot = plot(showChannels ? atrHigh : na, title='ATR High', style=plot.style_circles, color=color.new(sellColor, 0))
atrLowPlot = plot(showChannels ? atrLow : na, title='ATR Low', style=plot.style_circles, color=color.new(buyColor, 0))
fill(htPlot, atrHighPlot, title='ATR High Ribbon', color=color.new(sellColor, 90))
fill(htPlot, atrLowPlot, title='ATR Low Ribbon', color=color.new(buyColor, 90))
buySignal = not na(arrowUp) and trend2 == 0 and trend2[1] == 1
sellSignal = not na(arrowDown) and trend2 == 1 and trend2[1] == 0
plotshape(showArrows and buySignal ? atrLow : na, title='Trend UP', style=shape.triangleup, location=location.belowbar, size=size.tiny, color=color.new(buyColor, 0))
plotshape(showArrows and sellSignal ? atrHigh : na, title='Trend Down', style=shape.triangledown, location=location.abovebar, size=size.tiny, color=color.new(sellColor, 0))
notes = input('',title='Your_notesâ',inline='set00')
//tf = input(200, title='DC Period')
//mult15 = input.float(1.0, minval=0.001, maxval=10, step=0.2, title='DC Mult')
//Truncate Function
truncate(number, decimals) =>
factor = math.pow(10, decimals)
int(number * factor) / factor
//=======================================================================================
// Trade Time
daysback = input(30, title='Backtest Days, For Defining Best TF, Max: 60 Days')
millisecondinxdays = 1000 * 60 * 60 * 24 * daysback
leftbar = timenow - time < millisecondinxdays
backtest = leftbar
dpa = 8
//=======================================================================================
et1 = 'Supertrend'
longside = input.bool(true, title='Long Side', group='Strategy Option')
shortside = input.bool(true, title='Short Side', group='Strategy Option')
filter1 = 'Filter with Atr'
filter2 = 'Filter with RSI'
filter3 = 'Atr or RSI'
filter4 = 'Atr and RSI'
filter5 = 'No Filtering'
filter6 = 'Entry Only in flat market(By ATR or RSI)'
filter7 = 'Entry Only in flat market(By ATR and RSI)'
typefilter = input.string(filter5, title='Flat Filtering Input', options=[filter1, filter2, filter3, filter4, filter5, filter6, filter7], group='Strategy Options')
withsl = input.bool(false, title='Use Dynamic SL?', group='Strategy Options')
RSI = truncate(ta.rsi(close, input.int(7, group='RSI Filterring')), 2)
BBperiod = input.int(100,minval=1,title='Sensitivity',inline='set1', group='RSI Filterring')
BBdeviations = input.float(1.5,step=0.01,minval=0.01,title='Offsetâ',inline='set1', group='RSI Filterring')
if asset == 'BTC/D - 15m | Mid-Term'
BBperiod := 150
BBdeviations := 3.1
if asset == 'ETH/USDT - 15m | Short-Term'
BBperiod := 300
BBdeviations := 2
if asset == 'BTC/USDT - 30m | Mid-Term'
BBperiod := 300
BBdeviations := 2.5
if asset == 'BTC/USDT - 1h | Long-Term'
BBperiod := 180
BBdeviations := 1
if asset == 'BTC/USDT - 15m | Short-Term'
BBperiod := 150
BBdeviations := 3.1
if asset == 'QTUM/USDT - 30m |Short-Term'
BBperiod := 196
BBdeviations := 1
if asset == 'ZIL/USDT - 30m | Mid-Term'
BBperiod := 140
BBdeviations := 1.5
if asset == 'ZIL/USDT - 15m | Short-Term'
BBperiod := 150
BBdeviations := 3.5
if asset == 'AUDIO/USDT - 15m | Short-Term'
BBperiod := 320
BBdeviations := 2
if asset == 'AXS/USDT - 15m | Short-Term'
BBperiod := 300
BBdeviations := 3
if asset == 'BAND/USDT - 30m | Mid-Term'
BBperiod := 300
BBdeviations := 2
if asset == 'BAND/USDT - 15m | Short-Term'
BBperiod := 300
BBdeviations := 2
if asset == 'TRX/USDT - 30m | Mid-Term'
BBperiod := 200
BBdeviations := 2
if asset == 'OP/USDT - 15m | Short-Term'
BBperiod := 170
BBdeviations := 2.8
if asset == 'OP/USDT - 30m | Mid-Term'
BBperiod := 170
BBdeviations := 2.3
if asset == 'APE/USDT - 15m | Short-Term'
BBperiod := 120
BBdeviations := 1.8
if asset == 'APE/USDT - 30m | Mid-Term'
BBperiod := 170
BBdeviations := 2.3
if asset == 'ENS/USDT - 15m | Short-Term'
BBperiod := 170
BBdeviations := 3.3
if asset == 'BAKE/USDT - 30m | Mid-Term'
BBperiod := 100
BBdeviations := 2.6
if asset == 'CELR/USDT - 30m | Mid-Term'
BBperiod := 200
BBdeviations := 0.8
if asset == '1000PEPE/USDT - 15m | Short-Term'
BBperiod := 60
BBdeviations := 2
if asset == '1000SHIB/USDT - 45m | Mid-Term'
BBperiod := 50
BBdeviations := 3
if asset == 'CHR/USDT - 15m | Short-Term'
BBperiod := 50
BBdeviations := 3
if asset == 'CHR/USDT - 45m | Mid-Term'
BBperiod := 50
BBdeviations := 3
if asset == 'HNT/USDT - 15m | Short-Term'
BBperiod := 300
BBdeviations := 2
if asset == 'BLZ/USDT - 15m | Short-Term'
BBperiod := 190
BBdeviations := 1
if asset == 'EGLD/USDT - 15m | Short-Term'
BBperiod := 200
BBdeviations := 3
if asset == 'KAVA/USDT - 15m | Short-Term'
BBperiod := 200
BBdeviations := 2
if asset == 'ZEN/USDT - 15m | Short-Term'
BBperiod := 200
BBdeviations := 2
if asset == 'FLOW/USDT - 30m | Mid-Term'
BBperiod := 20
BBdeviations := 3
if asset == 'YFI/USDT - 15m | Short-Term'
BBperiod := 40
BBdeviations := 3
if asset == 'LDO/USDT - 15m | Short-Term'
BBperiod := 200
BBdeviations := 2
if asset == 'MATIC/USDT - 15m | Short-Term'
BBperiod := 200
BBdeviations := 2.5
if asset == 'ANKR/USDT - 15m | Short-Term'
BBperiod := 20
BBdeviations := 3
if asset == 'TOMO/USDT - 15m | Short-Term'
BBperiod := 20
BBdeviations := 3
if asset == 'DOT/USDT - 15m | Short-Term'
BBperiod := 20
BBdeviations := 2.5
if asset == 'DASH/USDT - 30m | Mid-Term'
BBperiod := 200
BBdeviations := 1
if asset == 'JASMY/USDT - 15m | Short-Term'
BBperiod := 60
BBdeviations := 2
if asset == 'WOO/USDT - 15m | Short-Term'
BBperiod := 40
BBdeviations := 3
if asset == 'SUSHI/USDT - 30m | Mid-Term'
BBperiod := 40
BBdeviations := 2
if asset == 'SUSHI/USDT - 15m | Short-Term'
BBperiod := 40
BBdeviations := 2
if asset == 'NEAR/USDT - 30m | Mid-Term'
BBperiod := 60
BBdeviations := 2
if asset == 'SKL/USDT - 15m | Short-Term'
BBperiod := 200
BBdeviations := 2
if asset == 'UNFI/USDT - 15m | Short-Term'
BBperiod := 180
BBdeviations := 2
if asset == 'FTM/USDT - 15m | Short-Term'
BBperiod := 80
BBdeviations := 2.2
if asset == 'SFP/USDT - 15m | Short-Term'
BBperiod := 150
BBdeviations := 2
if asset == 'BNB/USDT - 30m | Mid-Term'
BBperiod := 90
BBdeviations := 2.4
if asset == 'AUD/EUR - 15m | Short-Term'
BBperiod := 90
BBdeviations := 2.4
if asset == 'CAD/JPY - 15m | Short-Term'
BBperiod := 110
BBdeviations := 2
if asset == 'TSLA/TESLA - 15m | Short-Term'
BBperiod := 60
BBdeviations := 0.8
if asset == 'AAPL/APLE - 15m | Short-Term'
BBperiod := 70
BBdeviations := 0.3
if asset == 'AAPL/APLE - 5m | Short-Term'
BBperiod := 210
BBdeviations := 1
if asset == 'TSLA/TESLA - 5m | Short-Term'
BBperiod := 35
BBdeviations := 2.5
if asset == 'GOOG/GOOGLE - 15m | Short-Term'
BBperiod := 90
BBdeviations := 1.5
if asset == 'SILVER/XAGUSD - 15m | Short-Term'
BBperiod := 90
BBdeviations := 1.5
if asset == 'PLATINUM - 15m | Short-Term'
BBperiod := 90
BBdeviations := 1.5
if asset == 'XAU/USD - 15m | Mid-Term'
BBperiod := 20
BBdeviations := 3
if asset == 'AUD/EUR - 30m | Mid-Term'
BBperiod := 120
BBdeviations := 1.8
if asset == 'XAU/USD - 30m | Mid-Term'
BBperiod := 250
BBdeviations := 2
if asset == 'CHF/JPY - 15m | Short-Term'
BBperiod := 300
BBdeviations := 1.5
if asset == 'USD/JPY - 15m | Short-Term'
BBperiod := 50
BBdeviations := 2.5
if asset == 'USD/CAD - 15m | Short-Term'
BBperiod := 100
BBdeviations := 2.6
if asset == 'GBP/USD - 15m | Short-Term'
BBperiod := 80
BBdeviations := 3
if asset == 'EUR/USD - 15m | Short-Term'
BBperiod := 200
BBdeviations := 2
if asset == 'AUD/USD - 15m | Short-Term'
BBperiod := 400
BBdeviations := 1.5
if asset == 'GBP/JPY - 15m | Short-Term'
BBperiod := 100
BBdeviations := 2
toplimitrsi = input.int(45, title='TOP Limit', group='RSI Filterring')
botlimitrsi = input.int(10, title='BOT Limit', group='RSI Filterring')
// Support & Resistance
enableSR = input(true, "SUPPORT & RESISTANCE ON/Off", group="SUPPORT & RESISTANCE")
colorSup = input(#00ff7791, "SUPPORT", group="SUPPORT & RESISTANCE")
colorRes = input(#e91e1e9a, "RESISTANCE", group="SUPPORT & RESISTANCE")
strengthSR = input.int(6, "S/R STRENGTH", 1, group="SUPPORT & RESISTANCE")
lineStyle1 = input.string("Solid", "LINE STYLE", ["Solid", "Dotted", "Dashed"], group="SUPPORT & RESISTANCE")
lineWidth1 = input.int(2, "LINE WIDTH", 1, group="SUPPORT & RESISTANCE")
expandSR = input(true, "EXTEND LINES", group = "SUPPORT & RESISTANCE")
useZones = input(true, "ZONE ON/OFF", group="SUPPORT & RESISTANCE")
useHLZones = input(true, "HIGH LOW ZONES ON/OFF", group="SUPPORT & RESISTANCE")
zoneWidth = input.int(4, "ZONE WIDTH %", 0, tooltip="it's calculated using % of the distance between highest/lowest in last 300 bars", group="SUPPORT & RESISTANCE")
//===================================================================
//===================================================================
// TP SL Option
ex1 = 'TP & SL by Percentage Price'
ex2 = 'TP & SL by atr Value'
et = input.string(ex2, title='TP SL Type', options=[ex1, ex2], group='Strategy Options')
ST = false
period = 15
mult = 5
atrLen = input.int(5, minval=1, title='atr Length', group='Sideways Filtering Input')
atrMaType = input.string('EMA', options=['SMA', 'EMA'], group='Sideways Filtering Input', title='atr Moving Average Type')
atrMaLen = input.int(5, minval=1, title='atr MA Length', group='Sideways Filtering Input')
adxLen = input.float(5, minval = 1, maxval = 50, title = "ADX SMOOTHing", group='Sideways Filtering Input')
diLen = input.float(14, minval = 1, title = "DI Length", group='Sideways Filtering Input')
adxLim = input.float(22, minval = 1, title = "ADX Limit", group='Sideways Filtering Input')
SMOOTH = input.float(3, minval = 1, maxval = 5, title = "SMOOTHing Factor", group='Sideways Filtering Input')
lag = input.float(8, minval = 0, maxval = 15, title = "Lag", group='Sideways Filtering Input')
TP1 = input.float(1.5, title='TP1 Multiplier', group='TP/SL by ATR')
TP2 = input.int(3, title='TP2 Multiplier', group='TP/SL by ATR')
TP3 = input.int(5, title='TP3 Multiplier', group='TP/SL by ATR')
TP4 = input.float(title='TP 4 Multiplier', minval=0.0, step=0.1, defval=9, group='TP/SL by ATR')
SL = input.int(6, title='SL Atr Multiplier', group='TP/SL by ATR')
ptp1 = input.float(2, title='Take Profit 1 (%)', minval=0.0, step=0.1, defval=3, group='TP/SL Percentage Price') * 0.01
ptp2 = input.float(4, title='Take Profit 2 (%)', minval=0.0, step=0.1, defval=5, group='TP/SL Percentage Price') * 0.01
ptp3 = input.float(6, title='Take Profit 3 (%)', minval=0.0, step=0.1, defval=7, group='TP/SL Percentage Price') * 0.01
ptp4 = input.float(12, title='Take Profit 4 (%)', minval=0.0, step=0.1, defval=8, group='TP/SL Percentage Price') * 0.01
psl = input.float(3, title='StopLoss (%)', minval=0.0, step=0.1, defval=2) * 0.01
qtytp1 = input.int(30, title='QTY TP 1', group='Qty for TP')
qtytp2 = input.int(30, title='QTY TP 2', group='Qty for TP')
qtytp3 = input.int(30, title='QTY TP 3', group='Qty for TP')
qtytp4 = input.int(10, title='QTY TP 4', group='Qty for TP')
Qtytp1 = qtytp1 / 100
Qtytp2 = qtytp2 / 100
Qtytp3 = qtytp3 / 100
Qtytp4 = qtytp4 / 100
///
//===================================================================
//===================================================================
//Timeframe
//Supertrend Indicator
src = hl2
atr2 = ta.sma(ta.tr, period)
atr = request.security(syminfo.ticker, '', ta.atr(period))
up = src - mult * atr
up1 = nz(up[1], up)
up := close[1] > up1 ? math.max(up, up1) : up
dn = src + mult * atr
dn1 = nz(dn[1], dn)
dn := close[1] < dn1 ? math.min(dn, dn1) : dn
trend = 1
trend := nz(trend[1], trend)
trend := trend == -1 and close > dn1 ? 1 : trend == 1 and close < up1 ? -1 : trend
st = trend == 1 ? up : dn
//Buy-Sell Indicator
BBUpper = ta.sma(close,BBperiod)+ta.stdev(close,BBperiod)*BBdeviations
BBLower = ta.sma(close,BBperiod)-ta.stdev(close,BBperiod)*BBdeviations
oc2 = (close+open)/2
UP_trend = close>BBUpper and oc2>BBUpper
DN_trend = close<BBLower and oc2<BBLower
FLAT = close<BBUpper and close>BBLower
//TrendLine = ta.sma(ohlc4,BBperiod)
//plot(TrendLine, color=UP_trend ? color.new(color.green,0) : DN_trend ? color.new(color.red,0) : color.new(color.gray,0) ,style=plot.style_line,linewidth=3, title="Trend Line")
//p1 = plot(BBUpper, color=color.lime ,style=plot.style_line,linewidth=1, title="Trend Line")
//p2 = plot(BBLower, color=color.red ,style=plot.style_line,linewidth=1, title="Trend Line")
//fill(p1,p2,color=UP_trend ? color.new(color.green,50) : DN_trend ? color.new(color.red,50) : color.new(color.gray,50))
UseATRfilter = false
ATR1period = 5
hl = false
//
//
TrendLine = 0.0
iTrend = 0.0
long_final = 0.0
short_final = 0.0
//
BBSignal = close > BBUpper ? 1 : close < BBLower ? -1 : 0
//
if BBSignal == 1 and UseATRfilter == 1
TrendLine := low - ta.atr(ATR1period)
if TrendLine < TrendLine[1]
TrendLine := TrendLine[1]
TrendLine
if BBSignal == -1 and UseATRfilter == 1
TrendLine := high + ta.atr(ATR1period)
if TrendLine > TrendLine[1]
TrendLine := TrendLine[1]
TrendLine
if BBSignal == 0 and UseATRfilter == 1
TrendLine := TrendLine[1]
TrendLine
//
if BBSignal == 1 and UseATRfilter == 0
TrendLine := low
if TrendLine < TrendLine[1]
TrendLine := TrendLine[1]
TrendLine
if BBSignal == -1 and UseATRfilter == 0
TrendLine := high
if TrendLine > TrendLine[1]
TrendLine := TrendLine[1]
TrendLine
if BBSignal == 0 and UseATRfilter == 0
TrendLine := TrendLine[1]
TrendLine
//
iTrend := iTrend[1]
if TrendLine > TrendLine[1]
iTrend := 1
iTrend
if TrendLine < TrendLine[1]
iTrend := -1
iTrend
//
long_final := iTrend[1] == -1 and iTrend == 1 ? 1 : na
short_final := iTrend[1] == 1 and iTrend == -1 ? 1 : na
//
//plot(TrendLine, color=iTrend > 0 ? color.green : color.red, style=plot.style_line, linewidth=3, title='Trend Line', transp=0)
i_entryPriceSrc = input.source(title='Entry Price Calculation Src', defval=ohlc4, group='?? Risk Reward Ratio ??')
//filtering
atra = request.security(syminfo.tickerid, '', ta.atr(atrLen))
atrMa = atrMaType == 'EM' ? ta.ema(atra, atrMaLen) : ta.sma(atra, atrMaLen)
updm = ta.change(high)
downdm = -ta.change(low)
plusdm = na(updm) ? na : updm > downdm and updm > 0 ? updm : 0
minusdm = na(downdm) ? na : downdm > updm and downdm > 0 ? downdm : 0
//trur = rma(tr, diLen)
//plus = fixnan(100 * rma(plusdm, diLen) / trur)
//minus = fixnan(100 * rma(minusdm, diLen) / trur)
//sum = plus + minus
//adx = 100 * rma(abs(plus - minus) / (sum == 0 ? 1 : sum), adxLen)
cndSidwayss1 = atra >= atrMa
cndSidwayss2 = RSI > toplimitrsi or RSI < botlimitrsi
cndSidways = cndSidwayss1 or cndSidwayss2
cndSidways1 = cndSidwayss1 and cndSidwayss2
Sidwayss1 = atra <= atrMa
Sidwayss2 = RSI < toplimitrsi and RSI > botlimitrsi
Sidways = Sidwayss1 or Sidwayss2
Sidways1 = Sidwayss1 and Sidwayss2
trendType = typefilter == filter1 ? cndSidwayss1 : typefilter == filter2 ? cndSidwayss2 : typefilter == filter3 ? cndSidways : typefilter == filter4 ? cndSidways1 : typefilter == filter5 ? RSI > 0 : typefilter == filter6 ? Sidways : typefilter == filter7 ? Sidways1 : na
// Conditions
//buysignal1 = bool(na)
//sellsignal1 = bool(na)
//buysignal1 = ta.crossover(z, 100)
//sellsignal1 = ta.crossunder(z, -100)
// Entry FIX
//buysignal1 = ta.crossover(close, st)
//sellsignal1 = ta.crossunder(close, st)
buy = long_final and longside and backtest and trendType
sell = short_final and shortside and backtest and trendType
showZones = input(true, title='Show Bullish/Bearish Zones')
ruleState = 0
ruleState := buy ? 1 : sell ? -1 : nz(ruleState[1])
bgcolor(showZones ? ruleState == 1 ? color.rgb(116, 239, 143, 66) : ruleState == -1 ? color.rgb(255, 82, 82, 67) : color.gray : na, title=' Bullish/Bearish Zones', transp=90)
//bgcolor(buy ? color.blue : sell ? color.red : na, transp=80)
plotshape(buy, style=shape.labelup, location=location.belowbar, color=color.new(color.blue, 0), size=size.tiny, title='buy label', text='BUY', textcolor=color.new(color.white, 0))
plotshape(sell, style=shape.labeldown, location=location.abovebar, color=color.new(color.red, 0), size=size.tiny, title='sell label', text='SELL', textcolor=color.new(color.white, 0))
plotshape(buy == 1 and hl == false ? TrendLine - ta.atr(8) : na, text='Get ready to long', style=shape.labelup, location=location.absolute, color=color.new(color.green, 0), textcolor=color.new(color.white, 0), offset=0, size=size.auto, show_last = 2)
plotshape(sell == 1 and hl == false ? TrendLine + ta.atr(8) : na, text='Get ready to short', style=shape.labeldown, location=location.absolute, color=color.new(color.red, 0), textcolor=color.new(color.white, 0), offset=0, size=size.auto, show_last = 2)
use_atr = input.bool(true, title='ATR OR STDEV', group='TP/SL by ATR')
sl_trendline = input.bool(false, title='SL = TRENDLINE', group='TP/SL by ATR')
stdev = input.int(28, minval = 1, maxval = 50, title = "STDEV TP PERIOD", group='TP/SL by ATR')
atrper = input.int(14, minval = 1, maxval = 50, title = "ATR TP AND SL PERIOD", group='TP/SL by ATR')
//Tp & Sl by atr Mult
ratr = use_atr ? ta.valuewhen(buy, ta.atr(atrper), 0) : ta.valuewhen(buy, ta.stdev(close,stdev), 0)
ratrs = use_atr ? ta.valuewhen(buy, ta.atr(atrper), 0) : ta.valuewhen(buy, ta.stdev(close,stdev), 0)
cb = ta.valuewhen(buy, close, 0)
//if (use_atr)
// ratr := ta.valuewhen(buy, ta.atr(14), 0)
//else
//ratr := ta.valuewhen(buy, ta.stdev(close,14), 0)
tpb1 = cb + ratr * TP1
tpb2 = cb + ratr * TP2
tpb3 = cb + ratr * TP3
tpb4 = cb + ratr * TP4
slb = sl_trendline ? TrendLine : cb - ta.valuewhen(buy, ta.atr(atrper), 0) * SL //withsl?up:valuewhen(buy, up,0)
cs = ta.valuewhen(sell, close, 0)
tps1 = cs - ratrs * TP1
tps2 = cs - ratrs * TP2
tps3 = cs - ratrs * TP3
tps4 = cs - ratrs * TP4
sls = sl_trendline ? TrendLine : cs + ta.valuewhen(buy, ta.atr(atrper), 0) * SL //withsl?dn:valuewhen(sell, dn, 0)
Ptpb1 = cb * (1 + ptp1)
Ptpb2 = cb * (1 + ptp2)
Ptpb3 = cb * (1 + ptp3)
Ptpb4 = et == ex1 ? cb * (1 + ptp4) : tpb4
Pslb = cb * (1 - psl)
Ptps1 = cs * (1 - ptp1)
Ptps2 = cs * (1 - ptp2)
Ptps3 = cs * (1 - ptp3)
Ptps4 = et == ex1 ? cs * (1 - ptp4) : tps4
Psls = cs * (1 + psl)
//Variable Fix TP SL
tpb1t = et == ex1 ? Ptpb1 : tpb1
tpb2t = et == ex1 ? Ptpb2 : tpb2
tpb3t = et == ex1 ? Ptpb3 : tpb3
tpb4t = Ptpb4
slbt = et == ex1 ? Pslb : slb
tps1t = et == ex1 ? Ptps1 : tps1
tps2t = et == ex1 ? Ptps2 : tps2
tps3t = et == ex1 ? Ptps3 : tps3
tps4t = Ptps4
slst = et == ex1 ? Psls : sls
//===================================================================
//Input Zignaly Settings
z1 = 'Copy trading / Profit Sharing'
z2 = 'Signal Providing'
z3 = 'Telegram Notification'
ZZ = input.string(z3, title='BOT Type', options=[z1, z2, z3], group='Zignaly Settings')
P1 = 'Pair 1'
P2 = 'Pair 2'
P3 = 'Pair 3'
pair = input.string(defval=P1, title='Pair Trade', options=[P1, P2, P3], group='Zignaly Settings')
apikey = input.string('xxx', title='Api Key / WebHook', group='Zignaly Settings')
margin = input.int(10, title='Margin % (Use it Only if you use copytrading or profit sharing)', group='Zignaly Settings')
lev = input.int(30, group='Zignaly Settings')
qty = margin / close
slbm = et == ex1 ? Psls : slb
slsm = et == ex1 ? Psls : sls
slbmessage = '","stopLossPriority":"price","stopLossPrice":"' + str.tostring(slbm)
slsmessage = '","stopLossPriority":"price","stopLossPrice":"' + str.tostring(slsm)
// Zignaly Settings
pair1 = input.string('btcusdt', group='Pair & Signalid, Küçük Harf İle')
signal1 = input.string('btc', group='Pair & Signalid, Küçük Harf İle')
pair2 = input.string('ethusdt', group='Pair & Signalid, Küçük Harf İle')
signal2 = input.string('eth', group='Pair & Signalid, Küçük Harf İle')
pair3 = input.string('xxxusdt', group='Pair & Signalid, Küçük Harf İle')
signal3 = input.string('xxx', group='Pair & Signalid, Küçük Harf İle')
PAIR = pair == P1 ? pair1 : pair == P2 ? pair2 : pair3
signal = pair == P1 ? signal1 : pair == P2 ? signal2 : signal3
//alert command, copytrader/profitsharing
longct = '{"key":"' + str.tostring(apikey) + '","type":"reverse","exchange":"binance","exchangeAccountType":"futures","pair":"' + str.tostring(PAIR) + '","exitOrderType":"market","entryOrderType":"market","exitSide":"short","entrySide":"long","entryLeverage":"' + str.tostring(lev) + str.tostring(slbmessage) + '","takeProfitPriority":"price","takeProfitAmountPercentage1":"' + str.tostring(qtytp1) + '","takeProfitPrice1":"' + str.tostring(tpb1t) + '","takeProfitAmountPercentage2":"' + str.tostring(qtytp2) + '","takeProfitPrice2":"' + str.tostring(tpb2t) + '","takeProfitAmountPercentage3":"' + str.tostring(qtytp3) + '","takeProfitPrice3":"' + str.tostring(tpb3t) + '","takeProfitAmountPercentage4":"' + str.tostring(qtytp4) + '","takeProfitPrice4":"' + str.tostring(tpb4t) + '","positionSizePercentage":"' + str.tostring(margin) + '","signalId":"' + str.tostring(signal) + '"}'
shortct = '{"key":"' + str.tostring(apikey) + '","type":"reverse","exchange":"binance","exchangeAccountType":"futures","pair":"' + str.tostring(PAIR) + '","exitOrderType":"market","entryOrderType":"market","exitSide":"long","entrySide":"short","entryLeverage":"' + str.tostring(lev) + str.tostring(slsmessage) + '","takeProfitPriority":"price","takeProfitAmountPercentage1":"' + str.tostring(qtytp1) + '","takeProfitPrice1":"' + str.tostring(tps1t) + '","takeProfitAmountPercentage2":"' + str.tostring(qtytp2) + '","takeProfitPrice2":"' + str.tostring(tps2t) + '","takeProfitAmountPercentage3":"' + str.tostring(qtytp3) + '","takeProfitPrice3":"' + str.tostring(tps3t) + '","takeProfitAmountPercentage4":"' + str.tostring(qtytp4) + '","takeProfitPrice4":"' + str.tostring(tps4t) + '","positionSizePercentage":"' + str.tostring(margin) + '","signalId":"' + str.tostring(signal) + '"}'
slcommand = '{"key":"' + str.tostring(apikey) + '","pair":"' + str.tostring(PAIR) + '","exchange":"binance","exchangeAccountType":"futures","type":"exit","signalId":"' + str.tostring(signal) + '"}'
//signal provider
tpb1tsp = et == ex1 ? ptp1 * 100 : truncate((tpb1 - cb) * 100 / cb, 2)
tpb2tsp = et == ex1 ? ptp2 * 100 : truncate((tpb2 - cb) * 100 / cb, 2)
tpb3tsp = et == ex1 ? ptp3 * 100 : truncate((tpb3 - cb) * 100 / cb, 2)
tpb4tsp = ptp4 * 100
slbtsp = truncate((cb - slb) * 100 / cb, 2)
tps1tsp = et == ex1 ? ptp1 * 100 : truncate((cs - tps1) * 100 / cs, 2)
tps2tsp = et == ex1 ? ptp2 * 100 : truncate((cs - tps2) * 100 / cs, 2)
tps3tsp = et == ex1 ? ptp3 * 100 : truncate((cs - tps3) * 100 / cs, 2)
tps4tsp = ptp4 * 100
slstsp = truncate((sls - cs) * 100 / cs, 2)
slbmsp = et == ex1 ? psl * 100 : slbtsp
slsmsp = et == ex1 ? psl * 100 : slstsp
slbmessagesp = '","stopLossPercentage":"-' + str.tostring(slbmsp)
slsmessagesp = '","stopLossPercentage":"-' + str.tostring(slsmsp)
longsp = '{"key":"' + str.tostring(apikey) + '","type":"reverse","exchange":"binance","exchangeAccountType":"futures","pair":"' + str.tostring(PAIR) + '","exitOrderType":"market","entryOrderType":"limit","exitSide":"short","entrySide":"long","entryLimitPrice":"' + str.tostring(cb) + '","entryLeverage":"\n' + str.tostring(lev) + str.tostring(slbmessagesp) + '","takeProfitAmountPercentage1":"' + str.tostring(qtytp1) + '","takeProfitPercentage1":"' + str.tostring(tpb1tsp) + '","takeProfitAmountPercentage2":"' + str.tostring(qtytp2) + '","takeProfitPercentage2":"' + str.tostring(tpb2tsp) + '","takeProfitAmountPercentage3":"' + str.tostring(qtytp3) + '","takeProfitPercentage3":"' + str.tostring(tpb3tsp) + '","takeProfitAmountPercentage4":"' + str.tostring(qtytp4) + '","takeProfitPercentage4":"' + str.tostring(tpb4tsp) + '","positionSizePercentage":"' + str.tostring(margin) + '","signalId":"' + str.tostring(signal) + '"}'
shortsp = '{"key":"' + str.tostring(apikey) + '","type":"reverse","exchange":"binance","exchangeAccountType":"futures","pair":"' + str.tostring(PAIR) + '","exitOrderType":"market","entryOrderType":"limit","exitSide":"long","entrySide":"short","entryLimitPrice":"' + str.tostring(cs) + '","entryLeverage":"\n' + str.tostring(lev) + str.tostring(slsmessagesp) + '","takeProfitAmountPercentage1":"' + str.tostring(qtytp1) + '","takeProfitPercentage1":"' + str.tostring(tps1tsp) + '","takeProfitAmountPercentage2":"' + str.tostring(qtytp2) + '","takeProfitPercentage2":"' + str.tostring(tps2tsp) + '","takeProfitAmountPercentage3":"' + str.tostring(qtytp3) + '","takeProfitPercentage3":"' + str.tostring(tps3tsp) + '","takeProfitAmountPercentage4":"' + str.tostring(qtytp4) + '","takeProfitPercentage4":"' + str.tostring(tps4tsp) + '","positionSizePercentage":"' + str.tostring(margin) + '","signalId":"' + str.tostring(signal) + '"}'
//===================================================================
//MTF Analysis
//===================================================================
//===================================================================
//Source MTF
tf1 = input.timeframe('15', group='MTF Analysis')
tf2 = input.timeframe('30', group='MTF Analysis')
tf3 = input.timeframe('45', group='MTF Analysis')
tf4 = input.timeframe('60', group='MTF Analysis')
hl2A = request.security(syminfo.tickerid, tf1, hl2)
hl2B = request.security(syminfo.tickerid, tf2, hl2)
hl2C = request.security(syminfo.tickerid, tf3, hl2)
hl2D = request.security(syminfo.tickerid, tf4, hl2)
trA = request.security(syminfo.tickerid, tf1, ta.tr)
trB = request.security(syminfo.tickerid, tf2, ta.tr)
trC = request.security(syminfo.tickerid, tf3, ta.tr)
trD = request.security(syminfo.tickerid, tf4, ta.tr)
highA = request.security(syminfo.tickerid, tf1, high)
highB = request.security(syminfo.tickerid, tf2, high)
highC = request.security(syminfo.tickerid, tf3, high)
highD = request.security(syminfo.tickerid, tf4, high)
lowA = request.security(syminfo.tickerid, tf1, low)
lowB = request.security(syminfo.tickerid, tf2, low)
lowC = request.security(syminfo.tickerid, tf3, low)
lowD = request.security(syminfo.tickerid, tf4, low)
closeA = request.security(syminfo.tickerid, tf1, close)
closeB = request.security(syminfo.tickerid, tf2, close)
closeC = request.security(syminfo.tickerid, tf3, close)
closeD = request.security(syminfo.tickerid, tf4, close)
//Tele Notif
ep = trend == 1 ? cb : cs
winrate = truncate(strategy.wintrades / strategy.closedtrades * 100, 0)
capitalgain = 100 * strategy.netprofit / initialcapital
closedtrades = strategy.closedtrades
//Gathers User Inputs
//Dashboard
sideentry = strategy.position_size > 0 ? 'LONG' : strategy.position_size < 0 ? 'SHORT' : 'No Position'
epp = strategy.position_size > 0 ? cb : strategy.position_size < 0 ? cs : na
tp1p = truncate(strategy.position_size > 0 ? tpb1t : strategy.position_size < 0 ? tps1t : na, dpa)
tp2p = truncate(strategy.position_size > 0 ? tpb2t : strategy.position_size < 0 ? tps2t : na, dpa)
tp3p = truncate(strategy.position_size > 0 ? tpb3t : strategy.position_size < 0 ? tps3t : na, dpa)
tp4p = truncate(strategy.position_size > 0 ? tpb4t : strategy.position_size < 0 ? tps4t : na, dpa)
slp = truncate(strategy.position_size > 0 ? slbt : strategy.position_size < 0 ? slst : na, dpa)
dashDist = input.int(150, 'Dashboard Distance', group='Dashboard Settings')
dashColor = input.color(color.new(#080808, 0), 'Dashboard Color', inline='Dash Line', group='Dashboard Settings')
dashTextColor = input.color(color.new(#ffffff, 0), 'Text Color', inline='Dash Line', group='Dashboard Settings')
sinceentryb = int(math.max(1, nz(ta.barssince(buy and backtest and trendType))))
highestbarb = ta.highest(high[1], sinceentryb)
lowestbarb = ta.lowest(low[1], sinceentryb)
sinceentrys = int(math.max(1, nz(ta.barssince(sell and backtest and trendType))))
highestbars = ta.highest(high[1], sinceentrys)
lowestbars = ta.lowest(low[1], sinceentrys)
hittp1 = strategy.position_size > 0 ? highestbars > tpb1t : strategy.position_size < 0 ? lowestbars < tps1t : na
hittp1t = hittp1 ? ' â' : na
hittp2 = strategy.position_size > 0 ? highestbars > tpb2t : strategy.position_size < 0 ? lowestbars < tps2t : na
hittp2t = hittp2 ? ' â' : na
hittp3 = strategy.position_size > 0 ? highestbars > tpb3t : strategy.position_size < 0 ? lowestbars < tps3t : na
hittp3t = hittp3 ? ' â' : na
hittp4 = strategy.position_size > 0 ? highestbars > tpb4t : strategy.position_size < 0 ? lowestbars < tps4t : na
hittp4t = hittp4 ? ' â' : na
longnotif = '_____________________________' + '\n ' + '\n ð¤AlgoTR Signals' + '\n_____________________________' + '\n ' + '\nCoin : ' + syminfo.ticker + '\nPosition : ðº LONG' + '\nOpen Price : ' + str.tostring(truncate(ep, 0)) + '\nTake Profit 1 : ' + str.tostring(truncate(tpb1t, 0)) + '\nTake Profit 2 : ' + str.tostring(truncate(tpb2t, 0)) + '\nTake Profit 3 : ' + str.tostring(truncate(tpb3t, 0)) + '\nTake Profit 4 : ' + str.tostring(truncate(tpb4t, 0)) + '\nStoploss : ' + str.tostring(truncate(slbt, 0)) + '\n_____________________________' + '\n ' + '\n Backtest Days ' + 'On ' + str.tostring(truncate(daysback, 2)) + ' Days ð°' + '\n_____________________________' + '\n ' + '\nAlgoTR Signals Winrate : ' + str.tostring(winrate) + ' % ð' + '\nð° Net Profits : ' + str.tostring(truncate(capitalgain, 2)) + '% ð°' + '\nð Total Trades : ' + str.tostring(closedtrades) + ' ð' + '\n_____________________________'
shortnotif = '_______________________________' + '\n ' + '\nð¤AlgoTR Signals' + '\n_____________________________' + '\n ' + '\nCoin : ' + syminfo.ticker + '\nPosition : ð» SHORT' + '\nOpen Price : ' + str.tostring(truncate(ep, dpa)) + '\nTake Profit 1 : ' + str.tostring(truncate(tps1t, dpa)) + '\nTake Profit 2 : ' + str.tostring(truncate(tps2t, dpa)) + '\nTake Profit 3 : ' + str.tostring(truncate(tps3t, dpa)) + '\nTake Profit 4 : ' + str.tostring(truncate(tps4t, dpa)) + '\nStoploss : ' + str.tostring(truncate(slst, dpa)) + '\n_____________________________' + '\n ' + '\n Backtest Days ' + 'On ' + str.tostring(truncate(daysback, 2)) + ' Days ð°' + '\n_____________________________' + '\n ' + '\nð¤AlgoTR Signals Winrate : ' + str.tostring(winrate) + ' % ð' + '\nð° Net Profits : ' + str.tostring(truncate(capitalgain, 2)) + '% ð°' + '\nð Total Trades : ' + str.tostring(closedtrades) + ' ð' + '\n_____________________________'
exitziglong1 = 'â Position Statusâ \n\nTake Profit 1 â From ðº Long Signal\n' + 'at Price : ' + str.tostring(tpb1t) + ' in ' + syminfo.ticker // + tostring(exitpricelong1)
exitzigshort1 = 'â Position Statusâ \n\nTake Profit 1 â From ð» Short Signal\n' + 'at Price : ' + str.tostring(tps1t) + ' in ' + syminfo.ticker //+ tostring(exitpriceshort1)
exitziglong2 = 'â Position Statusâ \n\nTake Profit 2 â From ðº Long Signal\n' + 'at Price : ' + str.tostring(tpb2t) + ' in ' + syminfo.ticker // + tostring(exitpricelong2)
exitzigshort2 = 'â Position Statusâ \n\nTake Profit 2 â From ð» Short Signal\n' + 'at Price : ' + str.tostring(tps2t) + ' in ' + syminfo.ticker // + tostring(exitpriceshort2)
exitziglong3 = 'â Position Statusâ \n\nTake Profit 3 â From ðº Long Signal\n' + 'at Price : ' + str.tostring(tpb3t) + ' in ' + syminfo.ticker // + tostring(exitpricelong3)
exitzigshort3 = 'â Position Statusâ \n\nTake Profit 3 â From ð» Short Signal\n' + 'at Price : ' + str.tostring(tps3t) + ' in ' + syminfo.ticker // + tostring(exitpriceshort3)
exitziglong4 = 'â Position Statusâ \n\nTake Profit 4 â From ðº Long Signal\n' + 'at Price : ' + str.tostring(tpb4t) + ' in ' + syminfo.ticker // + tostring(exitpricelong3)
exitzigshort4 = 'â Position Statusâ \n\nTake Profit 4 â From ð» Short Signal\n' + 'at Price : ' + str.tostring(tps4t) + ' in ' + syminfo.ticker // + tostring(exitpriceshort3)
sllong = 'â Position Statusâ \n\nHit SL ð From ðº Long Signal\n' + ' Price : ' + str.tostring(slbt) + ' in ' + syminfo.ticker // + tostring(exitpricelong4)
slshort = 'â Position Statusâ \n\nHit SL ð From ð» Short Signal\n' + ' Price : ' + str.tostring(slst) + ' in ' + syminfo.ticker // + tostring(exitpriceshort4)
longbotcommand = ZZ == z1 ? longct : ZZ == z2 ? longsp : longnotif
shortbotcommand = ZZ == z1 ? shortct : ZZ == z2 ? shortsp : shortnotif
exitbotcommandl1 = ZZ == z3 ? exitziglong1 : na
exitbotcommands1 = ZZ == z3 ? exitzigshort1 : na
exitbotcommandl2 = ZZ == z3 ? exitziglong2 : na
exitbotcommands2 = ZZ == z3 ? exitzigshort2 : na
exitbotcommandl3 = ZZ == z3 ? exitziglong3 : na
exitbotcommands3 = ZZ == z3 ? exitzigshort3 : na
exitbotcommandl4 = ZZ == z3 ? exitziglong4 : na
exitbotcommands4 = ZZ == z3 ? exitzigshort4 : na
sllongcommand = ZZ == z3 ? sllong : slcommand
slshortcommand = ZZ == z3 ? slshort : slcommand
/////////////////////////////////////////////////////////////////////////////////
// Alerts
// to automate put this in trendinview message: {{strategy.order.alert_message}}
//long = input.text_area(defval = "zalupa", title = "Long Entry Message", group = "Alerts")
//short = input.text_area(defval = "zalupa", title = "Short Entry Message", group = "Alerts")
if long_final and backtest and trendType and longside
strategy.entry('Buy', direction=strategy.long, comment='LONG', alert_message=longbotcommand)
alert(message= '________ð¯AlgoTR Trade Information_________' + '\n ' + '\n ð¯Trade Information' + '\n_____________________________' + '\n ' + '\nCoin : ' + syminfo.ticker + '\nPosition : ð LONG(20X)' + '\nEntry Target : ' + str.tostring(truncate(ep, 0)) + '\nTake Profit1 : ' + str.tostring(truncate(tpb1t, 0)) + '\nTake Profit2 : ' + str.tostring(truncate(tpb2t, 0)) + '\nTake Profit3 : ' + str.tostring(truncate(tpb3t, 0)) + '\nTake Profit4 : ' + str.tostring(truncate(tpb4t, 0)) + '\nStoploss : ' + str.tostring(truncate(slbt, 0)) + '\n_____________________________' + '\n ' + '\n Backtest Days ' + 'On ' + str.tostring(truncate(daysback, 2)) + ' Days ð°' + '\n_____________________________' + '\n ' + '\nð ð¯AlgoTRð¸ Winrate : ' + str.tostring(winrate) + ' % ð' + '\nð° Net Profits : ' + str.tostring(truncate(capitalgain, 2)) + '% ð°' + '\nð¨ Notes ð¨'+ '\n⢠Disclaimer On !' + '\n⢠Future USD-M Coin Mode.'+ '\n⢠Trade with high risk.' + '\n⢠Stay wise & disciplined.'+ '\n⢠Risk Management.'+ '\n⢠Use 1-3% Wallet Future.\n'+ '\n_____________________________' + '\n'+ '\nð ð¯AlgoTR ð'+ '\n_____________________________'+ '\n')
if short_final and backtest and trendType and shortside
strategy.entry('Sell', direction=strategy.short, comment='SHORT', alert_message=shortbotcommand)
alert(message='_______ð¯AlgoTR Trade Information________' + '\n ' + '\nð¯Trade Information' + '\n_____________________________' + '\n ' + '\nCoin : ' + syminfo.ticker + '\nPosition : ð SHORT(20X)' + '\nEntry Target : ' + str.tostring(truncate(ep, dpa)) + '\nTake Profit1 : ' + str.tostring(truncate(tps1t, dpa)) + '\nTake Profit2 : ' + str.tostring(truncate(tps2t, dpa)) + '\nTake Profit3 : ' + str.tostring(truncate(tps3t, dpa)) + '\nTake Profit4 : ' + str.tostring(truncate(tps4t, dpa)) + '\nStoploss : ' + str.tostring(truncate(slst, dpa)) + '\n_____________________________' + '\n ' + '\n Backtest Days ' + 'On ' + str.tostring(truncate(daysback, 2)) + ' Days ð°' + '\n_____________________________' + '\n ' + '\nð ð¯AlgoTRð¸ Winrate : ' + str.tostring(winrate) + ' % ð' + '\nð° Net Profits : ' + str.tostring(truncate(capitalgain, 2)) + '% ð°' + '\nð¨ Notes ð¨'+ '\n⢠Disclaimer On !' + '\n⢠Future USD-M Coin Mode.'+ '\n⢠Trade with high risk.' + '\n⢠Stay wise & disciplined.'+ '\n⢠Risk Management.'+ '\n⢠Use 1-3% Wallet Future.\n'+ '\n_____________________________' + '\n'+ '\nð ð¯AlgoTR ð'+'\n_____________________________' + '\n')
//alert(short)
strategy.exit('TP 1', 'Buy', qty_percent=qtytp1, limit=tpb1t, alert_message=exitbotcommandl1)
strategy.exit('TP 2', 'Buy', qty_percent=qtytp2, limit=tpb2t, alert_message=exitbotcommandl2)
strategy.exit('TP 3', 'Buy', qty_percent=qtytp3, limit=tpb3t, alert_message=exitbotcommandl3)
strategy.exit('TP 4', 'Buy', qty_percent=qtytp4, limit=tpb4t, alert_message=exitbotcommandl4)
slbclose = short_final or low < slbt
strategy.close('Buy', when=slbclose, comment='SL', alert_message=sllongcommand)
strategy.exit('TP 1', 'Sell', qty_percent=qtytp1, limit=tps1t, alert_message=exitbotcommands1)
strategy.exit('TP 2', 'Sell', qty_percent=qtytp2, limit=tps2t, alert_message=exitbotcommands1)
strategy.exit('TP 3', 'Sell', qty_percent=qtytp3, limit=tps3t, alert_message=exitbotcommands1)
strategy.exit('TP 4', 'Sell', qty_percent=qtytp4, limit=tps4t, alert_message=exitbotcommands1)
slsclose = long_final or high > slst
strategy.close('Sell', when=slsclose, comment='SL', alert_message=slshortcommand)
leverage = input.int(title="Leverage", defval=20, minval=1, maxval=125, group='Strategy Option')
var label pre_entry_label_long = na
var label positionMaxLabel_long = na
var firstOrderPlaced_long = false
var ath = high
var peak_profit_long = 0.0
var string peak_profit_string_long = na
var drawdown_long = close
var peak_drawdown_long = 0.0
if (ta.crossover(strategy.position_size, 0))
ath := high
peak_profit_long := (((ath - strategy.position_avg_price) / strategy.position_avg_price) * 100) * leverage
peak_profit_string_long := str.tostring(math.round(peak_profit_long, 2))
positionMaxLabel_long := label.new(bar_index , ath, text ="Maximum Profit " + peak_profit_string_long + "%", textcolor = color.rgb(243, 239, 239), color = color.rgb(124, 131, 127, 76), style = label.style_label_down)
firstOrderPlaced_long := true
drawdown_long := close
peak_drawdown_long := (((drawdown_long - strategy.position_avg_price) / strategy.position_avg_price) * 100) * leverage
else if strategy.position_size > 0
if (ath < high)
ath := high
peak_profit_long := (((ath - strategy.position_avg_price) / strategy.position_avg_price) * 100) * leverage // The last value is the leverage
peak_profit_string_long := str.tostring(math.round(peak_profit_long, 2))
if (firstOrderPlaced_long)
label.set_x(positionMaxLabel_long, bar_index)
label.set_y(positionMaxLabel_long, ath)
label.set_text(positionMaxLabel_long, "Maximum Profit " + peak_profit_string_long + "%")
if drawdown_long > low
drawdown_long := low
peak_drawdown_long := (((drawdown_long - strategy.position_avg_price) / strategy.position_avg_price) * 100) * leverage
var label pre_entry_label_short = na
var label positionMaxLabel_short = na
var firstOrderPlaced_short = false
var atl = low
var peak_profit_short = 0.0
var string peak_profit_string_short = na
var drawdown_short = close
var peak_drawdown_short = 0.0
if (ta.crossunder(strategy.position_size, 0))
atl := low
peak_profit_short := -(((atl - strategy.position_avg_price) / strategy.position_avg_price) * 100) * leverage
peak_profit_string_short := str.tostring(math.round(peak_profit_short, 2))
positionMaxLabel_short := label.new(bar_index , atl, text ="Maximum Profit " + peak_profit_string_short + "%", textcolor = color.rgb(250, 247, 247), color = color.rgb(85, 88, 86, 76), style = label.style_label_up)
firstOrderPlaced_short := true
drawdown_short := close
peak_drawdown_short := -(((drawdown_short - strategy.position_avg_price) / strategy.position_avg_price) * 100) * leverage
else if strategy.position_size < 0
if (atl > low)
atl := low
peak_profit_short := -(((atl - strategy.position_avg_price) / strategy.position_avg_price) * 100) * leverage
peak_profit_string_short := str.tostring(math.round(peak_profit_short, 2))
if (firstOrderPlaced_short)
label.set_x(positionMaxLabel_short, bar_index)
label.set_y(positionMaxLabel_short, atl)
label.set_text(positionMaxLabel_short, "Maximum Profit " + peak_profit_string_short + "%")
if drawdown_short < high
drawdown_short := high
peak_drawdown_short := -(((drawdown_short - strategy.position_avg_price) / strategy.position_avg_price) * 100) * leverage
// SUPPORT & RESISTANCE
percWidth(len, perc) => (ta.highest(len) - ta.lowest(len)) * perc / 100
percWidth1(len, perc) => (ta.highest(len) - ta.lowest(len)) * perc / 100
🛠 How to Apply the Nayrafa AlgoTrade-vick-V3 Indicator in TradingView
- Open TradingView and log into your account.
- Go to the Pine Script Editor section.
- Copy and paste the provided script.
- Save the script and name it (e.g., “Nayrafa AlgoTrade”).
- Click “Add to Chart” to visualize the indicator.
- Adjust input settings based on asset type and trading style.
💡 Additional Trading Tips
✅ Combine with Momentum Indicators:
Using RSI or MACD alongside this script can help confirm buy/sell signals.
✅ Manage Risk Effectively:
Adjust position sizes according to risk appetite and market volatility.
✅ Trade with the Trend:
Following the script’s trend signals will improve accuracy and reduce losses.
🎯 Final Thoughts
The Nayrafa AlgoTrade-vick-V3 provides traders with a strategic blend of trend analysis, risk management, and asset-specific optimizations. Whether you’re a scalper looking for quick trades or a swing trader focusing on larger trends, this indicator offers versatility and precision.
However, it’s crucial to remember that no strategy is foolproof. Combining this tool with solid trading discipline and thorough market analysis will yield the best results.
Start optimizing your trading approach with Nayrafa AlgoTrade-vick-V3 today and take your trades to the next level! 🚀
RELATED POSTS
View all