커뮤니티
1/2 ATR시스템 수식 부탁드립니다
2016-04-18 12:48:34
148
글번호 97187
1.
var1 = highest(H,20)[1];
var2 = lowest(L,20)[1];
var3 = atr(20);
var4 = ma(C,25);
var5 = ma(C,350);
if var4 > var5 then{
if MarketPosition <= 0 and crossup(C,var1) Then
buy("b",OnClose,def,1);
}
if MarketPosition == 1 then{
if MaxEntries < 4 Then{
buy("bb",AtStop,LatestEntryPrice+var3*(1/2),1);
}
ExitLong("bx",AtStop,EntryPrice-var3*2+var3*(1/2)*(MaxEntries-1));
ExitLong("Bx3",AtStop,lowest(L,10));
}
if var4 < var5 then{
if MarketPosition >= 0 and CrossDown(C,var2) Then
sell("s",OnClose,def,1);
}
if MarketPosition == -1 then{
if MaxEntries < 4 Then{
sell("ss",AtStop,EntryPrice-var3*(1/2),1);
}
ExitShort("sx2",AtStop,EntryPrice+var3*2-var3*(1/2)*(MaxEntries-1));
ExitShort("sx3",AtStop,Highest(H,10));
}
2.
var1 = highest(H,20)[1];
var2 = lowest(L,20)[1];
var3 = atr(20);
var4 = ma(C,25);
var5 = ma(C,350);
if var4 > var5 then{
if MarketPosition <= 0 and crossup(C,var1) Then
buy("b",OnClose,def,1);
}
if MarketPosition == 1 then{
if MaxEntries < 4 Then{
buy("bb",AtStop,LatestEntryPrice+var3*(1/2),1);
}
ExitLong("bx",AtStop,EntryPrice-var3*2+var3*(1/2)*(MaxEntries-1));
ExitLong("Bx3",AtStop,Highest(C,BarsSinceEntry)-var3*3);
}
if var4 < var5 then{
if MarketPosition >= 0 and CrossDown(C,var2) Then
sell("s",OnClose,def,1);
}
if MarketPosition == -1 then{
if MaxEntries < 4 Then{
sell("ss",AtStop,EntryPrice-var3*(1/2),1);
}
ExitShort("sx2",AtStop,EntryPrice+var3*2-var3*(1/2)*(MaxEntries-1));
ExitShort("sx3",AtStop,Lowest(c,BarsSinceEntry)+var3*3);
}
이상의 식에서 손절가를 진입가격+-ATR(20)*1/2 로 바꾸고 싶습니다.
또 1계약씩 추가진입 시 전체 계약의 손절가를 한꺼번에 이동시키지 않고 계약마다 손절가를 설정해 주었으면 하네요.
ex> 첫번째 계약 0.7000 매수시 손절가 {ATR(20)=50}이라 가정했을 때 0.6900
두번째 계약 0.7050 매수 손절가 0.6950
세번째 계약 0.7100 매수 손절가 0.7000
네번째 계약 0.7150 매수 손절가 0.7050
물론 손절가에 다다렀다가 다시 추가 진입가격으로 올라갔을 때 추가 계약 진입하는 건 똑같습니다.
항상 수고하십니다. 감사합니다.
답변 1
예스스탁 예스스탁 답변
2016-04-18 20:01:11
안녕하세요
예스스탁입니다.
진입별로 손절은 SetStopLoss함수로만 가능합니다.
ATR의 50%는 첫진입시에 값으로 고정했습니다.
봉마다 변동되는 값으로 지정할수는 없습니다.
1
var : loss(0);
var1 = highest(H,20)[1];
var2 = lowest(L,20)[1];
var3 = atr(20);
var4 = ma(C,25);
var5 = ma(C,350);
if var4 > var5 then{
if MarketPosition <= 0 and crossup(C,var1) Then{
buy("b",OnClose,def,1);
loss = var3*(1/2);
}
}
if MarketPosition == 1 then{
if MaxEntries < 4 Then{
buy("bb",AtStop,LatestEntryPrice+var3*(1/2),1);
}
ExitLong("Bx3",AtStop,lowest(L,10));
}
if var4 < var5 then{
if MarketPosition >= 0 and CrossDown(C,var2) Then{
sell("s",OnClose,def,1);
loss = var3*(1/2);
}
}
if MarketPosition == -1 then{
if MaxEntries < 4 Then{
Sell("ss",AtStop,EntryPrice-var3*(1/2),1);
}
ExitShort("sx3",AtStop,Highest(H,10));
}
SetStopLoss(loss,PointStop);
2.
var : loss(0);
var1 = highest(H,20)[1];
var2 = lowest(L,20)[1];
var3 = atr(20);
var4 = ma(C,25);
var5 = ma(C,350);
if var4 > var5 then{
if MarketPosition <= 0 and crossup(C,var1) Then{
buy("b",OnClose,def,1);
loss = var3*(1/2);
}
}
if MarketPosition == 1 then{
if MaxEntries < 4 Then{
buy("bb",AtStop,LatestEntryPrice+var3*(1/2),1);
}
ExitLong("Bx3",AtStop,Highest(C,BarsSinceEntry)-var3*3);
}
if var4 < var5 then{
if MarketPosition >= 0 and CrossDown(C,var2) Then{
sell("s",OnClose,def,1);
loss = var3*(1/2);
}
}
if MarketPosition == -1 then{
if MaxEntries < 4 Then{
sell("ss",AtStop,EntryPrice-var3*(1/2),1);
}
ExitShort("sx3",AtStop,Lowest(c,BarsSinceEntry)+var3*3);
}
SetStopLoss(loss,PointStop);
즐거운 하루되세요
> 마틸다 님이 쓴 글입니다.
> 제목 : 1/2 ATR시스템 수식 부탁드립니다
> 1.
var1 = highest(H,20)[1];
var2 = lowest(L,20)[1];
var3 = atr(20);
var4 = ma(C,25);
var5 = ma(C,350);
if var4 > var5 then{
if MarketPosition <= 0 and crossup(C,var1) Then
buy("b",OnClose,def,1);
}
if MarketPosition == 1 then{
if MaxEntries < 4 Then{
buy("bb",AtStop,LatestEntryPrice+var3*(1/2),1);
}
ExitLong("bx",AtStop,EntryPrice-var3*2+var3*(1/2)*(MaxEntries-1));
ExitLong("Bx3",AtStop,lowest(L,10));
}
if var4 < var5 then{
if MarketPosition >= 0 and CrossDown(C,var2) Then
sell("s",OnClose,def,1);
}
if MarketPosition == -1 then{
if MaxEntries < 4 Then{
sell("ss",AtStop,EntryPrice-var3*(1/2),1);
}
ExitShort("sx2",AtStop,EntryPrice+var3*2-var3*(1/2)*(MaxEntries-1));
ExitShort("sx3",AtStop,Highest(H,10));
}
2.
var1 = highest(H,20)[1];
var2 = lowest(L,20)[1];
var3 = atr(20);
var4 = ma(C,25);
var5 = ma(C,350);
if var4 > var5 then{
if MarketPosition <= 0 and crossup(C,var1) Then
buy("b",OnClose,def,1);
}
if MarketPosition == 1 then{
if MaxEntries < 4 Then{
buy("bb",AtStop,LatestEntryPrice+var3*(1/2),1);
}
ExitLong("bx",AtStop,EntryPrice-var3*2+var3*(1/2)*(MaxEntries-1));
ExitLong("Bx3",AtStop,Highest(C,BarsSinceEntry)-var3*3);
}
if var4 < var5 then{
if MarketPosition >= 0 and CrossDown(C,var2) Then
sell("s",OnClose,def,1);
}
if MarketPosition == -1 then{
if MaxEntries < 4 Then{
sell("ss",AtStop,EntryPrice-var3*(1/2),1);
}
ExitShort("sx2",AtStop,EntryPrice+var3*2-var3*(1/2)*(MaxEntries-1));
ExitShort("sx3",AtStop,Lowest(c,BarsSinceEntry)+var3*3);
}
이상의 식에서 손절가를 진입가격+-ATR(20)*1/2 로 바꾸고 싶습니다.
또 1계약씩 추가진입 시 전체 계약의 손절가를 한꺼번에 이동시키지 않고 계약마다 손절가를 설정해 주었으면 하네요.
ex> 첫번째 계약 0.7000 매수시 손절가 {ATR(20)=50}이라 가정했을 때 0.6900
두번째 계약 0.7050 매수 손절가 0.6950
세번째 계약 0.7100 매수 손절가 0.7000
네번째 계약 0.7150 매수 손절가 0.7050
물론 손절가에 다다렀다가 다시 추가 진입가격으로 올라갔을 때 추가 계약 진입하는 건 똑같습니다.
항상 수고하십니다. 감사합니다.
다음글
이전글