예스스탁
예스스탁 답변
2020-12-04 10:12:19
안녕하세요
예스스탁입니다.
input : 최대투자금액(1500);
input : MFIPeriod(14);
input : MFI값1(20);
input : MFI값2(30);
input : MFI값3(40);
input : MFI진입금액1(10);
input : MFI진입금액2(20);
input : MFI진입금액3(30);
Input : RSIPeriod(14);
Input : RSI값1(20);
Input : RSI값2(30);
Input : RSI값3(40);
input : RSI진입금액1(10);
input : RSI진입금액2(20);
input : RSI진입금액3(30);
Input : MFI값4(70);
Input : RSI값4(76);
var : cnt(0),sum1(0),sum2(0),MFIv(0);
var : SigSum(0),count2(0),RSIsig(0);
Var : Counter(0), DownAmt(0), UpAmt(0), UpSum(0), DownSum(0), UpAvg(0), DownAvg(0);
var : idx(0), PreUpAvg(0), preDownAvg(0),RSIV(0),Xcnt(0);
Array : C1[100](0);
sum1 = 0;
sum2 = 0;
for cnt = 0 to MFIPeriod-1{
if (dayhigh(cnt)+daylow(cnt)+DayClose(cnt)) > (dayhigh(cnt+1)+daylow(cnt+1)+DayClose(cnt+1)) Then
sum1 = sum1 + DayVolume(cnt)*(dayhigh(cnt)+daylow(cnt)+DayClose(cnt))/3;
Else
sum1 = sum1+0;
if (dayhigh(cnt)+daylow(cnt)+DayClose(cnt)) < (dayhigh(cnt+1)+daylow(cnt+1)+DayClose(cnt+1)) Then
sum2 = sum2 + DayVolume(cnt)*(dayhigh(cnt)+daylow(cnt)+DayClose(cnt))/3;
Else
sum2 = sum2+0;
}
MFIv = 100 - 100 / (1 + (sum1 / sum2));
if Bdate != Bdate[1] Then
{
for cnt = 1 to 99
{
C1[cnt] = C1[cnt-1][1];
}
PreUpAvg = UpAvg[1];
preDownAvg = DownAvg[1];
idx = idx + 1;
}
C1[0] = C;
If idx == RSIPeriod+2 Then
{
UpSum = 0;
DownSum = 0;
For Counter = 0 To RSIPeriod - 1
{
UpAmt = C1[Counter] - C1[Counter+1];
If UpAmt >= 0 Then
DownAmt = 0;
Else
{
DownAmt = -UpAmt;
UpAmt = 0;
}
UpSum = UpSum + UpAmt;
DownSum = DownSum + DownAmt;
}
UpAvg = UpSum / RSIPeriod;
DownAvg = DownSum / RSIPeriod;
}
If idx > RSIPeriod+2 Then
{
UpAmt = C1[0] - C1[1];
If UpAmt >= 0 Then
DownAmt = 0;
Else
{
DownAmt = -UpAmt;
UpAmt = 0;
}
UpAvg = (PreUpAvg * (RSIPeriod - 1) + UpAmt) / RSIPeriod;
DownAvg = (preDownAvg * (RSIPeriod - 1) + DownAmt) / RSIPeriod;
}
If UpAvg + DownAvg <> 0 Then
RSIv = 100 * UpAvg / (UpAvg + DownAvg);
Else
RSIv = 0;
if MarketPosition == 0 or (MarketPosition == 1 and AvgEntryPrice*CurrentContracts < 최대투자금액*10000 ) Then
{
if (NextBarSdate != sdate[1] and NextBarStime >= 151000) or
(NextBarSdate == sdate[1] and NextBarStime >= 151000 and stime < 151000) Then
{
value1 = 0;
if MFIv < MFI값1 Then
value1 = value1+MFI진입금액1*10000;
if MFIv < MFI값2 Then
value1 = value1+MFI진입금액2*10000;
if MFIv < MFI값3 Then
value1 = value1+MFI진입금액3*10000;
if RSIv < RSI값1 Then
value1 = value1+RSI진입금액1*10000;
if RSIv < RSI값2 Then
value1 = value1+RSI진입금액2*10000;
if RSIv < RSI값3 Then
value1 = value1+RSI진입금액3*10000;
if value1 > 0 and (MarketPosition == 0 or (MarketPosition == 1 and Xcnt == 0)) Then
Buy("b",AtMarket,DEF,Floor(value1/NextBarOpen));
}
}
if MarketPosition == 1 Then
{
if MFIv > MFI값4 or RSIv > RSI값4 Then
{
if CurrentContracts*AvgEntryPrice < 5000000 Then
ExitLong("bx1",AtLimit,AvgEntryPrice*1.0115);
if CurrentContracts*AvgEntryPrice >= 5000000 and CurrentContracts*AvgEntryPrice < 10000000 Then
ExitLong("bx2",AtLimit,AvgEntryPrice*1.011);
if CurrentContracts*AvgEntryPrice >= 10000000 and CurrentContracts*AvgEntryPrice < 15000000 Then
ExitLong("bx3",AtLimit,AvgEntryPrice*1.0105);
}
}
Else
Xcnt = 0;
즐거운 하루되세요
> 이형지 님이 쓴 글입니다.
> 제목 : 국내주식 수식에 기능 추가 부탁드림니다.
> 전에 알려주신 수식에 다음 기능을 추가로 반영하고 싶습니다.
현재 매수 청산수식은 MFI 또는 RSI 값이 조건에 의해 일괄 청산하는 수식인데요...
활용하다가 보니 다음 기능을 부여하고 싶습니다.
1. 누적 매수금액이 0원 ~ 500만원 사이일때
1번 조건 : ( MFI(14)> 70 or RSI(14)> 76 )
2번 조건 : 매수 평균가 보다 1.15% 이상시
1.2 번의 교집합일때 청산하는 수식을 추가
2. 누적 매수금액이 500만원 ~ 1000만원 사이일때
1번 조건 : ( MFI(14)> 70 or RSI(14)> 76 )
2번 조건 : 매수 평균가 보다 1.1% 이상시
1.2 번의 교집합일때 청산하는 수식을 추가
3. 누적 매수금액이 1000만원 ~ 1500만원 사이일때
1번 조건 : ( MFI(14)> 70 or RSI(14)> 76 )
2번 조건 : 매수 평균가 보다 1.05% 이상시
1.2 번의 교집합일때 청산하는 수식을 추가
지금 쓰고 있는 수식입니다.
---------------------------------------------------------------
국내 주식 10분봉 셋팅
input : 최대투자금액(1500);
input : MFIPeriod(14);
input : MFI값1(20);
input : MFI값2(30);
input : MFI값3(40);
input : MFI진입금액1(10);
input : MFI진입금액2(20);
input : MFI진입금액3(30);
Input : RSIPeriod(14);
Input : RSI값1(20);
Input : RSI값2(30);
Input : RSI값3(40);
input : RSI진입금액1(10);
input : RSI진입금액2(20);
input : RSI진입금액3(30);
Input : MFI값4(70);
Input : RSI값4(76);
var : cnt(0),sum1(0),sum2(0),MFIv(0);
var : SigSum(0),count2(0),RSIsig(0);
Var : Counter(0), DownAmt(0), UpAmt(0), UpSum(0), DownSum(0), UpAvg(0), DownAvg(0);
var : idx(0), PreUpAvg(0), preDownAvg(0),RSIV(0),Xcnt(0);
Array : C1[100](0);
sum1 = 0;
sum2 = 0;
for cnt = 0 to MFIPeriod-1{
if (dayhigh(cnt)+daylow(cnt)+DayClose(cnt)) > (dayhigh(cnt+1)+daylow(cnt+1)+DayClose(cnt+1)) Then
sum1 = sum1 + DayVolume(cnt)*(dayhigh(cnt)+daylow(cnt)+DayClose(cnt))/3;
Else
sum1 = sum1+0;
if (dayhigh(cnt)+daylow(cnt)+DayClose(cnt)) < (dayhigh(cnt+1)+daylow(cnt+1)+DayClose(cnt+1)) Then
sum2 = sum2 + DayVolume(cnt)*(dayhigh(cnt)+daylow(cnt)+DayClose(cnt))/3;
Else
sum2 = sum2+0;
}
MFIv = 100 - 100 / (1 + (sum1 / sum2));
if Bdate != Bdate[1] Then
{
for cnt = 1 to 99
{
C1[cnt] = C1[cnt-1][1];
}
PreUpAvg = UpAvg[1];
preDownAvg = DownAvg[1];
idx = idx + 1;
}
C1[0] = C;
If idx == RSIPeriod+2 Then
{
UpSum = 0;
DownSum = 0;
For Counter = 0 To RSIPeriod - 1
{
UpAmt = C1[Counter] - C1[Counter+1];
If UpAmt >= 0 Then
DownAmt = 0;
Else
{
DownAmt = -UpAmt;
UpAmt = 0;
}
UpSum = UpSum + UpAmt;
DownSum = DownSum + DownAmt;
}
UpAvg = UpSum / RSIPeriod;
DownAvg = DownSum / RSIPeriod;
}
If idx > RSIPeriod+2 Then
{
UpAmt = C1[0] - C1[1];
If UpAmt >= 0 Then
DownAmt = 0;
Else
{
DownAmt = -UpAmt;
UpAmt = 0;
}
UpAvg = (PreUpAvg * (RSIPeriod - 1) + UpAmt) / RSIPeriod;
DownAvg = (preDownAvg * (RSIPeriod - 1) + DownAmt) / RSIPeriod;
}
If UpAvg + DownAvg <> 0 Then
RSIv = 100 * UpAvg / (UpAvg + DownAvg);
Else
RSIv = 0;
if MarketPosition == 0 or (MarketPosition == 1 and AvgEntryPrice*CurrentContracts < 최대투자금액*10000 ) Then
{
if (NextBarSdate != sdate[1] and NextBarStime >= 151000) or
(NextBarSdate == sdate[1] and NextBarStime >= 151000 and stime < 151000) Then
{
value1 = 0;
if MFIv < MFI값1 Then
value1 = value1+MFI진입금액1*10000;
if MFIv < MFI값2 Then
value1 = value1+MFI진입금액2*10000;
if MFIv < MFI값3 Then
value1 = value1+MFI진입금액3*10000;
if RSIv < RSI값1 Then
value1 = value1+RSI진입금액1*10000;
if RSIv < RSI값2 Then
value1 = value1+RSI진입금액2*10000;
if RSIv < RSI값3 Then
value1 = value1+RSI진입금액3*10000;
if value1 > 0 and (MarketPosition == 0 or (MarketPosition == 1 and Xcnt == 0)) Then
Buy("b",AtMarket,DEF,Floor(value1/NextBarOpen));
}
}
if MarketPosition == 1 Then
{
if MFIv > MFI값4 or RSIv > RSI값4 Then
ExitLong("bx2",AtMarket);
}
Else
Xcnt = 0;