Вот объединенный код, который можно добавить в Pine редактор на TradingView:
```
//@version=4
study(title="MA and EMA signals with Take Profit and Stop Loss", shorttitle="MA+EMA TP/SL", overlay=true)
// Inputs
fast_ma_length = input(title="Fast MA length", type=input.integer, defval=10)
slow_ma_length = input(title="Slow MA length", type=input.integer, defval=30)
ema_length = input(title="EMA length", type=input.integer, defval=20)
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
fast_ma = sma(close, fast_ma_length)
slow_ma = sma(close, slow_ma_length)
ema = ema(close, ema_length)
// Determining signals
long_entry = crossover(fast_ma, slow_ma) and crossover(close, ema)
short_entry = crossunder(fast_ma, slow_ma) and crossunder(close, ema)
exit_long = crossunder(close, ema)
exit_short = crossover(close, ema)
// Plotting signals
plotshape(long_entry, title="Buy", location=location.belowbar, style=shape.triangleup, color=color.green, text="L")
plotshape(short_entry, title="Sell", location=location.abovebar, style=shape.triangledown, color=color.red, text="S")
// 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)
// Plotting the Indicators
plot(fast_ma, title="Fast MA", color=color.yellow, linewidth=1, transp=0)
plot(slow_ma, title="Slow MA", color=color.blue, linewidth=1, transp=0)
plot(ema, title="EMA", color=color.purple, linewidth=1, transp=0)
```
```
//@version=4
study(title="MACD and RSI signals with Take Profit and Stop Loss", shorttitle="MACD+RSI TP/SL", overlay=true)
// Inputs
fast_length = input(title="Fast Length", type=input.integer, defval=12)
slow_length = input(title="Slow Length", type=input.integer, defval=26)
signal_length = input(title="Signal Length", type=input.integer, defval=9)
rsi_length = input(title="RSI Length", type=input.integer, defval=14)
upper_bound = input(title="Overbought level", type=input.float, defval=70.0)
lower_bound = input(title="Oversold level", type=input.float, defval=30.0)
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
[macdLine, signalLine, _] = macd(close, fast_length, slow_length, signal_length)
rsi = rsi(close, rsi_length)
// Determining signals
long_entry = crossover(macdLine, signalLine) and rsi <= lower_bound
short_entry = crossunder(macdLine, signalLine) and rsi >= upper_bound
exit_long = crossunder(macdLine, signalLine)
exit_short = crossover(macdLine, signalLine)
// Plotting signals
plotshape(long_entry, title="Buy", location=location.belowbar, style=shape.triangleup, color=color.green, text="o"
plotshape(short_entry, title="Sell", location=location.abovebar, style=shape.triangledown, color=color.red, text="h"
// 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)
// Plotting the Indicators
plot(macdLine, title="MACD Line", color=color.blue, linewidth=1, transp=0)
plot(signalLine, title="Signal Line", color=color.red, linewidth=1, transp=0)
plot(rsi, title="RSI", color=color.purple, linewidth=1, transp=0)
hline(upper_bound, title="Overbought Line", color=color.red, linestyle=hline.style_dotted)
hline(lower_bound, title="Oversold Line", color=color.green, linestyle=hline.style_dotted)
```
```
//@version=4
study(title=&quot;CCI, OBV, ROC, CMF Signals with Take Profit and Stop Loss&quot;, shorttitle=&quot;CCI+OBV+ROC+CMF TP/SL&quot;, overlay=true)
// Inputs
cci_length = input(title=&quot;CCI Length&quot;, type=input.integer, defval=14)
cci_upper_bound = input(title=&quot;Overbought CCI level&quot;, type=input.float, defval=100.0)
cci_lower_bound = input(title=&quot;Oversold CCI level&quot;, type=input.float, defval=-100.0)
obv_length = input(title=&quot;OBV Length&quot;, type=input.integer, defval=20)
roc_length = input(title=&quot;ROC Length&quot;, type=input.integer, defval=14)
min_chaikin_money_flow = input(title=&quot;Min CMF value&quot;, type=input.float, defval=-0.5)
tp1_perc = input(title=&quot;TP 1 %&quot;, type=input.float, defval=1.0)
tp2_perc = input(title=&quot;TP 2 %&quot;, type=input.float, defval=2.0)
tp3_perc = input(title=&quot;TP 3 %&quot;, type=input.float, defval=3.0)
sl_perc = input(title=&quot;SL %&quot;, type=input.float, defval=1.0)
// Calculating Indicators
cci = cci(high, low, close, cci_length)
obv = obv(close, volume)
roc = roc(close, roc_length)
chaikin_money_flow = cmf(high, low, close, volume)
// Determining signals
long_entry = cci &lt;= cci_lower_bound and obv > nz(obv[1]) and roc > 0 and chaikin_money_flow &gt;= min_chaikin_money_flow
short_entry = cci &gt;= cci_upper_bound and obv &lt; nz(obv[1]) and roc &lt; 0 and chaikin_money_flow &lt;= - min_chaikin_money_flow
exit_long = cci &gt;= cci_upper_bound or roc &lt; 0 or chaikin_money_flow &lt;= - min_chaikin_money_flow
exit_short = cci &lt;= cci_lower_bound or roc &gt; 0 or chaikin_money_flow &gt;= min_chaikin_money_flow
// Plotting signals
plotshape(long_entry, title=&quot;Buy&quot;, location=location.belowbar, style=shape.triangleup, color=color.green, text=&quot;n&quot
plotshape(short_entry, title=&quot;Sell&quot;, location=location.abovebar, style=shape.triangledown, color=color.red, text=&quot;o&quot
// 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=&quot;TP 1&quot;, color=color.gray, linewidth=2, style=plot.style_linebr)
tp2Line = plot(tp2, title=&quot;TP 2&quot;, color=color.gray, linewidth=2, style=plot.style_linebr)
tp3Line = plot(tp3, title=&quot;TP 3&quot;, color=color.gray, linewidth=2, style=plot.style_linebr)
// Stop Loss level
sl = close * (1 - sl_perc / 100)
slLine = plot(sl, title=&quot;SL&quot;, color=color.gray, linewidth=2, style=plot.style_linebr)
// Plotting the Indicators
plot(cci, title=&quot;CCI&quot;, color=color.blue, linewidth=1, transp=0)
plot(obv, title=&quot;OBV&quot;, color=color.red, linewidth=1, transp=0)
plot(roc, title=&quot;ROC&quot;, color=color.purple, linewidth=1, transp=0)
plot(chaikin_money_flow, title=&quot;CMF&quot;, color=color.yellow, linewidth=1, transp=0)
hline(cci_upper_bound, title=&quot;Overbought CCI Level&quot;, color=color.red, linestyle=hline.style_dotted)
hline(cci_lower_bound, title=&quot;Oversold CCI Level&quot;, color=color.green, linestyle=hline.style_dotted)
```
```
//@version=4
study(title=&amp;quot;RSI, Stoch RSI, CCI Signals with Take Profit and Stop Loss&amp;quot;, shorttitle=&amp;quot;RSI+StochRSI+CCI TP/SL&amp;quot;, overlay=true)
// Inputs
src = input(title=&amp;quot;Source&amp;quot;, type=input.source, defval=close)
rsi_length = input(title=&amp;quot;RSI Length&amp;quot;, type=input.integer, defval=14)
rsi_overbought = input(title=&amp;quot;Overbought RSI level&amp;quot;, type=input.float, defval=70.0)
rsi_oversold = input(title=&amp;quot;Oversold RSI level&amp;quot;, type=input.float, defval=30.0)
stochrsi_length = input(title=&amp;quot;Stoch RSI Length&amp;quot;, type=input.integer, defval=14)
stochrsi_overbought = input(title=&amp;quot;Overbought Stoch RSI level&amp;quot;, type=input.float, defval=80.0)
stochrsi_oversold = input(title=&amp;quot;Oversold Stoch RSI level&amp;quot;, type=input.float, defval=20.0)
cci_length = input(title=&amp;quot;CCI Length&amp;quot;, type=input.integer, defval=14)
cci_upper_bound = input(title=&amp;quot;Overbought CCI level&amp;quot;, type=input.float, defval=100.0)
cci_lower_bound = input(title=&amp;quot;Oversold CCI level&amp;quot;, type=input.float, defval=-100.0)
tp1_perc = input(title=&amp;quot;TP 1 %&amp;quot;, type=input.float, defval=1.0)
tp2_perc = input(title=&amp;quot;TP 2 %&amp;quot;, type=input.float, defval=2.0)
tp3_perc = input(title=&amp;quot;TP 3 %&amp;quot;, type=input.float, defval=3.0)
sl_perc = input(title=&amp;quot;SL %&amp;quot;, type=input.float, defval=1.0)
// Calculating Indicators
rsi = rsi(src, rsi_length)
stoch_rsi = stoch(rsi, stochrsi_length, stochrsi_length, stochrsi_length)
cci = cci(high, low, close, cci_length)
// Determining signals
long_entry = rsi &amp;lt;= rsi_oversold and stoch_rsi &amp;lt;= stochrsi_oversold and cci &amp;lt;= cci_lower_bound
short_entry = rsi &amp;gt;= rsi_overbought and stoch_rsi &amp;gt;= stochrsi_overbought and cci &amp;gt;= cci_upper_bound
exit_long = rsi &amp;gt;= rsi_overbought or stoch_rsi &amp;gt;= stochrsi_overbought or cci &amp;gt;= cci_upper_bound
exit_short = rsi &amp;lt;= rsi_oversold or stoch_rsi &amp;lt;= stochrsi_oversold or cci &amp;lt;= cci_lower_bound
// Plotting signals
plotshape(long_entry, title=&amp;quot;Buy&amp;quot;, location=location.belowbar, style=shape.triangleup, color=color.green, text=&amp;quot;g&amp;quot
plotshape(short_entry, title=&amp;quot;Sell&amp;quot;, location=location.abovebar, style=shape.triangledown, color=color.red, text=&amp;quot;t&amp;quot
// 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=&amp;quot;TP 1&amp;quot;, color=color.gray, linewidth=2, style=plot.style_linebr)
tp2Line = plot(tp2, title=&amp;quot;TP 2&amp;quot;, color=color.gray, linewidth=2, style=plot.style_linebr)
tp3Line = plot(tp3, title=&amp;quot;TP 3&amp;quot;, color=color.gray, linewidth=2, style=plot.style_linebr)
// Stop Loss level
sl = close * (1 - sl_perc / 100)
slLine = plot(sl, title=&amp;quot;SL&amp;quot;, color=color.gray, linewidth=2, style=plot.style_linebr)
// Plotting the Indicators
plot(rsi, title=&amp;quot;RSI&amp;quot;, color=color.blue, linewidth=1, transp=0)
plot(stoch_rsi, title=&amp;quot;Stoch RSI&amp;quot;, color=color.red, linewidth=1, transp=0)
plot(cci, title=&amp;quot;CCI&amp;quot;, color=color.purple, linewidth=1, transp=0)
hline(rsi_overbought, title=&amp;quot;Overbought RSI Level&amp;quot;, color=color.red, linestyle=hline.style_dotted)
hline(rsi_oversold, title=&amp;quot;Oversold RSI Level&amp;quot;, color=color.green, linestyle=hline.style_dotted)
hline(stochrsi_overbought, title=&amp;quot;Overbought Stoch RSI Level&amp;quot;, color=color.red, linestyle=hline.style_dotted)
hline(stochrsi_oversold, title=&amp;quot;Oversold Stoch RSI Level&amp;quot;, color=color.green, linestyle=hline.style_dotted)
hline(cci_upper_bound, title=&amp;quot;Overbought CCI Level&amp;quot;, color=color.red, linestyle=hline.style_dotted)
hline(cci_lower_bound, title=&amp;quot;Oversold CCI Level&amp;quot;, color=color.green, linestyle=hline.style_dotted)
```
```
//@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)
```