커뮤니티
수식 부탁드립니다.
2017-01-31 13:55:03
109
글번호 106367
아래식에서 40틱상승청산이(매수든 매도든) 2번 발생하면 그날 거래는 종료하고 싶습니다.
수식 수정좀 부탁드립니다.
당일손실 = -PriceScale*당일누적손실틱수;
if stime == 종료시간 or (stime > 종료시간 and stime[1] < 종료시간) Then
{
Tcond = false;
if MarketPosition == 1 Then
ExitLong("종료시간 매수청산");
if MarketPosition == -1 Then
ExitShort("종료시간 매도청산");
}
if stime == 시작시간 or (stime > 시작시간 and stime[1] < 시작시간) Then
{
T = 0;
Tcond = true;
Xcond = false;
N1 = NetProfit;
}
daypl = NetProfit-N1;
if TotalTrades > TotalTrades[1] and (IsExitName("누적손실매수청산",1) or IsExitName("누적손실매도청산",1)) Then
Xcond = true;
if mav3 > mav3[1] and crossup(macdv,macds) Then{
T = 1;
ii = index;
}
if mav3 < mav3[1] and CrossDown(macdv,macds) Then{
T = -1;
ii = index;
}
if Tcond == true and Xcond == false then{
if MarketPosition == 0 and T == 1 and index <= ii+10 and CrossDown(c,mav) Then
buy("매수");
if MarketPosition == 0 and T == -1 and index <= ii+10 and CrossUp(c,mav) Then
sell("매도");
}
if MarketPosition == 1 then{
ExitLong("40틱상승매수청산",atlimit,EntryPrice+PriceScale*40);
ExitLong("누적손실매수청산",atlimit,EntryPrice-당일손실-daypl );
if CrossDown(mav1,mav2) Then
exitlong("10일선하향청산");
}
if MarketPosition == -1 then{
ExitShort("40틱상승매도청산",atlimit,EntryPrice-PriceScale*40);
ExitShort("누적손실매도청산",atlimit,EntryPrice+당일손실+daypl );
if CrossUp(mav1,mav2) Then
ExitShort("10일선상향청산");
}
답변 1
예스스탁 예스스탁 답변
2017-01-31 17:44:49
안녕하세요
예스스탁입니다.
var : Xcond1(false),Xcnt(0);
당일손실 = -PriceScale*당일누적손실틱수;
if stime == 종료시간 or (stime > 종료시간 and stime[1] < 종료시간) Then
{
Tcond = false;
if MarketPosition == 1 Then
ExitLong("종료시간 매수청산");
if MarketPosition == -1 Then
ExitShort("종료시간 매도청산");
}
if stime == 시작시간 or (stime > 시작시간 and stime[1] < 시작시간) Then
{
T = 0;
Tcond = true;
Xcond = false;
Xcond1 = false;
Xcnt = 0;
N1 = NetProfit;
}
daypl = NetProfit-N1;
if TotalTrades > TotalTrades[1] and (IsExitName("누적손실매수청산",1) or IsExitName("누적손실매도청산",1)) Then
Xcond = true;
if TotalTrades > TotalTrades[1] and (IsExitName("40틱상승매수청산",1) or IsExitName("40틱상승매도청산",1)) Then{
Xcnt = Xcnt+1;
if Xcnt == 2 Then
Xcond1 = true;
}
if mav3 > mav3[1] and crossup(macdv,macds) Then{
T = 1;
ii = index;
}
if mav3 < mav3[1] and CrossDown(macdv,macds) Then{
T = -1;
ii = index;
}
if Tcond == true and Xcond == false and Xcond1 == false then{
if MarketPosition == 0 and T == 1 and index <= ii+10 and CrossDown(c,mav) Then
buy("매수");
if MarketPosition == 0 and T == -1 and index <= ii+10 and CrossUp(c,mav) Then
sell("매도");
}
if MarketPosition == 1 then{
ExitLong("40틱상승매수청산",atlimit,EntryPrice+PriceScale*40);
ExitLong("누적손실매수청산",atlimit,EntryPrice-당일손실-daypl );
if CrossDown(mav1,mav2) Then
exitlong("10일선하향청산");
}
if MarketPosition == -1 then{
ExitShort("40틱상승매도청산",atlimit,EntryPrice-PriceScale*40);
ExitShort("누적손실매도청산",atlimit,EntryPrice+당일손실+daypl );
if CrossUp(mav1,mav2) Then
ExitShort("10일선상향청산");
}
즐거운 하루되세요
> 바바큰 님이 쓴 글입니다.
> 제목 : 수식 부탁드립니다.
> 아래식에서 40틱상승청산이(매수든 매도든) 2번 발생하면 그날 거래는 종료하고 싶습니다.
수식 수정좀 부탁드립니다.
당일손실 = -PriceScale*당일누적손실틱수;
if stime == 종료시간 or (stime > 종료시간 and stime[1] < 종료시간) Then
{
Tcond = false;
if MarketPosition == 1 Then
ExitLong("종료시간 매수청산");
if MarketPosition == -1 Then
ExitShort("종료시간 매도청산");
}
if stime == 시작시간 or (stime > 시작시간 and stime[1] < 시작시간) Then
{
T = 0;
Tcond = true;
Xcond = false;
N1 = NetProfit;
}
daypl = NetProfit-N1;
if TotalTrades > TotalTrades[1] and (IsExitName("누적손실매수청산",1) or IsExitName("누적손실매도청산",1)) Then
Xcond = true;
if mav3 > mav3[1] and crossup(macdv,macds) Then{
T = 1;
ii = index;
}
if mav3 < mav3[1] and CrossDown(macdv,macds) Then{
T = -1;
ii = index;
}
if Tcond == true and Xcond == false then{
if MarketPosition == 0 and T == 1 and index <= ii+10 and CrossDown(c,mav) Then
buy("매수");
if MarketPosition == 0 and T == -1 and index <= ii+10 and CrossUp(c,mav) Then
sell("매도");
}
if MarketPosition == 1 then{
ExitLong("40틱상승매수청산",atlimit,EntryPrice+PriceScale*40);
ExitLong("누적손실매수청산",atlimit,EntryPrice-당일손실-daypl );
if CrossDown(mav1,mav2) Then
exitlong("10일선하향청산");
}
if MarketPosition == -1 then{
ExitShort("40틱상승매도청산",atlimit,EntryPrice-PriceScale*40);
ExitShort("누적손실매도청산",atlimit,EntryPrice+당일손실+daypl );
if CrossUp(mav1,mav2) Then
ExitShort("10일선상향청산");
}
다음글