커뮤니티
62458 수식 중 오류가 있는듯 합니다..
2019-05-11 22:00:19
167
글번호 128607
분활 청산 되어야 하는데 "bx1"와 "sx1"만 청산됩니다..
2, 3, 4 계약일때 "bx1"와 "sx1"만 청산됩니다..분활청산이 안됩니다.
수식은 아래와 같습니다..
var : vol(0),cross(0);
input : 진입시작(90000),진입종료(040000),강제청산시간(050000);
var : Tcond(false);
if (sdate != sdate[1] and stime >= 진입시작) or
(sdate == sdate[1] and stime >= 진입시작 and stime[1] < 진입시작) then
{
Tcond = true;
vol = 1;
cross = 0;
}
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
{
if MarketPosition == 1 Then
ExitLong("bx");
if MarketPosition == -1 Then
ExitShort("sx");
}
if Tcond == true then
{
if MarketPosition <= 0 and tcond == true and crossup(C,dayopen) Then
{
if MarketPosition == -1 Then
{
cross = cross+1;
if cross == 2 Then
{
cross = 0;
vol = vol+1;
}
}
Else
{
cross = 0;
vol = 1;
}
buy("b",OnClose,def,min(4,vol));
}
if MarketPosition >= 0 and tcond == true and CrossDown(c,dayopen) Then
{
if MarketPosition == 1 Then
{
cross = cross+1;
if cross == 2 Then
{
cross = 0;
vol = vol+1;
}
}
Else
{
cross = 0;
vol = 1;
}
sell("s",OnClose,def,min(4,vol));
}
if MarketPosition == 1 then
{
if MaxEntries == 1 Then
ExitLong("bx1",atlimit,EntryPrice+PriceScale*20);
if MaxEntries == 2 Then
{
ExitLong("bx21",atlimit,EntryPrice+PriceScale*10,"",1,1);
ExitLong("bx22",atlimit,EntryPrice+PriceScale*30,"",1,1);
}
if MaxEntries == 3 Then
{
ExitLong("bx31",atlimit,EntryPrice+PriceScale*10,"",1,1);
ExitLong("bx32",atlimit,EntryPrice+PriceScale*20,"",1,1);
ExitLong("bx33",atlimit,EntryPrice+PriceScale*30,"",1,1);
}
if MaxEntries == 4 Then
{
ExitLong("bx41",atlimit,EntryPrice+PriceScale*10,"",1,1);
ExitLong("bx42",atlimit,EntryPrice+PriceScale*20,"",1,1);
ExitLong("bx43",atlimit,EntryPrice+PriceScale*30,"",1,1);
ExitLong("bx44",atlimit,EntryPrice+PriceScale*40,"",1,1);
}
}
if MarketPosition == -1 then
{
if MaxEntries == 1 Then
ExitShort("sx1",atlimit,EntryPrice-PriceScale*20);
if MaxEntries == 2 Then
{
ExitShort("sx21",atlimit,EntryPrice-PriceScale*10,"",1,1);
ExitShort("sx22",atlimit,EntryPrice-PriceScale*30,"",1,1);
}
if MaxEntries == 3 Then
{
ExitShort("sx31",atlimit,EntryPrice-PriceScale*10,"",1,1);
ExitShort("sx32",atlimit,EntryPrice-PriceScale*20,"",1,1);
ExitShort("sx33",atlimit,EntryPrice-PriceScale*30,"",1,1);
}
if MaxEntries == 4 Then
{
ExitShort("sx41",atlimit,EntryPrice-PriceScale*10,"",1,1);
ExitShort("sx42",atlimit,EntryPrice-PriceScale*20,"",1,1);
ExitShort("sx43",atlimit,EntryPrice-PriceScale*30,"",1,1);
ExitShort("sx44",atlimit,EntryPrice-PriceScale*40,"",1,1);
}
}
}
답변 1
예스스탁 예스스탁 답변
2019-05-14 11:17:09
안녕하세요
예스스탁입니다.
진입계약수로 판단해야 하는데 진입신호수로 판단하게 작성이 되어 있었습니다.
수정한 식입니다.
var : vol(0),cross(0);
input : 진입시작(90000),진입종료(040000),강제청산시간(050000);
var : Tcond(false);
if (sdate != sdate[1] and stime >= 진입시작) or
(sdate == sdate[1] and stime >= 진입시작 and stime[1] < 진입시작) then
{
Tcond = true;
vol = 1;
cross = 0;
}
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
{
if MarketPosition == 1 Then
ExitLong("bx");
if MarketPosition == -1 Then
ExitShort("sx");
}
if Tcond == true then
{
if MarketPosition <= 0 and tcond == true and crossup(C,dayopen) Then
{
if MarketPosition == -1 Then
{
cross = cross+1;
if cross == 2 Then
{
cross = 0;
vol = vol+1;
}
}
Else
{
cross = 0;
vol = 1;
}
buy("b",OnClose,def,min(4,vol));
}
if MarketPosition >= 0 and tcond == true and CrossDown(c,dayopen) Then
{
if MarketPosition == 1 Then
{
cross = cross+1;
if cross == 2 Then
{
cross = 0;
vol = vol+1;
}
}
Else
{
cross = 0;
vol = 1;
}
sell("s",OnClose,def,min(4,vol));
}
if MarketPosition == 1 then
{
if MaxContracts == 1 Then
ExitLong("bx1",atlimit,EntryPrice+PriceScale*20);
if MaxContracts == 2 Then
{
ExitLong("bx21",atlimit,EntryPrice+PriceScale*10,"",1,1);
ExitLong("bx22",atlimit,EntryPrice+PriceScale*30,"",1,1);
}
if MaxContracts == 3 Then
{
ExitLong("bx31",atlimit,EntryPrice+PriceScale*10,"",1,1);
ExitLong("bx32",atlimit,EntryPrice+PriceScale*20,"",1,1);
ExitLong("bx33",atlimit,EntryPrice+PriceScale*30,"",1,1);
}
if MaxContracts == 4 Then
{
ExitLong("bx41",atlimit,EntryPrice+PriceScale*10,"",1,1);
ExitLong("bx42",atlimit,EntryPrice+PriceScale*20,"",1,1);
ExitLong("bx43",atlimit,EntryPrice+PriceScale*30,"",1,1);
ExitLong("bx44",atlimit,EntryPrice+PriceScale*40,"",1,1);
}
}
if MarketPosition == -1 then
{
if MaxContracts == 1 Then
ExitShort("sx1",atlimit,EntryPrice-PriceScale*20);
if MaxContracts == 2 Then
{
ExitShort("sx21",atlimit,EntryPrice-PriceScale*10,"",1,1);
ExitShort("sx22",atlimit,EntryPrice-PriceScale*30,"",1,1);
}
if MaxContracts == 3 Then
{
ExitShort("sx31",atlimit,EntryPrice-PriceScale*10,"",1,1);
ExitShort("sx32",atlimit,EntryPrice-PriceScale*20,"",1,1);
ExitShort("sx33",atlimit,EntryPrice-PriceScale*30,"",1,1);
}
if MaxContracts == 4 Then
{
ExitShort("sx41",atlimit,EntryPrice-PriceScale*10,"",1,1);
ExitShort("sx42",atlimit,EntryPrice-PriceScale*20,"",1,1);
ExitShort("sx43",atlimit,EntryPrice-PriceScale*30,"",1,1);
ExitShort("sx44",atlimit,EntryPrice-PriceScale*40,"",1,1);
}
}
}
즐거운 하루되세요
> 레드골드 님이 쓴 글입니다.
> 제목 : 62458 수식 중 오류가 있는듯 합니다..
> 분활 청산 되어야 하는데 "bx1"와 "sx1"만 청산됩니다..
2, 3, 4 계약일때 "bx1"와 "sx1"만 청산됩니다..분활청산이 안됩니다.
수식은 아래와 같습니다..
var : vol(0),cross(0);
input : 진입시작(90000),진입종료(040000),강제청산시간(050000);
var : Tcond(false);
if (sdate != sdate[1] and stime >= 진입시작) or
(sdate == sdate[1] and stime >= 진입시작 and stime[1] < 진입시작) then
{
Tcond = true;
vol = 1;
cross = 0;
}
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
{
if MarketPosition == 1 Then
ExitLong("bx");
if MarketPosition == -1 Then
ExitShort("sx");
}
if Tcond == true then
{
if MarketPosition <= 0 and tcond == true and crossup(C,dayopen) Then
{
if MarketPosition == -1 Then
{
cross = cross+1;
if cross == 2 Then
{
cross = 0;
vol = vol+1;
}
}
Else
{
cross = 0;
vol = 1;
}
buy("b",OnClose,def,min(4,vol));
}
if MarketPosition >= 0 and tcond == true and CrossDown(c,dayopen) Then
{
if MarketPosition == 1 Then
{
cross = cross+1;
if cross == 2 Then
{
cross = 0;
vol = vol+1;
}
}
Else
{
cross = 0;
vol = 1;
}
sell("s",OnClose,def,min(4,vol));
}
if MarketPosition == 1 then
{
if MaxEntries == 1 Then
ExitLong("bx1",atlimit,EntryPrice+PriceScale*20);
if MaxEntries == 2 Then
{
ExitLong("bx21",atlimit,EntryPrice+PriceScale*10,"",1,1);
ExitLong("bx22",atlimit,EntryPrice+PriceScale*30,"",1,1);
}
if MaxEntries == 3 Then
{
ExitLong("bx31",atlimit,EntryPrice+PriceScale*10,"",1,1);
ExitLong("bx32",atlimit,EntryPrice+PriceScale*20,"",1,1);
ExitLong("bx33",atlimit,EntryPrice+PriceScale*30,"",1,1);
}
if MaxEntries == 4 Then
{
ExitLong("bx41",atlimit,EntryPrice+PriceScale*10,"",1,1);
ExitLong("bx42",atlimit,EntryPrice+PriceScale*20,"",1,1);
ExitLong("bx43",atlimit,EntryPrice+PriceScale*30,"",1,1);
ExitLong("bx44",atlimit,EntryPrice+PriceScale*40,"",1,1);
}
}
if MarketPosition == -1 then
{
if MaxEntries == 1 Then
ExitShort("sx1",atlimit,EntryPrice-PriceScale*20);
if MaxEntries == 2 Then
{
ExitShort("sx21",atlimit,EntryPrice-PriceScale*10,"",1,1);
ExitShort("sx22",atlimit,EntryPrice-PriceScale*30,"",1,1);
}
if MaxEntries == 3 Then
{
ExitShort("sx31",atlimit,EntryPrice-PriceScale*10,"",1,1);
ExitShort("sx32",atlimit,EntryPrice-PriceScale*20,"",1,1);
ExitShort("sx33",atlimit,EntryPrice-PriceScale*30,"",1,1);
}
if MaxEntries == 4 Then
{
ExitShort("sx41",atlimit,EntryPrice-PriceScale*10,"",1,1);
ExitShort("sx42",atlimit,EntryPrice-PriceScale*20,"",1,1);
ExitShort("sx43",atlimit,EntryPrice-PriceScale*30,"",1,1);
ExitShort("sx44",atlimit,EntryPrice-PriceScale*40,"",1,1);
}
}
}
다음글
이전글