Richard
Logik teras strategi perdagangan penyu Richard
Selepas memasuki kedudukan, strategi ini menggunakan Julat Benar Purata (ATR) untuk mengira harga stop loss. Ia juga mengesan harga tertinggi dan rendah 10 hari untuk stop loss slippage. Apabila stop loss panjang atau stop loss slippage dicetuskan, ia akan menutup kedudukan panjang. Apabila stop loss pendek atau stop loss slippage dicetuskan, ia akan menutup kedudukan pendek.
Strategi perdagangan penyu Richard
Terdapat juga beberapa risiko dengan strategi perdagangan penyu Richard:
Untuk mengurangkan risiko ini, kita boleh mengoptimumkan keadaan kemasukan dengan lebih banyak penunjuk untuk meramalkan trend; menyesuaikan algoritma stop loss untuk mengurangkan kekerapan stop loss.
Strategi perdagangan penyu Richard
Strategi perdagangan penyu Richard
/*backtest start: 2023-02-05 00:00:00 end: 2024-02-05 00:00:00 period: 1d basePeriod: 1h exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}] */ // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © melodyera0822 //@version=4 strategy("Richard Strategy", overlay=true) // User input variable_for_stoploss = input(4,title="stop loss var") lenght = input(20,title="lenght") // high_low _20_day_highest = highest(nz(close[1]), lenght) _20_day_lowest = lowest(nz(close[1]), lenght) _10_day_low = lowest(nz(close[1]), lenght/2) _10_day_high = highest(nz(close[1]), lenght/2) //indicators atr20 = atr(20) ema_atr20 = ema(atr20,20) //vars var traded = "false" var buy_sell = "none" var buyExit = false var sellExit = false var stoploss = 0 buyCon = close > _20_day_highest and traded == "false" plotshape(buyCon,style = shape.triangleup,location = location.belowbar, color = color.green ) if (buyCon) strategy.entry("long", strategy.long, when = buyCon) traded := "true" buy_sell := "buy" stoploss := round(close - variable_for_stoploss * ema_atr20) sellCon = close < _20_day_lowest and traded == "false" plotshape(sellCon,style = shape.triangledown, color = color.red ) if (sellCon) strategy.entry("short", strategy.short) traded := "true" buy_sell := "sell" stoploss := round(close - variable_for_stoploss * ema_atr20) if traded == "true" if buy_sell == "buy" and ((close<stoploss)or(close<_10_day_low)) strategy.close("long") buyExit := true traded := "false" if buy_sell == "sell" and ((close>stoploss)or(close>_10_day_high)) strategy.close("short") sellExit := true traded := "false" plotshape(buyExit,style = shape.triangleup,location = location.belowbar, color = color.yellow ) buyExit := false plotshape(sellExit,style = shape.triangledown, color = color.yellow ) sellExit := false