커뮤니티
수식부탁드립니다
2009-08-03 07:57:09
613
글번호 23872
if MarketPosition != 1 Then{
Condition1 = false;
Condition2 = false;
Condition3 = false;
}
if MarketPosition != -1 Then{
Condition4 = false;
Condition5 = false;
Condition6 = false;
}
if C > O and macd(12,26) > macd(12,26)[1] and Condition2 == False Then{
buy("매수2");
Condition2 = true;
}
if crossup(ma(c,20),ma(C,80)) and Condition3 == False Then{
buy("매수3");
Condition3 = true;
}
if C < O and macd(12,26) < macd(12,26)[1] and Condition5 == False Then{
Sell("매도2");
Condition5 = true;
}
if crossdown(ma(c,20),ma(C,80))and Condition6 == False Then{
Sell("매도3");
Condition6 = true;
}
상기의 각식에서 이익청산후 발생하는 다음의 반대수식을 제한 하고자 합니다.
예를 들어 매수2에서 2포인트 이하의 수익이 발생하였다고 가정하면
그다음 신호가 매수이거나 매도에 관계없이 그대로 진행하고
매수2에서 2포인트 이상의 수익이 발생하였다고 가정하면
그다음신호는 매수일경우에는 그대로 실행하고
반대로 매도가 나오면 실행시키지 않고. 그다음에 나오는 매도는
실행할수 있도록 가능한가요[매수(o)-매도(x)-매도 (o)]
상기수식으로 곤란한다면
간단한 예제를 부탁드립니다.
답변 1
예스스탁 예스스탁 답변
2009-08-03 13:24:37
안녕하세요
예스스탁입니다.
if MarketPosition != 1 Then{
Condition1 = false;
Condition2 = false;
Condition3 = false;
}
if MarketPosition != -1 Then{
Condition4 = false;
Condition5 = false;
Condition6 = false;
}
if TotalTrades == 0 Then{ # 첫신호
if C > O and macd(12,26) > macd(12,26)[1] and Condition2 == False Then{
buy("첫매수2");
Condition2 = true;
}
if crossup(ma(c,20),ma(C,80)) and Condition3 == False Then{
buy("첫매수3");
Condition3 = true;
}
if C < O and macd(12,26) < macd(12,26)[1] and Condition5 == False Then{
Sell("첫매도2");
Condition5 = true;
}
if crossdown(ma(c,20),ma(C,80))and Condition6 == False Then{
Sell("첫매도3");
Condition6 = true;
}
}
if TotalTrades > 0 and PositionProfit(1) < 2 Then{ # 두번째 신호부터 전포지션수익이 2 미만일때
if C > O and macd(12,26) > macd(12,26)[1] and Condition2 == False Then{
buy("매수2");
Condition2 = true;
}
if crossup(ma(c,20),ma(C,80)) and Condition3 == False Then{
buy("매수3");
Condition3 = true;
}
if C < O and macd(12,26) < macd(12,26)[1] and Condition5 == False Then{
Sell("매도2");
Condition5 = true;
}
if crossdown(ma(c,20),ma(C,80))and Condition6 == False Then{
Sell("매도3");
Condition6 = true;
}
}
if TotalTrades > 0 and PositionProfit(1) >= 2 Then{ # 두번째 신호부터 전포지션수익이 2이상일때
if MarketPosition(1) == 1 Then{ # 전 포지션이 매수일때
if C > O and macd(12,26) > macd(12,26)[1] and Condition2 == False Then{
buy("매수22");
Condition2 = true;
}
if crossup(ma(c,20),ma(C,80)) and Condition3 == False Then{
buy("매수33");
Condition3 = true;
}
if C < O and macd(12,26) < macd(12,26)[1] and
countif(crossdown(ma(c,20),ma(C,80)),BarsSinceExit(1)) >= 1 and
Condition5 == False Then{
Sell("매도22");
Condition5 = true;
}
if crossdown(ma(c,20),ma(C,80)) and
CountIF(C < O and macd(12,26) < macd(12,26)[1],BarsSinceExit(1)) >= 1 and
Condition6 == False Then{
Sell("매도33");
Condition6 = true;
}
}
if MarketPosition(1) == -1 Then{ # 전 포지션이 매도일때
if C > O and macd(12,26) > macd(12,26)[1] and
CountIF(crossup(ma(c,20),ma(C,80)),BarsSinceExit(1)) >= 1 and
Condition2 == False Then{
buy("매수222");
Condition2 = true;
}
if crossup(ma(c,20),ma(C,80)) and
countif(C > O and macd(12,26) > macd(12,26)[1],BarsSinceExit(1)) >= 1 and
Condition3 == False Then{
buy("매수333");
Condition3 = true;
}
if C < O and macd(12,26) < macd(12,26)[1] and Condition5 == False Then{
Sell("매도222");
Condition5 = true;
}
if crossdown(ma(c,20),ma(C,80)) and Condition6 == False Then{
Sell("매도333");
Condition6 = true;
}
}
}
즐거운 하루되세요
> addwin7 님이 쓴 글입니다.
> 제목 : 수식부탁드립니다
> if MarketPosition != 1 Then{
Condition1 = false;
Condition2 = false;
Condition3 = false;
}
if MarketPosition != -1 Then{
Condition4 = false;
Condition5 = false;
Condition6 = false;
}
if C > O and macd(12,26) > macd(12,26)[1] and Condition2 == False Then{
buy("매수2");
Condition2 = true;
}
if crossup(ma(c,20),ma(C,80)) and Condition3 == False Then{
buy("매수3");
Condition3 = true;
}
if C < O and macd(12,26) < macd(12,26)[1] and Condition5 == False Then{
Sell("매도2");
Condition5 = true;
}
if crossdown(ma(c,20),ma(C,80))and Condition6 == False Then{
Sell("매도3");
Condition6 = true;
}
상기의 각식에서 이익청산후 발생하는 다음의 반대수식을 제한 하고자 합니다.
예를 들어 매수2에서 2포인트 이하의 수익이 발생하였다고 가정하면
그다음 신호가 매수이거나 매도에 관계없이 그대로 진행하고
매수2에서 2포인트 이상의 수익이 발생하였다고 가정하면
그다음신호는 매수일경우에는 그대로 실행하고
반대로 매도가 나오면 실행시키지 않고. 그다음에 나오는 매도는
실행할수 있도록 가능한가요[매수(o)-매도(x)-매도 (o)]
상기수식으로 곤란한다면
간단한 예제를 부탁드립니다.
다음글
이전글