예스스탁
예스스탁 답변
2024-04-15 14:34:28
안녕하세요
예스스탁입니다.
input : starttime(080300),Endtime(055700);
input : 타주기분(30),P(5),Period(5),period1(10),Period2(20);
input : 익절포인트수1(200),익절포인트수2(120),익절포인트수3(60),익절포인트수4(160),손절포인트수1(80),손절포인트수2(60),손절포인트수3(375),당일수익포인트수(950),당일손실포인트수(500);
Input : shortPeriod(12), longPeriod(26);
Input : af(0.02), maxAF(0.2);
INPUT : LENGTH(20);
VAR : TCHAN(0), BCHAN(0);
Var : value(0),value1(0);
Var : N1(0),dayPl(0),당일수익(0),당일손실(0),Xcond(false);
var : S1(0),D1(0),TM(0),TF(0),cnt(0),entry(0),bbup(0),bbdn(0),avgv1(0),avgv2(0);
var : sum1(0),mav1(0),sum2(0),mav2(0),sum3(0),mav3(0),avgv(0),Tcond(False),t(30),PROc(0);
Array : CC[100](0);
value = sar(af,maxAF);
value1 = MACD(shortPeriod, longPeriod);
TCHAN = HIGHEST(HIGH, LENGTH)[1];
BCHAN = LOWEST(LOW, LENGTH)[1];
PROC = PROC(Period1);
avgv = ma(c,Period);
avgv1 =ma(c,Period1);
avgv2 =ma(c,Period2);
bbup = BollBandUp(20,2);
bbdn = BollBandDown(20,2);
if sdate != sDate[1] Then
{
if StartTime < EndTime Then
SetStopEndofday(Endtime);
}
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
{
if StartTime < EndTime Then
SetStopEndofday(0);
Else
SetStopEndofday(EndTime);
S1 = TimeToMinutes(stime);
D1 = sdate;
entry = 0;
Condition3 = False;
Tcond = true;
Xcond = false;
N1 = NetProfit;
}
당일수익 = PriceScale*당일수익포인트수;
당일손실 = PriceScale*당일손실포인트수;
daypl = NetProfit-N1;
if TotalTrades > TotalTrades[1] then
{
if daypl >= 당일수익 or daypl <= -당일손실 Then
Xcond = true;
if (IsExitName("dbp",1) == true or IsExitName("dbl",1) == true or
IsExitName("dsp",1) == true or IsExitName("dsl",1) == true) then
Xcond = true;
}
if D1 > 0 then
{
if (MarketPosition != 0 and MarketPosition != MarketPosition[1]) or
(MarketPosition == MarketPosition[1] and TotalTrades > TotalTrades[1]) Then
entry = entry+1;
if sdate == D1 Then
TM = TimeToMinutes(stime)-S1;
Else
TM = TimeToMinutes(stime)+1440-S1;
TF = TM%타주기분;
if Bdate != Bdate[1] or
(Bdate == Bdate[1] and 타주기분 > 1 and TF < TF[1]) or
(Bdate == Bdate[1] and 타주기분 > 1 and TM >= TM[1]+타주기분) or
(Bdate == Bdate[1] and 타주기분 == 1 and TM > TM[1]) Then
{
for cnt = 1 to 99
{
CC[cnt] = CC[cnt-1][1];
}
}
CC[0] = C;
if CC[P+2] > 0 then
{
sum1 = 0;
sum2 = 0;
sum3 = 0;
for cnt = 0 to P-1
{
sum1 = sum1 + CC[cnt];
sum2 = sum2 + CC[cnt+1];
sum3 = sum3 + CC[cnt+2];
}
mav1 = sum1/P;
mav2 = sum2/P;
mav3 = sum3/P;
}
if Xcond == false and Tcond == true then
{
if MarketPosition >= 0 and mav1<mav2-2 and c>=avgv and !(avgv1[1]<avgv1 and avgv2[1]<avgv2 and avgv[1]<avgv)
and !(avgv>avgv1 and avgv1>avgv2)Then
{
#진입청산식1.
#진입청산식2
#진입청산식3
#
#
#진입청산식6
}
}
}
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));
}
if sTime >= 080300 and sTime < 160000 Then
{
SetStopProfittarget(PriceScale*익절포인트수3,PointStop);
SetStopLoss(PriceScale*손절포인트수3,PointStop);
}
Else if sTime >= 200000 or sTime < 060000 Then
{
SetStopProfittarget(PriceScale*익절포인트수1,PointStop);
SetStopLoss(PriceScale*손절포인트수3,PointStop);
}
Else
{
SetStopProfittarget(PriceScale*익절포인트수2,PointStop);
SetStopLoss(PriceScale*손절포인트수3,PointStop);
}
즐거운 하루되세요
> 동백초보 님이 쓴 글입니다.
> 제목 : 수식 검토 부탁합니다.
> 해외 선물 거래
1. 시작시간:08:03 종료시간:익일 05:57
2. 시작시간 부터 거래를 하다가 당일 목표 수익이나 손실에 도달하면 더 이상 거래를 하지 않도록 하려고 수식을 작성 하였는데 목표 수익이나 손실에 도달하여도 거래가 계속 됩니다. 아래 수식 검토 부탁 드립니다.
==========================================================================
input : starttime(080300),Endtime(055700);
input : 타주기분(30),P(5),Period(5),period1(10),Period2(20);
input : 익절포인트수1(200),익절포인트수2(120),익절포인트수3(60),익절포인트수4(160),손절포인트수1(80),손절포인트수2(60),손절포인트수3(375),당일수익포인트수(950),당일손실포인트수(500);
var : S1(0),D1(0),TM(0),TF(0),cnt(0),entry(0),bbup(0),bbdn(0),avgv1(0),avgv2(0);
var : sum1(0),mav1(0),sum2(0),mav2(0),sum3(0),mav3(0),avgv(0),Tcond(False),t(30),PROc(0);
Array : CC[100](0);
Input : af(0.02), maxAF(0.2);
Var : value(0),value1(0);
Var : N1(0),dayPl(0),당일수익(0),당일손실(0),Xcond(false);
value = sar(af,maxAF);
Input : shortPeriod(12), longPeriod(26);
value1 = MACD(shortPeriod, longPeriod);
INPUT : LENGTH(20);
VAR : TCHAN(0), BCHAN(0);
TCHAN = HIGHEST(HIGH, LENGTH)[1];
BCHAN = LOWEST(LOW, LENGTH)[1];
PROC = PROC(Period1);
avgv = ma(c,Period);
avgv1 =ma(c,Period1);
avgv2 =ma(c,Period2);
bbup = BollBandUp(20,2);
bbdn = BollBandDown(20,2);
if Bdate != Bdate[1] Then
{
S1 = TimeToMinutes(stime);
D1 = sdate;
entry = 0;
Condition3 = False;
}
{
if D1 > 0 then
if (MarketPosition != 0 and MarketPosition != MarketPosition[1]) or
(MarketPosition == MarketPosition[1] and TotalTrades > TotalTrades[1]) Then
entry = entry+1;
if sdate == D1 Then
TM = TimeToMinutes(stime)-S1;
Else
TM = TimeToMinutes(stime)+1440-S1;
TF = TM%타주기분;
if Bdate != Bdate[1] or
(Bdate == Bdate[1] and 타주기분 > 1 and TF < TF[1]) or
(Bdate == Bdate[1] and 타주기분 > 1 and TM >= TM[1]+타주기분) or
(Bdate == Bdate[1] and 타주기분 == 1 and TM > TM[1]) Then
{
for cnt = 1 to 99
{
CC[cnt] = CC[cnt-1][1];
}
}
CC[0] = C;
if CC[P+2] > 0 then
{
sum1 = 0;
sum2 = 0;
sum3 = 0;
for cnt = 0 to P-1
{
sum1 = sum1 + CC[cnt];
sum2 = sum2 + CC[cnt+1];
sum3 = sum3 + CC[cnt+2];
}
mav1 = sum1/P;
mav2 = sum2/P;
mav3 = sum3/P;
}
if sdate != sDate[1] Then
SetStopEndofday(Endtime);
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
{
SetStopEndofday(0);
Tcond = true;
}
당일수익 = PriceScale*당일수익포인트수;
당일손실 = PriceScale*당일손실포인트수;
if Bdate != Bdate[1] Then
{
Xcond = false;
N1 = NetProfit;
}
daypl = NetProfit-N1;
if TotalTrades > TotalTrades[1] then
{
if daypl >= 당일수익 or daypl <= -당일손실 Then
Xcond = true;
if (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 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));
}
{
if MarketPosition >= 0 and mav1<mav2-2 and c>=avgv and !(avgv1[1]<avgv1 and avgv2[1]<avgv2 and avgv[1]<avgv)
and !(avgv>avgv1 and avgv1>avgv2)Then
{
#진입청산식1.
#진입청산식2
#진입청산식3
#
#
#진입청산식6
if sTime >= 080300 and sTime < 160000 Then
{
SetStopProfittarget(PriceScale*익절포인트수3,PointStop);
SetStopLoss(PriceScale*손절포인트수3,PointStop);
}
Else if sTime >= 200000 or sTime < 060000 Then
{
SetStopProfittarget(PriceScale*익절포인트수1,PointStop);
SetStopLoss(PriceScale*손절포인트수3,PointStop);
}
Else
{
SetStopProfittarget(PriceScale*익절포인트수2,PointStop);
SetStopLoss(PriceScale*손절포인트수3,PointStop);
}
}
}
항상 도와주셔서 감사 드립니다.
에제 수정해주신 수식을 적용하니 새벽 6시에 거래가 종료되고 나서 거래 시작 시간인 오전 8시3분부터 밤 12시까지는 일절 진입이 안되고 있습니다. 검토 부탁 드립니다.
> 예스스탁 님이 쓴 글입니다.
> 제목 : Re : 수식 검토 부탁합니다.
>
안녕하세요
예스스탁입니다.
input : starttime(080300),Endtime(055700);
input : 타주기분(30),P(5),Period(5),period1(10),Period2(20);
input : 익절포인트수1(200),익절포인트수2(120),익절포인트수3(60),익절포인트수4(160),손절포인트수1(80),손절포인트수2(60),손절포인트수3(375),당일수익포인트수(950),당일손실포인트수(500);
Input : shortPeriod(12), longPeriod(26);
Input : af(0.02), maxAF(0.2);
INPUT : LENGTH(20);
VAR : TCHAN(0), BCHAN(0);
Var : value(0),value1(0);
Var : N1(0),dayPl(0),당일수익(0),당일손실(0),Xcond(false);
var : S1(0),D1(0),TM(0),TF(0),cnt(0),entry(0),bbup(0),bbdn(0),avgv1(0),avgv2(0);
var : sum1(0),mav1(0),sum2(0),mav2(0),sum3(0),mav3(0),avgv(0),Tcond(False),t(30),PROc(0);
Array : CC[100](0);
value = sar(af,maxAF);
value1 = MACD(shortPeriod, longPeriod);
TCHAN = HIGHEST(HIGH, LENGTH)[1];
BCHAN = LOWEST(LOW, LENGTH)[1];
PROC = PROC(Period1);
avgv = ma(c,Period);
avgv1 =ma(c,Period1);
avgv2 =ma(c,Period2);
bbup = BollBandUp(20,2);
bbdn = BollBandDown(20,2);
if sdate != sDate[1] Then
{
if StartTime < EndTime Then
SetStopEndofday(Endtime);
}
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
{
if StartTime < EndTime Then
SetStopEndofday(0);
Else
SetStopEndofday(EndTime);
S1 = TimeToMinutes(stime);
D1 = sdate;
entry = 0;
Condition3 = False;
Tcond = true;
Xcond = false;
N1 = NetProfit;
}
당일수익 = PriceScale*당일수익포인트수;
당일손실 = PriceScale*당일손실포인트수;
daypl = NetProfit-N1;
if TotalTrades > TotalTrades[1] then
{
if daypl >= 당일수익 or daypl <= -당일손실 Then
Xcond = true;
if (IsExitName("dbp",1) == true or IsExitName("dbl",1) == true or
IsExitName("dsp",1) == true or IsExitName("dsl",1) == true) then
Xcond = true;
}
if D1 > 0 then
{
if (MarketPosition != 0 and MarketPosition != MarketPosition[1]) or
(MarketPosition == MarketPosition[1] and TotalTrades > TotalTrades[1]) Then
entry = entry+1;
if sdate == D1 Then
TM = TimeToMinutes(stime)-S1;
Else
TM = TimeToMinutes(stime)+1440-S1;
TF = TM%타주기분;
if Bdate != Bdate[1] or
(Bdate == Bdate[1] and 타주기분 > 1 and TF < TF[1]) or
(Bdate == Bdate[1] and 타주기분 > 1 and TM >= TM[1]+타주기분) or
(Bdate == Bdate[1] and 타주기분 == 1 and TM > TM[1]) Then
{
for cnt = 1 to 99
{
CC[cnt] = CC[cnt-1][1];
}
}
CC[0] = C;
if CC[P+2] > 0 then
{
sum1 = 0;
sum2 = 0;
sum3 = 0;
for cnt = 0 to P-1
{
sum1 = sum1 + CC[cnt];
sum2 = sum2 + CC[cnt+1];
sum3 = sum3 + CC[cnt+2];
}
mav1 = sum1/P;
mav2 = sum2/P;
mav3 = sum3/P;
}
if Xcond == false and Tcond == true then
{
if MarketPosition >= 0 and mav1<mav2-2 and c>=avgv and !(avgv1[1]<avgv1 and avgv2[1]<avgv2 and avgv[1]<avgv)
and !(avgv>avgv1 and avgv1>avgv2)Then
{
#진입청산식1.
#진입청산식2
#진입청산식3
#
#
#진입청산식6
}
}
}
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));
}
if sTime >= 080300 and sTime < 160000 Then
{
SetStopProfittarget(PriceScale*익절포인트수3,PointStop);
SetStopLoss(PriceScale*손절포인트수3,PointStop);
}
Else if sTime >= 200000 or sTime < 060000 Then
{
SetStopProfittarget(PriceScale*익절포인트수1,PointStop);
SetStopLoss(PriceScale*손절포인트수3,PointStop);
}
Else
{
SetStopProfittarget(PriceScale*익절포인트수2,PointStop);
SetStopLoss(PriceScale*손절포인트수3,PointStop);
}
즐거운 하루되세요
> 동백초보 님이 쓴 글입니다.
> 제목 : 수식 검토 부탁합니다.
> 해외 선물 거래
1. 시작시간:08:03 종료시간:익일 05:57
2. 시작시간 부터 거래를 하다가 당일 목표 수익이나 손실에 도달하면 더 이상 거래를 하지 않도록 하려고 수식을 작성 하였는데 목표 수익이나 손실에 도달하여도 거래가 계속 됩니다. 아래 수식 검토 부탁 드립니다.
==========================================================================
input : starttime(080300),Endtime(055700);
input : 타주기분(30),P(5),Period(5),period1(10),Period2(20);
input : 익절포인트수1(200),익절포인트수2(120),익절포인트수3(60),익절포인트수4(160),손절포인트수1(80),손절포인트수2(60),손절포인트수3(375),당일수익포인트수(950),당일손실포인트수(500);
var : S1(0),D1(0),TM(0),TF(0),cnt(0),entry(0),bbup(0),bbdn(0),avgv1(0),avgv2(0);
var : sum1(0),mav1(0),sum2(0),mav2(0),sum3(0),mav3(0),avgv(0),Tcond(False),t(30),PROc(0);
Array : CC[100](0);
Input : af(0.02), maxAF(0.2);
Var : value(0),value1(0);
Var : N1(0),dayPl(0),당일수익(0),당일손실(0),Xcond(false);
value = sar(af,maxAF);
Input : shortPeriod(12), longPeriod(26);
value1 = MACD(shortPeriod, longPeriod);
INPUT : LENGTH(20);
VAR : TCHAN(0), BCHAN(0);
TCHAN = HIGHEST(HIGH, LENGTH)[1];
BCHAN = LOWEST(LOW, LENGTH)[1];
PROC = PROC(Period1);
avgv = ma(c,Period);
avgv1 =ma(c,Period1);
avgv2 =ma(c,Period2);
bbup = BollBandUp(20,2);
bbdn = BollBandDown(20,2);
if Bdate != Bdate[1] Then
{
S1 = TimeToMinutes(stime);
D1 = sdate;
entry = 0;
Condition3 = False;
}
{
if D1 > 0 then
if (MarketPosition != 0 and MarketPosition != MarketPosition[1]) or
(MarketPosition == MarketPosition[1] and TotalTrades > TotalTrades[1]) Then
entry = entry+1;
if sdate == D1 Then
TM = TimeToMinutes(stime)-S1;
Else
TM = TimeToMinutes(stime)+1440-S1;
TF = TM%타주기분;
if Bdate != Bdate[1] or
(Bdate == Bdate[1] and 타주기분 > 1 and TF < TF[1]) or
(Bdate == Bdate[1] and 타주기분 > 1 and TM >= TM[1]+타주기분) or
(Bdate == Bdate[1] and 타주기분 == 1 and TM > TM[1]) Then
{
for cnt = 1 to 99
{
CC[cnt] = CC[cnt-1][1];
}
}
CC[0] = C;
if CC[P+2] > 0 then
{
sum1 = 0;
sum2 = 0;
sum3 = 0;
for cnt = 0 to P-1
{
sum1 = sum1 + CC[cnt];
sum2 = sum2 + CC[cnt+1];
sum3 = sum3 + CC[cnt+2];
}
mav1 = sum1/P;
mav2 = sum2/P;
mav3 = sum3/P;
}
if sdate != sDate[1] Then
SetStopEndofday(Endtime);
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
{
SetStopEndofday(0);
Tcond = true;
}
당일수익 = PriceScale*당일수익포인트수;
당일손실 = PriceScale*당일손실포인트수;
if Bdate != Bdate[1] Then
{
Xcond = false;
N1 = NetProfit;
}
daypl = NetProfit-N1;
if TotalTrades > TotalTrades[1] then
{
if daypl >= 당일수익 or daypl <= -당일손실 Then
Xcond = true;
if (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 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));
}
{
if MarketPosition >= 0 and mav1<mav2-2 and c>=avgv and !(avgv1[1]<avgv1 and avgv2[1]<avgv2 and avgv[1]<avgv)
and !(avgv>avgv1 and avgv1>avgv2)Then
{
#진입청산식1.
#진입청산식2
#진입청산식3
#
#
#진입청산식6
if sTime >= 080300 and sTime < 160000 Then
{
SetStopProfittarget(PriceScale*익절포인트수3,PointStop);
SetStopLoss(PriceScale*손절포인트수3,PointStop);
}
Else if sTime >= 200000 or sTime < 060000 Then
{
SetStopProfittarget(PriceScale*익절포인트수1,PointStop);
SetStopLoss(PriceScale*손절포인트수3,PointStop);
}
Else
{
SetStopProfittarget(PriceScale*익절포인트수2,PointStop);
SetStopLoss(PriceScale*손절포인트수3,PointStop);
}
}
}