무작위 행운을 기반으로 한 간단한 거래 전략


생성 날짜: 2023-09-13 17:48:13 마지막으로 수정됨: 2023-09-13 17:48:13
복사: 0 클릭수: 734
avatar of ChaoZhang ChaoZhang
1
집중하다
1617
수행원

이 전략의 이름은 random luck based simple trading strategy . 이 전략은 무작위적인 방법을 사용하여 매주 첫날에 더 많은 또는 더 적은 신호를 생성하고, 수많은 반복 테스트를 통해 무작위 거래의 효과를 평가한다.

이 전략의 거래 논리는 매우 간단하고 직설적입니다.

  1. 매주 월요일, 동전을 던지고, 앞과 뒷의 결과가 무작위로 나옵니다.

  2. 만약 머리가 있다면, 그 날에 더 많이 하고, 만약 꼬리가 있다면, 그 날에 빈 채로 하라.

  3. 더 많이 할 때, 중지 손실은 1 배 ATR, 중지 중지 1 배 ATR; 공평하게 할 때, 1:1의 위험 수익률을 달성한다.

  4. 이번 주말에 지분을 유지하다 평점으로 떨어졌다.

이 전략의 장점은 수년간의 데이터를 거슬러 올라가 무작위 거래의 평균 승률을 평가할 수 있다는 것입니다. 거래 규칙은 매우 간단하여 전략 비교 기준으로 사용할 수 있습니다.

그러나 무작위 거래는 시장 법칙을 활용할 수 없으며 지속적으로 긍정적 인 수익을 얻는 것이 어렵습니다. 정지 중지 손실 고정 또한 손실 확산을 유발할 수 있습니다. 거래자는 실험적인 전략으로만 사용할 수 있으며 실장에 사용할 수 없습니다.

전체적으로, 데이터 재검토는 무작위 거래의 효과를 암시할 수 있지만, 실제적으로 사용할 수 있는 전략을 대변하지 않는다. 거래자는 결국 판단력과 체계적인 거래 기법을 필요로 한다.

전략 소스 코드
/*backtest
start: 2022-09-12 00:00:00
end: 2023-01-12 00:00:00
period: 2d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=5
strategy("CoinFlip", overlay = true)

int result = int(math.random()+0.5)
atr_period = input(defval = 20, title = "ATR Period")
year_to_test = input(defval = 2022, title = "Year to Test")
day_of_week = input(defval = 1, title = "Day of Week")

atr = ta.atr(atr_period)

shouldSell = result == 0 and dayofweek == day_of_week
shouldBuy = result == 1 and dayofweek == day_of_week 

plotshape(result == 0 and dayofmonth == day_of_week, title="sell", location=location.abovebar, color=color.red, transp=0, style=shape.arrowdown)
plotshape(result == 1 and dayofmonth == day_of_week, title="buy", location=location.belowbar, color=color.lime, transp=0, style=shape.arrowup)


strategy.entry("short entry", strategy.short, 1000 / (1*atr), when=shouldSell and year == year_to_test)
strategy.entry("long entry", strategy.long,  1000  / (1*atr), when=shouldBuy and year == year_to_test)

strategy.exit("exit", "long entry", limit = close + 1*atr, stop = close - 1*atr, when = shouldBuy)
strategy.exit("exit", "short entry", limit = close - 1*atr, stop = close + 1*atr, when = shouldSell)