
この戦略は,candleの实体部分に基づいています.EMA指標と組み合わせて,市場の傾向の方向を判断し,ORIGINAL PRIMITIVE TREND TRACKINGの効果を実現します. 陽線が大きいときは多行し,陰線が大きいときは空行して,市場傾向を追跡します.
この戦略は以下の利点があります.
この戦略にはいくつかのリスクがあります.
リスクは以下の方法で軽減できます
この戦略は,以下の点で最適化できます.
この戦略は,原始的なシンプルなタイプのトレンド追跡戦略の1つである。キャンドル構造の判断により,トレンドの方向を効果的に追跡することができる。同時に,急速なストップ・ロスの仕組みを設定し,利益をロックすることができる。この戦略は,トレンド追跡ポートフォリオを補完できるが,リスクを下げるために最適化する必要がある。将来,他の指標と組み合わせた効果をさらに研究する価値がある。
/*backtest
start: 2023-10-23 00:00:00
end: 2023-11-22 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=3
strategy(title = "Noro's Primitive Strategy v1.0", shorttitle = "Primitive str 1.0", overlay=true, default_qty_type = strategy.percent_of_equity, default_qty_value = 100.0, pyramiding = 10)
//Settings
needlong = input(true, defval = true, title = "Long")
needshort = input(true, defval = true, title = "Short")
usebody = input(true, defval = true, title = "Use body")
useus = input(true, defval = true, title = "Use UUP")
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(01, defval = 01, 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")
//Logic
body = abs(close - open)
sbody = ema(body, 30) / 2
bar = close > open ? 1 : close < open ? -1 : 0
//Signals
up = bar == -1 and (body > sbody or usebody == false) and (close < strategy.position_avg_price or strategy.position_size <= 0 or useus == false)
dn = bar == 1 and (body > sbody or usebody == false) and (close > strategy.position_avg_price or strategy.position_size >= 0 or useus == false)
//Trading
if up
strategy.entry("Long", strategy.long, needlong == false ? 0 : na, when=(time > timestamp(fromyear, frommonth, fromday, 00, 00) and time < timestamp(toyear, tomonth, today, 00, 00)))
if dn
strategy.entry("Short", strategy.short, needshort == false ? 0 : na, when=(time > timestamp(fromyear, frommonth, fromday, 00, 00) and time < timestamp(toyear, tomonth, today, 00, 00)))
if time > timestamp(toyear, tomonth, today, 00, 00)
strategy.close_all()