
이 전략은 ATR 지표에 기반한 트렌드 브레이킹 전략이다. 그것의 주요 아이디어는 가격이 ATR의 일정한 배수를 초과할 때 트렌드 브레이킹 작업을 수행하는 것이다. 전략은 동시에 트렌드의 확인과 날짜 범위를 사용하여 거래의 제한 기능을 포함한다.
전략은 ATR 지수를 사용하여 가격 변동의 폭을 판단한다. ATR은 평균 실제 파장을 나타냅니다. 이는 특정 시간 동안의 평균 가격 변동의 폭을 측정합니다. 전략에는 length 파라미트가 ATR 주기를 계산하고, numATRs 파라미트는 돌파의 ATR 배수를 나타냅니다.
가격 상승이 상위 numATRs 곱하기 ATR을 돌파할 때, 더 많은 작업을 수행합니다. 가격이 하락이 하위 numATRs 곱하기 ATR을 돌파할 때, 하위 numATRs 곱하기 ATR을 돌파할 때, 하위 작업을 수행합니다.
또한, 전략은 긴 포지션 ((needlong) 을 필요로 하는 BOOL 변수와 공백 (needshort) 을 필요로 하는 BOOL 변수를 추가하여, 오직 공백만 하거나 공백만 하는 것을 제어할 수 있다. 전략은 또한 날짜 범위를 설정하여, 지정된 날짜 사이에만 거래를 하고, 따라서 시간 범위를 제한한다.
전략은 size 변수를 사용하여 포지션을 판단하고, 포지션 상황에 따라 단수 수를 계산한다. 손수는 계정 권리 이익의 비율에 따라 계산한다.
이 전략의 전체적인 아이디어는 명확하고 이해하기 쉽다. ATR 지표를 사용하여 시장의 변동성에 자동으로 적응하는 것은 일반적인 트렌드 추적 전략이다. 파라미터 최적화 및 다른 전략의 조합을 통해 전략의 성과와 안정성을 더욱 향상시킬 수 있다. 그러나 단일 손실을 과도하게 방지하는 데 주의를 기울여야 하며, 급격한 상황 변화 시 손실을 멈추는 데 주의를 기울여야 한다.
/*backtest
start: 2023-09-30 00:00:00
end: 2023-10-30 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//Noro
//2018
//@version=3
strategy(title = "Noro's Volty Strategy v1.0", shorttitle = "Volty 1.0", overlay = true, default_qty_type = strategy.percent_of_equity, default_qty_value = 100, pyramiding = 100)
//Settings
needlong = input(true, defval = true, title = "Long")
needshort = input(false, defval = false, title = "Short")
capital = input(100, defval = 100, minval = 1, maxval = 10000, title = "Lot, %")
length = input(5)
numATRs = input(0.75)
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")
//Indicator
atrs = sma(tr, length) * numATRs
//Trading
size = strategy.position_size
lot = 0.0
lot := size == 0 ? strategy.equity / close * capital / 100 : lot[1]
if (not na(close[length])) and needlong
strategy.entry("L", strategy.long, lot, stop = close + atrs, when = (time > timestamp(fromyear, frommonth, fromday, 00, 00) and time < timestamp(toyear, tomonth, today, 23, 59)))
if (not na(close[length])) and needlong == false
strategy.entry("L", strategy.long, 0, stop = close + atrs, when = (time > timestamp(fromyear, frommonth, fromday, 00, 00) and time < timestamp(toyear, tomonth, today, 23, 59)))
if (not na(close[length])) and needshort
strategy.entry("S", strategy.short, lot, stop = close - atrs, when = (time > timestamp(fromyear, frommonth, fromday, 00, 00) and time < timestamp(toyear, tomonth, today, 23, 59)))
if (not na(close[length])) and needshort == false
strategy.entry("S", strategy.short, 0, stop = close - atrs, when = (time > timestamp(fromyear, frommonth, fromday, 00, 00) and time < timestamp(toyear, tomonth, today, 23, 59)))