답변완료
문의 드립니다
수고 많으십니다.
아래 수식에서 3가지 변경 원합니다. 청산틱수,첫진입틱수,추가진입틱수 위치를 지정할 수 있도록 해주세요.
1.현재 진입되어 있는 물량의 청산틱수는 하락에서 상승으로, 상승에서 하락으로 추세가 바뀌는 시점에 전량 청산되는데, 추세가 바뀐 후 수 틱 혹은 몇 틱이 더 추가되는 지점으로 지정할 수 있도록 변경 부탁합니다.
2.현재 첫진입틱수는 추세가 바뀐 후 전고점, 전저점 대비 연속되는 추세에서 수 틱 혹은 몇 틱이 추가되는 지점에 첫진입 하도록 지정하는데, 진입 물량 청산 지점(진입 물량 청산 후)에 수 틱 혹은 몇 틱이 더 추가되는 지점으로 지정할 수 있도록 변경 부탁합니다.
3.추가진입틱수는 현재처럼 첫진입 후 첫진입 지점에 수 틱 혹은 몇 틱이 추가될 때마다 추가 진입할 수 있도록 지정할 수 있게 변경부탁합니다.
그리고 현재 수식에서 손절이나, 추가진입 수량을 단계마다 다르게 지정 한 부분은 그대로 사용할 수 있게 변경없이 유지시켜 주세요.
감사합니다, 수고하세요.
Input:length(12),손절틱수(990);
Var:j(0),lastHiVal(0),lastLoVal(0),sBar(0),eBar(0),TL1(0),TL2(0),TL3(0),Text1(0),처리구분(""),TL_Val1(0),TL_Val2(0),color(0);
var:T(0),B(0),Bx(0),S(0),Sx(0);
Array:고점[10,2](0),저점[10,2](0);
처리구분 = "";
If Highest(H,length) == H and lastHiVal <> H and Lowest(L,length) == L and lastLoVal <> L Then
{
If 저점[1,1] > L Then 처리구분 = "저점처리";
If 고점[1,1] < H Then 처리구분 = "고점처리";
}
Else If Highest(H,length) == H and lastHiVal <> H Then 처리구분 = "고점처리";
Else If Lowest(L,length) == L and lastLoVal <> L Then 처리구분 = "저점처리";
If 처리구분 == "고점처리" Then
{
T = 1;
lastHiVal = H;
If 고점[1,2] < 저점[1,2] Then
{
For j = 10 DownTo 2
{
고점[j,1] = 고점[j-1,1];
고점[j,2] = 고점[j-1,2];
}
}
If 고점[1,2] < 저점[1,2] or 고점[1,1] < H Then
{
고점[1,1] = H;
고점[1,2] = Index;
sBar = Index - 저점[1,2];
eBar = 0;
If TL_GetBeginDate(TL1) == sDate[sBar] and TL_GetBeginTime(TL1) == sTime[sBar] Then
{
TL_Delete(TL1);
Text_Delete(Text1);
If 고점[3,1][1] < 고점[2,1][1] and 고점[2,1][1] > 고점[1,1][1] and 저점[2,1][1] < 저점[1,1][1] Then
TL_Delete(TL2);
}
if 고점[1,1] > 고점[2,1] or 고점[2,1] == 0 Then{
color = RED;
# buy("b");
}
TL1 = TL_New(sDate[sBar],sTime[sBar],저점[1,1],sDate[eBar],sTime[eBar],고점[1,1]);
TL_SetColor(TL1,color);
Text1 = Text_New(sDate[eBar],sTime[eBar],고점[1,1],NumToStr(abs(고점[1,1]-저점[1,1])/PriceScale,0)+NewLine+NumToStr(고점[1,1],2));
Text_SetStyle(Text1, 2, 1);
If 고점[3,1] < 고점[2,1] and 고점[2,1] > 고점[1,1] and 저점[2,1] < 저점[1,1] Then
{
sBar = Index - 저점[2,2];
eBar = Index - 저점[1,2];
}
}
}
If 처리구분 == "저점처리" Then
{
T = -1;
lastLoVal = L;
If 저점[1,2] < 고점[1,2] Then
{
For j = 10 DownTo 2
{
저점[j,1] = 저점[j-1,1];
저점[j,2] = 저점[j-1,2];
}
}
If 저점[1,2] < 고점[1,2] or 저점[1,1] > L Then
{
저점[1,1] = L;
저점[1,2] = Index;
sBar = Index - 고점[1,2];
eBar = 0;
If TL_GetBeginDate(TL1) == sDate[sBar] and TL_GetBeginTime(TL1) == sTime[sBar] Then
{
TL_Delete(TL1);
Text_Delete(Text1);
If 저점[2,1][1] < 저점[1,1][1] and 저점[2,1][1] < 저점[3,1][1] and 고점[2,1][1] > 고점[1,1][1] Then
TL_Delete(TL3);
}
if 저점[1,1] < 저점[2,1] or 저점[2,1] == 0 Then{
color = blue;
# sell("s");
}
TL1 = TL_New(sDate[sBar],sTime[sBar],고점[1,1],sDate[eBar],sTime[eBar],저점[1,1]);
TL_SetColor(TL1,color);
Text1 = Text_New(sDate[eBar],sTime[eBar],저점[1,1],NumToStr(abs(고점[1,1]-저점[1,1])/PriceScale,0)+NewLine+NumToStr(저점[1,1],2));
Text_SetStyle(Text1, 2, 0);
If 저점[2,1] < 저점[1,1] and 저점[2,1] < 저점[3,1] and 고점[2,1] > 고점[1,1] Then
{
sBar = Index - 고점[2,2];
eBar = Index - 고점[1,2];
}
}
}
TL_SetSize(TL1,3);
input : N(10),첫진입틱수(241),추가진입틱수(200);
#상승구간의 마지막저점 저장
if Color == RED Then
{
var1 = 저점[2,1];
}
#하락구간의 마지막 고점 저장
if Color == BLUE Then
{
var2 = 고점[2,1];
}
if MarketPosition <= 0 Then
{
if color == BLUE and var1 > 0 and L > var1-PriceScale*첫진입틱수 Then
Buy("b",AtLimit,var1-PriceScale*첫진입틱수,1);
}
if MarketPosition == 1 Then
{
value1 = Floor(MaxEntries/N)+1;
Buy("bb",AtLimit,(var1[BarsSinceEntry]-PriceScale*첫진입틱수)-(PriceScale*추가진입틱수)*MaxEntries,value1);
if T == -1 and 고점[1,1] > 0 Then
ExitLong("bx1",AtLimit,고점[1,1]+PriceScale*1);
if T == 1 and 고점[2,1] > 0 Then
ExitLong("bx2",AtLimit,고점[2,1]+PriceScale*1);
}
if MarketPosition >= 0 Then
{
if Color == RED and Var2 > 0 and H < var2+PriceScale*첫진입틱수 Then
Sell("s",AtLimit,Var2+PriceScale*첫진입틱수,1);
}
if MarketPosition == -1 Then
{
value1 = Floor(MaxEntries/N)+1;
Sell("ss",AtLimit,(var2[BarsSinceEntry]+PriceScale*첫진입틱수)+(PriceScale*추가진입틱수)*MaxEntries,value1);
if T == 1 and 저점[1,1] > 0 Then
ExitShort("sx1",AtLimit,저점[1,1]-PriceScale*1);
if T == -1 and 저점[2,1] > 0 Then
ExitShort("sx2",AtLimit,저점[2,1]-PriceScale*1);
}
2023-08-17
1432
글번호 171489
시스템