커뮤니티
수식문의드립니다.
2017-11-24 12:14:06
170
글번호 114476
어제 질문했던 것을 보니 제가 질문을 잘못했더군요.
매수든 매도든 다수의 계약으로 한번에 진입한 이후,
청산을 여러가지 경우로 나누어 청산하는 전략을 세우려고 합니다.
예를 들어,
매수로 N계약만큼 진입 이후,
1. 체결된 계약(또는 남아 있는 계약)의 1/2은 0.5P(10틱)에서 청산
2. A라는 조건을 만족시 남아 있는 계약의 1/2은 청산
3. B라는 조건을 만족시 남아 있는 계약의 1/2은 청산
4. 체결된 계약(또는 남아 있는 계약 전부)에 대해서 C라는 조건을 만족시에는 모두 청산
위 1~4의 조건은 어떤 것이 먼저 만족할 지는 상황에 따라 다릅니다.
이와 같이 청산 전략을 세울경우 수식을 어떻게 만들어야 되나요?
(4번에서, C라는 조건이었는데, B라는 조건이라고 써놔서 혼란을 야기한 것 같습니다.)
알려주신 수식에서
var : count(0);
if MarketPosition == 1 then{
if CurrentContracts < CurrentContracts[1] and LatestExitName(0) == "bx1" Then
Condition1 = true;
if CurrentContracts < CurrentContracts[1] and LatestExitName(0) == "bx2" Then
Condition2 = true;
if CurrentContracts < CurrentContracts[1] and LatestExitName(0) == "bx3" Then
Condition3 = true;
if CurrentContracts < CurrentContracts[1] and LatestExitName(0) == "bx4" Then
Condition4 = true;
부분이 꼭 필요한가요?
각조건 별로...exitlong함수에서 currentcontracts*0.5나 currentcontracts를 써서 그냥 작성하면 오류가 나나요?
이래저래 청산되고 남은 계약수가 0이 되었을때는, exitlong이나 exitshort 함수가 실행되지 않도록 하는 작업이 꼭 필요한 것인지요? 그냥 currentcontracts 나 marketposition이 0이 되면 어차피 실행이 안되니 상관없는 것 아닌지 궁금합니다.
그냥, 위 예시에서.
if 진입 then
exitlong("",atlimit,EntryPrice+PriceScale*10,"",Floor(CurrentContracts*0.5),1);
if A조건 then
exitlong("",OnClose,def,"",Floor(CurrentContracts*0.5),1);
if B조건 then
exitlong("",OnClose,def,"",Floor(CurrentContracts*0.5),1);
if C조건 then
exitlong("",OnClose,def,"",Floor(CurrentContracts),1);
이런 식으로 해버리면 오류가 나나요?
답변 1
예스스탁 예스스탁 답변
2017-11-28 10:20:38
안녕하세요
예스스탁입니다.
if CurrentContracts < CurrentContracts[1] and LatestExitName(0) == "bx1" Then
Condition1 = true;
if CurrentContracts < CurrentContracts[1] and LatestExitName(0) == "bx2" Then
Condition2 = true;
if CurrentContracts < CurrentContracts[1] and LatestExitName(0) == "bx3" Then
Condition3 = true;
if CurrentContracts < CurrentContracts[1] and LatestExitName(0) == "bx4" Then
Condition4 = true;
위 부분은 각 청산이 진입후 1회만 반복하라는 내용입니다.
진입이 1회이면 필요없습니다.
아래와 같이 작성하시면 됩니다.
if MarketPosition == 1 then{
exitlong("",atlimit,EntryPrice+PriceScale*10,"",Floor(CurrentContracts*0.5),1);
if A조건 then
exitlong("",OnClose,def,"",Floor(CurrentContracts*0.5),1);
if B조건 then
exitlong("",OnClose,def,"",Floor(CurrentContracts*0.5),1);
if C조건 then
exitlong("",OnClose,def,"",Floor(CurrentContracts),1);
}
즐거운 하루되세요
> 디벨로퍼 님이 쓴 글입니다.
> 제목 : 수식문의드립니다.
> 어제 질문했던 것을 보니 제가 질문을 잘못했더군요.
매수든 매도든 다수의 계약으로 한번에 진입한 이후,
청산을 여러가지 경우로 나누어 청산하는 전략을 세우려고 합니다.
예를 들어,
매수로 N계약만큼 진입 이후,
1. 체결된 계약(또는 남아 있는 계약)의 1/2은 0.5P(10틱)에서 청산
2. A라는 조건을 만족시 남아 있는 계약의 1/2은 청산
3. B라는 조건을 만족시 남아 있는 계약의 1/2은 청산
4. 체결된 계약(또는 남아 있는 계약 전부)에 대해서 C라는 조건을 만족시에는 모두 청산
위 1~4의 조건은 어떤 것이 먼저 만족할 지는 상황에 따라 다릅니다.
이와 같이 청산 전략을 세울경우 수식을 어떻게 만들어야 되나요?
(4번에서, C라는 조건이었는데, B라는 조건이라고 써놔서 혼란을 야기한 것 같습니다.)
알려주신 수식에서
var : count(0);
if MarketPosition == 1 then{
if CurrentContracts < CurrentContracts[1] and LatestExitName(0) == "bx1" Then
Condition1 = true;
if CurrentContracts < CurrentContracts[1] and LatestExitName(0) == "bx2" Then
Condition2 = true;
if CurrentContracts < CurrentContracts[1] and LatestExitName(0) == "bx3" Then
Condition3 = true;
if CurrentContracts < CurrentContracts[1] and LatestExitName(0) == "bx4" Then
Condition4 = true;
부분이 꼭 필요한가요?
각조건 별로...exitlong함수에서 currentcontracts*0.5나 currentcontracts를 써서 그냥 작성하면 오류가 나나요?
이래저래 청산되고 남은 계약수가 0이 되었을때는, exitlong이나 exitshort 함수가 실행되지 않도록 하는 작업이 꼭 필요한 것인지요? 그냥 currentcontracts 나 marketposition이 0이 되면 어차피 실행이 안되니 상관없는 것 아닌지 궁금합니다.
그냥, 위 예시에서.
if 진입 then
exitlong("",atlimit,EntryPrice+PriceScale*10,"",Floor(CurrentContracts*0.5),1);
if A조건 then
exitlong("",OnClose,def,"",Floor(CurrentContracts*0.5),1);
if B조건 then
exitlong("",OnClose,def,"",Floor(CurrentContracts*0.5),1);
if C조건 then
exitlong("",OnClose,def,"",Floor(CurrentContracts),1);
이런 식으로 해버리면 오류가 나나요?
다음글
이전글