Chiến lược này được sử dụng để thực hiện giao dịch dài hạn trong các tình huống xu hướng bằng cách tính toán giá nhập và xuất sau khi di chuyển.
Tính toán tỷ lệ phần trăm chuyển giá của giá đóng cửa của một đường K.
Giá di chuyển xuống là đường mua, giá di chuyển lên là đường bán.
Khi giá chạm vào đường mua, bạn có thể mở thêm vị trí.
Khi giá chạm đường bán ra, bạn sẽ bị phá vỡ.
Chiến lược này tự động theo dõi các điểm dừng bằng cách thiết lập giá nhập và thoát bằng di động. Tối ưu hóa tham số và tối ưu hóa logic phán đoán có thể làm tăng hiệu quả chiến lược hơn nữa.
/*backtest
start: 2022-09-14 00:00:00
end: 2023-09-20 00:00:00
period: 4d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//Noro
//2019
//@version=3
strategy(title = "Noro's ShiftEx Strategy v2.0", shorttitle = "ShiftEx 2.0", overlay = true, default_qty_type = strategy.percent_of_equity, default_qty_value = 100, pyramiding = 0)
//Settings
buy = input(-10.0, title = "Buy, src-%")
sell = input(0.0, title = "Sell, src+%")
buysrc = input(low, title = "Source for buy")
sellsrc = input(ohlc4, title = "Source for sell")
offset = input(true)
fromyear = input(1900, defval = 1900, minval = 1900, maxval = 2100, title = "From Year")
toyear = input(2100, defval = 2100, minval = 1900, maxval = 2100, title = "To Year")
frommonth = input(01, defval = 01, minval = 01, maxval = 12, title = "From Month")
tomonth = input(12, defval = 12, minval = 01, maxval = 12, title = "To Month")
fromday = input(01, defval = 01, minval = 01, maxval = 31, title = "From day")
today = input(31, defval = 31, minval = 01, maxval = 31, title = "To day")
//Levels
bar = close > open ? 1 : close < open ? -1 : 0
mult = 1 / syminfo.mintick
lb = bar == -1 ? buysrc + ((buysrc / 100) * (buy * 1)) : buysrc + ((buysrc / 100) * (buy * 2))
levelbuy = round(lb * mult) / mult
ls = sellsrc + ((sellsrc / 100) * sell)
levelsell = round(ls * mult) / mult
//Lines
os = offset ? 1 : 0
plot(levelbuy, offset = os, linewidth = 2, color = lime, title = "Buy")
plot(levelsell, offset = os, linewidth = 2, color = blue, title = "Sell")
//Trading
if low[1] > 0
strategy.entry("long", strategy.long, limit = levelbuy, when = (time > timestamp(fromyear, frommonth, fromday, 00, 00) and time < timestamp(toyear, tomonth, today, 23, 59)))
strategy.entry("close", strategy.short, 0, limit = levelsell, when = (time > timestamp(fromyear, frommonth, fromday, 00, 00) and time < timestamp(toyear, tomonth, today, 23, 59)))