PROTECTED SOURCE SCRIPT
Universal Bot [AVATrade - PineConnector Ready]

//version=5
strategy("Universal Bot [AVATrade - PineConnector Ready]", overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=100)
// === INPUTS === //
emaLen = input.int(20, title="EMA Lengte")
rsiLen = input.int(14, title="RSI Lengte")
macdFast = input.int(12, title="MACD Fast")
macdSlow = input.int(26, title="MACD Slow")
macdSig = input.int(9, title="MACD Signaallijn")
atrLen = input.int(14, title="ATR Lengte")
riskUSD = input.float(5, title="Risico per trade ($)")
accountUSD = input.float(500, title="Accountgrootte ($)")
riskReward = input.float(2.0, title="Risk-Reward ratio")
trailingPercent = input.float(0.5, title="Trailing stop (%)")
// === INDICATOREN === //
ema = ta.ema(close, emaLen)
rsi = ta.rsi(close, rsiLen)
[macdLine, signalLine, _] = ta.macd(close, macdFast, macdSlow, macdSig)
atr = ta.atr(atrLen)
// === SIGNALEN === //
longCond = ta.crossover(close, ema) and macdLine > signalLine and rsi > 55
shortCond = ta.crossunder(close, ema) and macdLine < signalLine and rsi < 45
// === POSITIEBEREKENING === //
entryPrice = close
stopLoss = atr
takeProfit = atr * riskReward
lotRaw = riskUSD / stopLoss
lotFinal = lotRaw / 100000 // omzetten naar standaard lot voor brokers
lotStr = str.tostring(lotFinal, "#.####")
slLong = entryPrice - stopLoss
tpLong = entryPrice + takeProfit
slShort = entryPrice + stopLoss
tpShort = entryPrice - takeProfit
// === TRAILING STOP === //
trailOffset = entryPrice * trailingPercent / 100
trailPips = trailOffset / syminfo.mintick
// === STRATEGIE EN ALERTS === //
if (longCond)
strategy.entry("LONG", strategy.long)
strategy.exit("TP/SL LONG", from_entry="LONG", limit=tpLong, stop=slLong, trail_points=trailPips, trail_offset=trailPips)
alert_message = '{ "action": "buy", "symbol": "' + syminfo.ticker + '", "lot": ' + lotStr + ', "sl": ' + str.tostring(slLong) + ', "tp": ' + str.tostring(tpLong) + ', "trail": ' + str.tostring(trailingPercent) + ' }'
alert(alert_message, alert.freq_once_per_bar)
if (shortCond)
strategy.entry("SHORT", strategy.short)
strategy.exit("TP/SL SHORT", from_entry="SHORT", limit=tpShort, stop=slShort, trail_points=trailPips, trail_offset=trailPips)
alert_message = '{ "action": "sell", "symbol": "' + syminfo.ticker + '", "lot": ' + lotStr + ', "sl": ' + str.tostring(slShort) + ', "tp": ' + str.tostring(tpShort) + ', "trail": ' + str.tostring(trailingPercent) + ' }'
alert(alert_message, alert.freq_once_per_bar)
// === VISUEEL === //
plot(ema, title="EMA", color=color.orange)
plotshape(longCond, title="BUY", location=location.belowbar, color=color.green, style=shape.labelup, text="BUY")
plotshape(shortCond, title="SELL", location=location.abovebar, color=color.red, style=shape.labeldown, text="SELL")
strategy("Universal Bot [AVATrade - PineConnector Ready]", overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=100)
// === INPUTS === //
emaLen = input.int(20, title="EMA Lengte")
rsiLen = input.int(14, title="RSI Lengte")
macdFast = input.int(12, title="MACD Fast")
macdSlow = input.int(26, title="MACD Slow")
macdSig = input.int(9, title="MACD Signaallijn")
atrLen = input.int(14, title="ATR Lengte")
riskUSD = input.float(5, title="Risico per trade ($)")
accountUSD = input.float(500, title="Accountgrootte ($)")
riskReward = input.float(2.0, title="Risk-Reward ratio")
trailingPercent = input.float(0.5, title="Trailing stop (%)")
// === INDICATOREN === //
ema = ta.ema(close, emaLen)
rsi = ta.rsi(close, rsiLen)
[macdLine, signalLine, _] = ta.macd(close, macdFast, macdSlow, macdSig)
atr = ta.atr(atrLen)
// === SIGNALEN === //
longCond = ta.crossover(close, ema) and macdLine > signalLine and rsi > 55
shortCond = ta.crossunder(close, ema) and macdLine < signalLine and rsi < 45
// === POSITIEBEREKENING === //
entryPrice = close
stopLoss = atr
takeProfit = atr * riskReward
lotRaw = riskUSD / stopLoss
lotFinal = lotRaw / 100000 // omzetten naar standaard lot voor brokers
lotStr = str.tostring(lotFinal, "#.####")
slLong = entryPrice - stopLoss
tpLong = entryPrice + takeProfit
slShort = entryPrice + stopLoss
tpShort = entryPrice - takeProfit
// === TRAILING STOP === //
trailOffset = entryPrice * trailingPercent / 100
trailPips = trailOffset / syminfo.mintick
// === STRATEGIE EN ALERTS === //
if (longCond)
strategy.entry("LONG", strategy.long)
strategy.exit("TP/SL LONG", from_entry="LONG", limit=tpLong, stop=slLong, trail_points=trailPips, trail_offset=trailPips)
alert_message = '{ "action": "buy", "symbol": "' + syminfo.ticker + '", "lot": ' + lotStr + ', "sl": ' + str.tostring(slLong) + ', "tp": ' + str.tostring(tpLong) + ', "trail": ' + str.tostring(trailingPercent) + ' }'
alert(alert_message, alert.freq_once_per_bar)
if (shortCond)
strategy.entry("SHORT", strategy.short)
strategy.exit("TP/SL SHORT", from_entry="SHORT", limit=tpShort, stop=slShort, trail_points=trailPips, trail_offset=trailPips)
alert_message = '{ "action": "sell", "symbol": "' + syminfo.ticker + '", "lot": ' + lotStr + ', "sl": ' + str.tostring(slShort) + ', "tp": ' + str.tostring(tpShort) + ', "trail": ' + str.tostring(trailingPercent) + ' }'
alert(alert_message, alert.freq_once_per_bar)
// === VISUEEL === //
plot(ema, title="EMA", color=color.orange)
plotshape(longCond, title="BUY", location=location.belowbar, color=color.green, style=shape.labelup, text="BUY")
plotshape(shortCond, title="SELL", location=location.abovebar, color=color.red, style=shape.labeldown, text="SELL")
Korumalı komut dosyası
Bu komut dosyası kapalı kaynak olarak yayınlanmaktadır. Ancak, özgürce ve herhangi bir sınırlama olmaksızın kullanabilirsiniz – daha fazla bilgi burada.
Feragatname
Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, işlem veya diğer türden tavsiye veya tavsiyeler anlamına gelmez ve teşkil etmez. Kullanım Şartları'nda daha fazlasını okuyun.
Korumalı komut dosyası
Bu komut dosyası kapalı kaynak olarak yayınlanmaktadır. Ancak, özgürce ve herhangi bir sınırlama olmaksızın kullanabilirsiniz – daha fazla bilgi burada.
Feragatname
Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, işlem veya diğer türden tavsiye veya tavsiyeler anlamına gelmez ve teşkil etmez. Kullanım Şartları'nda daha fazlasını okuyun.