- Регистрация
- 17.03.23
- Сообщения
- 223
- Онлайн
- 6д 3ч 53м
- Сделки
- 0
- Нарушения
- 0 / 0
Куда ты пропал? Ты выполняешь задачу?Вот объединенный код, который можно добавить в Pine редактор на TradingView:
```
//@version=4
study(title="Bollinger Bands, Fib Retracement, EMA Signals with Take Profit and Stop Loss", shorttitle="BB + Fib Retracement + EMA TP/SL", overlay=true)
// Inputs
bb_length = input(title="BB Length", type=input.integer, defval=20)
bb_multiplier = input(title="BB Multiplier", type=input.float, defval=2.0)
ema_length = input(title="EMA Length", type=input.integer, defval=20)
fib_levels = input(title="Fib Retracement Levels", type=input.string, defval="0.236,0.382,0.618")
tp1_perc = input(title="TP 1 %", type=input.float, defval=1.0)
tp2_perc = input(title="TP 2 %", type=input.float, defval=2.0)
tp3_perc = input(title="TP 3 %", type=input.float, defval=3.0)
sl_perc = input(title="SL %", type=input.float, defval=1.0)
// Calculating Indicators
bb = bbands(close, bb_length, bb_multiplier)
ema = ema(close, ema_length)
// Fibonacci Retracement Levels
retracementLevels = str.split(fib_levels, ",")
for i = 0 to array.size(retracementLevels) - 1
fibLevel = float(array.get(retracementLevels, i))
fibPrice = ema * (1 - fibLevel)
plot(fibPrice, title="Fib Retracement Level " + tostring(fibLevel), color=color.gray, linewidth=2, style=plot.style_linebr)
// Take Profit levels
tp1 = close * (1 + tp1_perc / 100)
tp2 = close * (1 + tp2_perc / 100)
tp3 = close * (1 + tp3_perc / 100)
tp1Line = plot(tp1, title="TP 1", color=color.gray, linewidth=2, style=plot.style_linebr)
tp2Line = plot(tp2, title="TP 2", color=color.gray, linewidth=2, style=plot.style_linebr)
tp3Line = plot(tp3, title="TP 3", color=color.gray, linewidth=2, style=plot.style_linebr)
// Stop Loss level
sl = close * (1 - sl_perc / 100)
slLine = plot(sl, title="SL", color=color.gray, linewidth=2, style=plot.style_linebr)
// Determining signals
long_entry = close < ema and close <= bb.lowerband and barssince(close > bb.lowerband) >= barssince(close > bb.upperband) and not na(bb.upperband[1])
short_entry = close > ema and close >= bb.upperband and barssince(close < bb.upperband) >= barssince(close < bb.lowerband) and not na(bb.lowerband[1])
exit_long = close >= ema or close >= tp1 or close >= tp2 or close >= tp3 or close <= sl
exit_short = close <= ema or close <= tp1 or close <= tp2 or close <= tp3 or close >= sl
// Plotting signals
plotshape(long_entry, title="Buy", location=location.belowbar, style=shape.triangleup, color=color.green, text="g")
plotshape(short_entry, title="Sell", location=location.abovebar, style=shape.triangledown, color=color.red, text="t")
// Plotting the Indicators
plot(bb.upperband, title="BB Upper Band", color=color.blue, linewidth=1, transp=0)
plot(bb.lowerband, title="BB Lower Band", color=color.blue, linewidth=1, transp=0)
plot(ema, title="EMA", color=color.black, linewidth=1, transp=0)
hline(tp1, title="TP 1", color=color.gray, linestyle=hline.style_dotted)
hline(tp2, title="TP 2", color=color.gray, linestyle=hline.style_dotted)
hline(tp3, title="TP 3", color=color.gray, linestyle=hline.style_dotted)
hline(sl, title="SL", color=color.gray, linestyle=hline.style_dotted)
```