커뮤니티
수식문의드립니다
2018-09-19 16:48:15
188
글번호 122162
아래처럼 답변 주셔서 돌려봤는데 안되서 Tcount 문제인가해서 기본값을 true로하고 시작종료시간 수식 지우고 했더니 챠트중에 맨처음 부분만 적용되고 끝나네요 ㅠㅠ
왜그런걸까요? 틱봉이라서 시간이 안먹히는건가요 아님 어떤 문제가 있는건가요?
input : 시작시간(90000),종료시간(30000);
Input : 당일누적수익틱수1(20),당일누적수익틱수2(10),당일누적손실틱수(80);
Var : N1(0),dayPl(0),당일누적수익1(0),당일누적수익2(0),당일누적손실(0),Xcond(false),Tcond(false);
당일누적수익1 = PriceScale*당일누적수익틱수1;
당일누적수익2 = PriceScale*당일누적수익틱수2;
당일누적손실 = PriceScale*당일누적손실틱수;
if (sdate != sdate[1] and stime >= 시작시간) or
(sdate == sdate[1] and stime >= 시작시간 and stime[1] < 시작시간) Then
{
Tcond == true;
Xcond = false;
N1 = NetProfit;
Condition1 = false;
}
if (sdate != sdate[1] and stime >= 종료시간) or
(sdate == sdate[1] and stime >= 종료시간 and stime[1] < 종료시간) Then
{
Tcond = false;
}
daypl = NetProfit-N1;
if daypl <= -PriceScale*10 Then
Condition1 = true;
if TotalTrades > TotalTrades[1] and
(IsExitName("dbp1",1) == true or IsExitName("dbp2",1) == true or IsExitName("dbl",1) == true or
IsExitName("dsp1",1) == true or IsExitName("dsp1",2) == true or IsExitName("dsl",1) == true) then
Xcond = true;
if Xcond == false and Tcond == true then
{
if /*매수진입조건*/ Then
{
buy("b");
}
if /*매도진입조건*/ Then
{
sell("s");
}
if MarketPosition == 1 then
{
if Condition1 == false then
ExitLong("dbp1",atlimit,EntryPrice+((당일누적수익1-daypl)/CurrentContracts));
Else
ExitLong("dbp2",atlimit,EntryPrice+((당일누적수익2-daypl)/CurrentContracts));
ExitLong("dbl",AtStop,EntryPrice-((당일누적손실+daypl)/CurrentContracts));
}
if MarketPosition == -1 then
{
if Condition1 == false then
ExitShort("dsp1",atlimit,EntryPrice-((당일누적수익1-daypl)/CurrentContracts));
Else
ExitShort("dsp2",atlimit,EntryPrice-((당일누적수익2-daypl)/CurrentContracts));
ExitShort("dsl",AtStop,EntryPrice+((당일누적손실+daypl)/CurrentContracts));
}
}
답변 1
예스스탁 예스스탁 답변
2018-09-19 17:20:38
안녕하세요
예스스탁입니다.
변수에 값할당 잘못되어 수정했습니다.
만약 지정한 종료시간에 포지션이 있으면 청산한다면
종료시간 체크 로직을 아래와 같이 변경하시면 됩니다.
각 수식의 종료시간 조건 내용을 아래와 같이 변경하시면 됩니다.
if (sdate != sdate[1] and stime >= 종료시간) or
(sdate == sdate[1] and stime >= 종료시간 and stime[1] < 종료시간) Then
{
Tcond = false;
if MarketPosition == 1 Then
ExitLong();
if MarketPosition == -1 Then
ExitShort();
}
1
input : 시작시간(90000),종료시간(30000);
Input : 당일누적수익틱수(20),당일누적손실틱수(15);
Var : N1(0),dayPl(0),당일누적수익(0),당일누적손실(0),Xcond(false),Tcond(false);
당일누적수익 = PriceScale*당일누적수익틱수;
당일누적손실 = PriceScale*당일누적손실틱수;
if (sdate != sdate[1] and stime >= 종료시간) or
(sdate == sdate[1] and stime >= 종료시간 and stime[1] < 종료시간) Then
{
Tcond = false;
}
if (sdate != sdate[1] and stime >= 시작시간) or
(sdate == sdate[1] and stime >= 시작시간 and stime[1] < 시작시간) Then
{
Tcond = true;
Xcond = false;
N1 = NetProfit;
}
daypl = NetProfit-N1;
if TotalTrades > TotalTrades[1] and
(IsExitName("dbp",1) == true or IsExitName("dbl",1) == true or
IsExitName("dsp",1) == true or IsExitName("dsl",1) == true) then
Xcond = true;
if Xcond == false and Tcond == true then
{
if /*매수진입조건*/ Then
{
buy("b");
}
if /*매도진입조건*/ Then
{
sell("s");
}
if MarketPosition == 1 then{
ExitLong("dbp",atlimit,EntryPrice+((당일누적수익-daypl)/CurrentContracts));
ExitLong("dbl",AtStop,EntryPrice-((당일누적손실+daypl)/CurrentContracts));
}
if MarketPosition == -1 then{
ExitShort("dsp",atlimit,EntryPrice-((당일누적수익-daypl)/CurrentContracts));
ExitShort("dsl",AtStop,EntryPrice+((당일누적손실+daypl)/CurrentContracts));
}
}
2
input : 시작시간(90000),종료시간(30000);
Input : 당일누적수익틱수1(20),당일누적수익틱수2(10),당일누적손실틱수(80);
Var : N1(0),dayPl(0),당일누적수익1(0),당일누적수익2(0),당일누적손실(0),Xcond(false),Tcond(false);
당일누적수익1 = PriceScale*당일누적수익틱수1;
당일누적수익2 = PriceScale*당일누적수익틱수2;
당일누적손실 = PriceScale*당일누적손실틱수;
if (sdate != sdate[1] and stime >= 종료시간) or
(sdate == sdate[1] and stime >= 종료시간 and stime[1] < 종료시간) Then
{
Tcond = false;
}
if (sdate != sdate[1] and stime >= 시작시간) or
(sdate == sdate[1] and stime >= 시작시간 and stime[1] < 시작시간) Then
{
Tcond = true;
Xcond = false;
N1 = NetProfit;
Condition1 = false;
}
daypl = NetProfit-N1;
if daypl <= -PriceScale*10 Then
Condition1 = true;
if TotalTrades > TotalTrades[1] and
(IsExitName("dbp1",1) == true or
IsExitName("dbp2",1) == true or
IsExitName("dbl",1) == true or
IsExitName("dsp1",1) == true or
IsExitName("dsp1",2) == true or
IsExitName("dsl",1) == true) then
Xcond = true;
if Xcond == false and Tcond == true then
{
if /*매수진입조건*/ crossup(C,ma(C,20)) Then
{
buy("b");
}
if /*매도진입조건*/ CrossDown(C,ma(C,20)) Then
{
sell("s");
}
if MarketPosition == 1 then
{
if Condition1 == false then
ExitLong("dbp1",atlimit,EntryPrice+((당일누적수익1-daypl)/CurrentContracts));
Else
ExitLong("dbp2",atlimit,EntryPrice+((당일누적수익2-daypl)/CurrentContracts));
ExitLong("dbl",AtStop,EntryPrice-((당일누적손실+daypl)/CurrentContracts));
}
if MarketPosition == -1 then
{
if Condition1 == false then
ExitShort("dsp1",atlimit,EntryPrice-((당일누적수익1-daypl)/CurrentContracts));
Else
ExitShort("dsp2",atlimit,EntryPrice-((당일누적수익2-daypl)/CurrentContracts));
ExitShort("dsl",AtStop,EntryPrice+((당일누적손실+daypl)/CurrentContracts));
}
}
즐거운 하루되세요
> toal 님이 쓴 글입니다.
> 제목 : 수식문의드립니다
> 아래처럼 답변 주셔서 돌려봤는데 안되서 Tcount 문제인가해서 기본값을 true로하고 시작종료시간 수식 지우고 했더니 챠트중에 맨처음 부분만 적용되고 끝나네요 ㅠㅠ
왜그런걸까요? 틱봉이라서 시간이 안먹히는건가요 아님 어떤 문제가 있는건가요?
input : 시작시간(90000),종료시간(30000);
Input : 당일누적수익틱수1(20),당일누적수익틱수2(10),당일누적손실틱수(80);
Var : N1(0),dayPl(0),당일누적수익1(0),당일누적수익2(0),당일누적손실(0),Xcond(false),Tcond(false);
당일누적수익1 = PriceScale*당일누적수익틱수1;
당일누적수익2 = PriceScale*당일누적수익틱수2;
당일누적손실 = PriceScale*당일누적손실틱수;
if (sdate != sdate[1] and stime >= 시작시간) or
(sdate == sdate[1] and stime >= 시작시간 and stime[1] < 시작시간) Then
{
Tcond == true;
Xcond = false;
N1 = NetProfit;
Condition1 = false;
}
if (sdate != sdate[1] and stime >= 종료시간) or
(sdate == sdate[1] and stime >= 종료시간 and stime[1] < 종료시간) Then
{
Tcond = false;
}
daypl = NetProfit-N1;
if daypl <= -PriceScale*10 Then
Condition1 = true;
if TotalTrades > TotalTrades[1] and
(IsExitName("dbp1",1) == true or IsExitName("dbp2",1) == true or IsExitName("dbl",1) == true or
IsExitName("dsp1",1) == true or IsExitName("dsp1",2) == true or IsExitName("dsl",1) == true) then
Xcond = true;
if Xcond == false and Tcond == true then
{
if /*매수진입조건*/ Then
{
buy("b");
}
if /*매도진입조건*/ Then
{
sell("s");
}
if MarketPosition == 1 then
{
if Condition1 == false then
ExitLong("dbp1",atlimit,EntryPrice+((당일누적수익1-daypl)/CurrentContracts));
Else
ExitLong("dbp2",atlimit,EntryPrice+((당일누적수익2-daypl)/CurrentContracts));
ExitLong("dbl",AtStop,EntryPrice-((당일누적손실+daypl)/CurrentContracts));
}
if MarketPosition == -1 then
{
if Condition1 == false then
ExitShort("dsp1",atlimit,EntryPrice-((당일누적수익1-daypl)/CurrentContracts));
Else
ExitShort("dsp2",atlimit,EntryPrice-((당일누적수익2-daypl)/CurrentContracts));
ExitShort("dsl",AtStop,EntryPrice+((당일누적손실+daypl)/CurrentContracts));
}
}
다음글