This strategy mainly utilizes moving averages and Bollinger Bands to capture market trends and volatility. It employs three different types of moving averages: Simple Moving Average (SMA), Weighted Moving Average (WMA), and Exponential Moving Average (EMA). At the same time, it uses Bollinger Bands to set price channels, with the upper and lower bands serving as signals for opening and closing positions. When the price breaks through the upper Bollinger Band, it opens a short position; when it breaks through the lower band, it opens a long position. It also sets wider Bollinger Bands as stop-loss levels, closing positions when the price breaches these bands. Overall, this strategy attempts to establish positions promptly when trends emerge and decisively cut losses when risks escalate, aiming to achieve stable returns.
The Marina Parfenova School Project Bot is a quantitative trading strategy based on moving averages and Bollinger Bands. It attempts to profit by capturing market trends while controlling drawdowns through Bollinger Band stop-loss lines. The strategy logic is simple and straightforward, with a wide range of applications, and parameters can be flexibly adjusted according to market characteristics. However, in practical application, attention still needs to be paid to issues such as sideways markets, extreme conditions, parameter optimization, etc., and further refinement of capital and position management rules is necessary. Overall, this strategy can serve as a basic quantitative trading framework, which can be continuously optimized and improved upon to achieve more robust trading results.
/*backtest start: 2024-03-01 00:00:00 end: 2024-03-31 23:59:59 period: 1h basePeriod: 15m exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}] */ //@version=5 strategy ("Marina Parfenova School Project Bot", overlay = true) sma(price, n) => result = 0.0 for i = 0 to n - 1 result := result + price [i] / n result wma(price, n) => result = 0.0 sum_weight = 0.0 weight = 0.0 for i = 0 to n - 1 weight := n - 1 result := result + price [i]*weight sum_weight := sum_weight + weight result/sum_weight ema(price, n) => result = 0.0 alpha = 2/(n + 1) prevResult = price if (na(result[1]) == false) prevResult := result[1] result := alpha * price + (1 - alpha) * prevResult /// Настройки n_slow = input.int(50, "Период медленной скользящей средней", step=5) n_fast = input.int(4, "Период быстрой скользящей средней") n_deviation = input.int(30, "Период среднеквадратического отклонения", step=5) k_deviation_open = input.float(1.2, "Коэффициент ширины коридора покупки", step=0.1) k_deviation_close = input.float(1.6, "Коэффициент ширины коридора продажи", step=0.1) // ----- Линии индикаторов ----- // Медленная скользящая sma = sma(close, n_slow) plot(sma, color=#d3d3d3) // Линии Боллинджера, обозначающие коридор цены bollinger_open = k_deviation_open * ta.stdev(close, n_deviation) open_short_line = sma + bollinger_open plot(open_short_line, color=#ec8383) open_long_line = sma - bollinger_open plot(open_long_line, color=#6dd86d) bollinger_close = k_deviation_close * ta.stdev(close, n_deviation) close_short_line = sma + bollinger_close plot(close_short_line, color=#e3e3e3) close_long_line = sma - bollinger_close plot(close_long_line, color=#e3e3e3) // Быстрая скользящая ema = ema(close, n_fast) plot(ema, color = color.aqua, linewidth = 2) // ----- Сигналы для запуска стратегии ----- // если ema пересекает линию open_short сверху вниз - сигнал на создание ордера в short if(ema[1] >= open_short_line[1] and ema < open_short_line) strategy.entry("short", strategy.short) // если ema пересекает линию open_long снизу вверх - сигнал на создание ордера в long if(ema[1] <= open_long_line[1] and ema > open_long_line) strategy.entry("long", strategy.long) // если свеча пересекает верхнюю линию коридора продажи - закрываем все long-ордера if (high >= close_short_line) strategy.close("long") // если свеча пересекает нижнюю линию коридора продажи - закрываем все short-ордера if (low <= close_long_line) strategy.close("short")