
Основная идея этой стратегии заключается в том, чтобы использовать высокие и низкие точки трехминутного K-линии в качестве точки прорыва, делать больше, когда цена прорывает высокие точки трехминутного K-линии, и быть свободным, когда она прорывает низкие точки. Эта стратегия подходит для торговли в течение дня, при закрытии позиции в течение дня, и продолжать торговлю на следующий день. Преимущества этой стратегии заключаются в том, что она проста и понятна, ее легко реализовать, и риск относительно низок.
Стратегия основана на трехминутном прорыве высоких и низких точек K-линии и применяется для торговли в течение дня. Преимущества заключаются в том, что она проста и понятна, ее легко реализовать, а риск относительно низок. Но также существуют некоторые риски, например, когда рынок колеблется, может возникнуть большой отход.
/*backtest
start: 2023-06-08 00:00:00
end: 2024-06-13 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("Banknifty Strategy", overlay=true, default_qty_type=strategy.fixed, default_qty_value=1)
// Parameters
start_date = input(timestamp("2024-01-01 00:00"), title="Start Date")
end_date = input(timestamp("2024-06-07 23:59"), title="End Date")
// Time settings
var startTime = timestamp("2024-06-09 09:15")
var endTime = timestamp("2024-06-09 09:24")
// Variables to store the 3rd 3-minute candle
var bool isCandleFound = false
var float thirdCandleHigh = na
var float thirdCandleLow = na
var float baseCandleHigh = na
var float baseCandleLow = na
var float entryPrice = na
var float targetPrice = na
// Check if the current time is within the specified date range
inDateRange = true
// Capture the 3rd 3-minute candle
if (inDateRange and not isCandleFound)
var int candleCount = 0
if (true)
candleCount := candleCount + 1
if (candleCount == 3)
thirdCandleHigh := high
thirdCandleLow := low
isCandleFound := true
// Wait for a candle to close above the high of the 3rd 3-minute candle
if (isCandleFound and na(baseCandleHigh) and close > thirdCandleHigh)
baseCandleHigh := close
baseCandleLow := low
// Strategy logic for buying and selling
if (not na(baseCandleHigh))
// Buy condition
if (high > baseCandleHigh and strategy.opentrades == 0)
entryPrice := high
targetPrice := entryPrice + 100
strategy.entry("Buy", strategy.long, limit=entryPrice)
// Sell condition
if (low < baseCandleLow and strategy.opentrades == 0)
entryPrice := low
targetPrice := entryPrice - 100
strategy.entry("Sell", strategy.short, limit=entryPrice)
// Exit conditions
if (strategy.opentrades > 0)
// Exit BUY trade when profit is 100 points or carry forward to next day
if (strategy.position_size > 0 and high >= targetPrice)
strategy.exit("Take Profit", from_entry="Buy", limit=targetPrice)
// Exit SELL trade when profit is 100 points or carry forward to next day
if (strategy.position_size < 0 and low <= targetPrice)
strategy.exit("Take Profit", from_entry="Sell", limit=targetPrice)
// Close trades at the end of the day
if (time == timestamp("2024-06-09 15:30"))
strategy.close("Buy", comment="Market Close")
strategy.close("Sell", comment="Market Close")
// Plotting for visualization
plotshape(series=isCandleFound, location=location.belowbar, color=color.red, style=shape.labeldown, text="3rd 3-min candle")
plot(baseCandleHigh, title="Base Candle High", color=color.green, linewidth=2, style=plot.style_line)
plot(baseCandleLow, title="Base Candle Low", color=color.red, linewidth=2, style=plot.style_line)