답변완료
문의드립니다
혹시 이게 가능한지요?
신호가 나오는 캔들의 종가에 매수나 매도 진입인데요.
종가에 바로 진입하지 않고 조정받았다가 종가를 돌파할때 매수나 매도 진입 가능하게
수식을 짤 수 있나요?
즉, 신호가 나왔어도 조정받고 다시 종가를 돌파할 때 매수,
다시 종가를 깰 때 매도, 이렇게 진입이 조정 가능한지 질문 드립니다.
가능하다면
아래 수식에 첨가해 주시면 감사하겠습니다.
input : StartTime(101200),EndTime(114000);
input : Length(20), D1(2);
input : 익절1(30),손절1(30),청산구분시간(103000),익절2(50),손절2(30),익절연속횟수(3),손절연속횟수(2);
var : Tcond(false),profit(0),loss(0);
if (sdate != sdate[1] and stime >= EndTime) or
(sdate == sdate[1] and stime >= EndTime and stime[1] < EndTime) Then
Tcond = False;
if (sdate != sdate[1] and stime >= StartTime) or
(sdate == sdate[1] and stime >= StartTime and stime[1] < StartTime) Then
{
Tcond = true;
profit = 0;
loss = 0;
}
if TotalTrades > TotalTrades[1] Then
{
if IsExitName("bp1.",1) or IsExitName("bp2.",21) or IsExitName("bp1",1) or IsExitName("bp2",21) or
IsExitName("sp1.",1) or IsExitName("sp2.",1) or IsExitName("sp1",1) or IsExitName("sp2",1) Then
profit = profit+1;
Else
profit = 0;
if IsExitName("bl1.",1) or IsExitName("bl2.",1) or IsExitName("bl1",1) or IsExitName("bl2",1) or
IsExitName("sl1.",1) or IsExitName("sl2.",1) or IsExitName("sl1",1) or IsExitName("sl2",1) Then
loss = loss+1;
Else
loss = 0;
}
var1 = BollBandUp(Length,D1);
var2 = BollBandDown(Length,D1);
if Tcond == true Then
{
If CrossUP(H,var1) and (c > o or (C==O and C >= C[1])) and profit < 익절연속횟수 and loss < 손절연속횟수 then
{
Buy("b",OnClose,DEF,1);
if sTime >= StartTime and sTime < 청산구분시간 Then
{
ExitLong("bp1.",AtLimit,C+PriceScale*익절1,"",1,1);
ExitLong("bl1.",AtStop,C-PriceScale*손절1,"",1,1);
}
if sTime >= 청산구분시간 and sTime < Endtime Then
{
ExitLong("bp2.",AtLimit,C+PriceScale*익절2,"",1,1);
ExitLong("bl2.",AtStop,C-PriceScale*손절2,"",1,1);
}
}
If CrossDown(L,Var2) and (C < O or (C==O and C < C[1])) and profit < 익절연속횟수 and loss < 손절연속횟수 then
{
Sell("s",OnClose,DEF,1);
if sTime >= StartTime and sTime < 103000 Then
{
ExitShort("sp1.",AtLimit,C-PriceScale*익절1,"",1,1);
ExitShort("sl1.",AtStop,C+PriceScale*손절1,"",1,1);
}
if sTime >= 103000 and sTime < Endtime Then
{
ExitShort("sp2.",AtLimit,C-PriceScale*익절2,"",1,1);
ExitShort("sl2.",AtStop,C+PriceScale*손절2,"",1,1);
}
}
}
if MarketPosition == 1 Then
{
if sTime >= StartTime and sTime < 청산구분시간 Then
{
ExitLong("bp1",AtLimit,EntryPrice+PriceScale*익절1,"",1,1);
ExitLong("bl1",AtStop,EntryPrice-PriceScale*손절1,"",1,1);
}
if sTime >= 청산구분시간 and sTime < Endtime Then
{
ExitLong("bp2",AtLimit,EntryPrice+PriceScale*익절2,"",1,1);
ExitLong("bl2",AtStop,EntryPrice-PriceScale*손절2,"",1,1);
}
}
if MarketPosition == -1 Then
{
if sTime >= StartTime and sTime < 103000 Then
{
ExitShort("sp1",AtLimit,EntryPrice-PriceScale*익절1,"",1,1);
ExitShort("sl1",AtStop,EntryPrice+PriceScale*손절1,"",1,1);
}
if sTime >= 103000 and sTime < Endtime Then
{
ExitShort("sp2",AtLimit,EntryPrice-PriceScale*익절2,"",1,1);
ExitShort("sl2",AtStop,EntryPrice+PriceScale*손절2,"",1,1);
}
}
IF Endtime > starttime Then
SetStopEndofday(Endtime);
Else
{
if sDate != sDate[1] Then
SetStopEndofday(Endtime);
}
if (sdate != sdate[1] and stime >= StartTime) or
(sdate == sdate[1] and stime >= StartTime and stime[1] < StartTime) Then
{
IF Endtime <= starttime Then
{
SetStopEndofday(0);
}
}
2021-10-27
694
글번호 153204
시스템
답변완료
수고하십니다
수고하십니다
7445번 재차요청입니다
아래 수식은 직전파동 조정대입니다
여기에 추가 요청 합니다
Input:종가사용여부(0),파동선두께(0),수치표시(1);
Var:j(0),jj(0),HH(0),LL(0),최종고가(0),최종저가(0),최종꼭지점(""),처리구분(""),
TL1(0),Text1(0),tl2(0);
Array:고[10,4](0),저[10,4](0); // 1:가격,2:Index,3:sDate,4:sTime
#==========================================#
HH = IFF(종가사용여부==1,C,H);
LL = IFF(종가사용여부==1,C,L);
If Index == 0 Then
{
고[1,1] = HH;
저[1,1] = LL;
}
Condition1 = Highest(HH,100) == HH and 최종고가 <> HH;
Condition2 = Lowest (LL,100) == LL and 최종저가 <> LL;
처리구분 = "";
If Condition1 and Condition2 Then // 기간고점과 기간저점 동시 발생
{
If 최종꼭지점 == "저점" Then
{
If 저[1,1] > LL Then 처리구분 = "저점처리";
Else 처리구분 = "고점처리";
}
Else If 최종꼭지점 == "고점" Then
{
If 고[1,1] < HH Then 처리구분 = "고점처리";
Else 처리구분 = "저점처리";
}
}
Else If Condition1 Then 처리구분 = "고점처리";
Else If Condition2 Then 처리구분 = "저점처리";
#==========================================#
If 처리구분 == "고점처리" Then
{
최종고가 = HH; // 신규고점을 체크하기 위해 저장
If 최종꼭지점 == "저점" Then
{
For j = 10 DownTo 2
{
For jj = 1 To 4
{
고[j,jj] = 고[j-1,jj];
}
}
고[1,1] = HH;
고[1,2] = Index;
고[1,3] = sDate;
고[1,4] = sTime;
TL1 = TL_New(저[1,3],저[1,4],저[1,1],고[1,3],고[1,4],고[1,1]);
If 수치표시 == -1 Then
{
Text1 = Text_New(고[1,3],고[1,4],고[1,1],NumToStr(고[1,1],2));
Text_SetStyle(Text1, 2, 1);
Text_SetColor(Text1,BLACK);
}
TL_SetSize(TL1,파동선두께);
TL_SetColor(TL1,red);
}
Else If 고[1,1] < HH Then // 1번 고점보다 높은 고가 출현
{
고[1,1] = HH;
고[1,2] = Index;
고[1,3] = sDate;
고[1,4] = sTime;
TL_SetEnd(TL1,고[1,3],고[1,4],고[1,1]);
TL_SetEnd(TL2,고[1,3],고[1,4],고[1,1]);
// 시작점은 변동없고 끝점의 위치가 현재 봉으로 연장된 것임
If 수치표시 == -1 Then
{
Text_SetLocation(Text1,고[1,3],고[1,4],고[1,1]);
Text_SetString(Text1,NumToStr(고[1,1],2));
}
}
최종꼭지점 = "고점";
}
#==========================================#
If 처리구분 == "저점처리" Then
{
최종저가 = LL;
If 최종꼭지점 == "고점" then
{
For j = 10 DownTo 2
{
For jj = 1 To 4
{
저[j,jj] = 저[j-1,jj];
}
}
저[1,1] = LL;
저[1,2] = Index;
저[1,3] = sDate;
저[1,4] = sTime;
TL1 = TL_New(고[1,3],고[1,4],고[1,1],저[1,3],저[1,4],저[1,1]);
If 수치표시 == -1 Then
{
Text1 = Text_New(저[1,3],저[1,4],저[1,1],NumToStr(저[1,1],2));
Text_SetStyle(Text1, 2, 0);
Text_SetColor(Text1,BLACK);
}
TL_SetSize(TL1,파동선두께);
TL_SetColor(TL1,blue);
}
Else If 저[1,1] > LL then
{
저[1,1] = LL;
저[1,2] = Index;
저[1,3] = sDate;
저[1,4] = sTime;
TL_SetEnd(TL1,저[1,3],저[1,4],저[1,1]);
TL_SetEnd(TL2,저[1,3],저[1,4],저[1,1]);
If 수치표시 == -1 Then
{
Text_SetLocation(Text1,저[1,3],저[1,4],저[1,1]);
Text_SetString(Text1,NumToStr(저[1,1],2));
}
}
최종꼭지점 = "저점";
}
#===============피보나치 되돌림=======================#
Array: fr[15,4](0); // 1:비율, 2:값, 3:라인번호, 4:텍스트번호 <= 2차원 배열입니다.
If Index == 0 Then // 첫번째 칼럼에는 피보나치 비율을
{
fr[1,1] = 0;
fr[3,1] = 0.382;
fr[4,1] = 0.50;
fr[5,1] = 0.618;
fr[7,1] = 1;
}
If 최종꼭지점[1] == "고점" and 최종꼭지점 == "저점" Then // 추세가 바뀔 때 피보나치 라인을 계산
{
for j = 1 to 15
{
If fr[j,3] > 0 Then TL_Delete(fr[j,3]); // 기존의 라인은 지우고
fr[j,2] = 고[1,1] - ((고[1,1] - 저[2,1]) * fr[j,1]); // 피보나치 비율을 곱해서 계산
fr[j,3] = TL_New(고[1,3],고[1,4],fr[j,2],sDate,sTime,fr[j,2]); // 라인을 생성
TL_SetExtRight(fr[j,3],true);
}
}
Else If 최종꼭지점[1] == "저점" and 최종꼭지점 == "고점" Then
{
for j = 1 to 15
{
If fr[j,3] > 0 Then TL_Delete(fr[j,3]);
fr[j,2] = 저[1,1] + ((고[2,1] - 저[1,1]) * fr[j,1]);
fr[j,3] = TL_New(저[1,3],저[1,4],fr[j,2],sDate,sTime,fr[j,2]);
TL_SetExtRight(fr[j,3],true);
}
}
Else // 추세변동이 없으면 기존 피보나치 라인을 연장한다.
{
for j = 1 to 15
{
TL_SetEnd(fr[j,3],sDate,sTime,fr[j,2]);
}
}
for j = 1 to 15 {
If 수치표시 == 1 Then
{
If fr[j,4] > 0 Then Text_Delete(fr[j,4]);
fr[j,4] = Text_New(고[1,3],고[1,4],fr[j,2],"(" + NumToStr(fr[j,1]*100,1) + "%) " + NumToStr(fr[j,2],2));
Text_SetStyle(fr[j,4], 0, 1);
Text_SetColor(fr[j,4], Lgreen);
Text_SetLocation(fr[j,4], sdate, stime, fr[j,2]);
}
If 수치표시 == 1 Then
{
If fr[j,4] > 0 Then Text_Delete(fr[j,4]);
fr[j,4] = Text_New(저[1,3],저[1,4],fr[j,2],"(" + NumToStr(fr[j,1]*100,1) + "%) " + NumToStr(fr[j,2],2));
Text_SetStyle(fr[j,4], 0, 1);
Text_SetColor(fr[j,4], Lgreen);
Text_SetLocation(fr[j,4], sdate, stime, fr[j,2]);
}
2021-10-27
694
글번호 153201
지표