R에서 전략을 백 테스팅하기 위해 SIT (Systematic Investor Toolbox)를 사용하고 있습니다. 현재이 기능을 사용하여 역 테스팅시 fixed stop loss으로 사용하고 있습니다.SIT R에서 맞춤형 정지 손실 기능을 작성하는 방법은 무엇입니까?
stop.loss <- function(weight, price, tstart, tend, pstop) {
index = tstart : tend
if(weight > 0)
price[ index ] < (1 - pstop) * price[ tstart ]
else
price[ index ] > (1 + pstop) * price[ tstart ]
}
#The stop loss function
Stoploss = .25/100
#Set our maximum loss at a .25% move in price against our trade
data$weight[] = NA
data$weight[] = custom.stop.fn(coredata(long.short.strategy), coredata(prices), stop.loss,pstop = Stoploss)
models$stoploss = bt.run.share(data, clean.signal=T, trade.summary = TRUE)
#Our long short model with a .25% stop loss
나는 SIT 내 자신의 사용자 정의 정지 기능을 만들려고하지만 매개 변수는이 목적을 위해 SIT에서 사용하는 방법과 아무 생각이 없습니다.
내 사용자 지정 정지 손실의 아이디어는 내가 가격을 흔적 만 한 번 이동 정지 손실을 싶지 않는 때문 후행 정지 손실되지 않습니다
1) Initially fixed stop loss should be 10% of entry price
2) when price move more than 20% of entry price a new fixed stop loss be made at 10% of new entry price
입니다.