
В данной статье представлена стратегия количественного трейдинга, основанная на процентной удешевленности. Эта стратегия определяет время покупки и продажи, устанавливая процентное удешевление и выбирая подходящий временной цикл. Сигнал покупки или продажи срабатывает, когда цена повышается или падает по сравнению с предыдущей ценой закрытия сверх указанной процентной удешевленности.
В основе этой стратегии лежит генерация торгового сигнала на основе процента изменения цены. Во-первых, пользователю необходимо установить процентную цену, которая показывает, насколько сильно изменилась цена по сравнению с предыдущей ценой закрытия. В то же время, пользователь также должен выбрать временной период, такой как 1 минута, 1 час, 1 день, для вычисления максимальной цены, минимальной цены и цены закрытия в течение этого периода.
В данной статье представлена стратегия количественной торговли, основанная на процентной наценке, которая автоматически генерирует сигналы покупки и продажи путем установки процентной наценки и временного цикла изменения цен. Эта стратегия проста в использовании, гибка и широко применима, но в то же время подвержена риску рыночных колебаний, параметров и перенастройки.
/*backtest
start: 2023-05-28 00:00:00
end: 2024-06-02 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("GBS Percentage", overlay=true)
// Define input options for percentage settings and timeframe
percentage = input.float(1.04, title="Percentage Threshold", minval=0.01, step=0.01) / 100
timeframe = input.timeframe("D", title="Timeframe", options=["1", "3", "5", "15", "30", "60", "240", "D", "W", "M"])
// Calculate high, low, and close of the selected timeframe
high_timeframe = request.security(syminfo.tickerid, timeframe, high)
low_timeframe = request.security(syminfo.tickerid, timeframe, low)
close_timeframe = request.security(syminfo.tickerid, timeframe, close)
// Calculate the percentage threshold based on the previous close
threshold = close_timeframe[1] * percentage
// Define conditions for Buy and Sell
buyCondition = high_timeframe > (close_timeframe[1] + threshold)
sellCondition = low_timeframe < (close_timeframe[1] - threshold)
// Entry and exit rules
if (buyCondition)
strategy.entry("Buy", strategy.long)
if (sellCondition)
strategy.entry("Sell", strategy.short)
// Close the positions based on the conditions
if (sellCondition)
strategy.close("Buy")
if (buyCondition)
strategy.close("Sell")
// Plot Buy and Sell signals on the chart
plotshape(series=buyCondition, title="Buy Entry", color=color.green, style=shape.triangleup, location=location.belowbar)
plotshape(series=sellCondition, title="Sell Entry", color=color.red, style=shape.triangledown, location=location.abovebar)
// Plot the equity curve of the strategy
plot(strategy.equity, title="Equity", color=color.blue, linewidth=2)