예스스탁
예스스탁 답변
2022-05-18 13:51:08
안녕하세요
예스스탁입니다.
input : 금액(10000000),원하는_평단가요율(1.01),시작날짜(20200101);
var : Bcond(False),x(False);
var1 = Highest(c,15);
Var2 = Lowest(c,20);
var3 = Highest(c,20);
Var4 = Lowest(c,20);
....이하생략
Var11 = Lowest(c,20);
var12 = Highest(c,20);
Var13 = Lowest(c,40);
var14 = Highest(c,40);
....이하생략
if MarketPosition == 1 Then
{
if CurrentContracts > CurrentContracts[1] Then
{
if LatestEntryName(0) == "a1" Then
Condition1 = true;
if LatestEntryName(0) == "a3" Then
Condition3 = true;
...이하생략
if LatestEntryName(0) == "b1" Then
Condition11 = true;
if LatestEntryName(0) == "b2" Then
Condition13 = true;
...이하생략
}
//////////////////////////////////////////////////////////////////////////////////
if MarketPosition == 1 Then
exitlong("평단매도",atlimit,AvgEntryPrice*원하는_평단가요율);
///////////////////////////////////////////////////////////////////////////////////
}
Else
{
x = False;
Condition1 = False;
Condition3 = False;
...이하생략
Condition11 = False;
Condition13 = False;
...이하생략
}
Bcond = False;
if Bcond == False and x == False and CrossUp(c,var1[1]) and sDate >= 시작날짜 and Condition1 == False Then
{
Bcond = true;
Buy("a1",OnClose,DEf,((금액*(1/20))/C));
}
if Bcond == False and X == false and CrossDown(c,var11[1]) and sDate >= 시작날짜 and Condition11 == False Then
{
Bcond = true;
Buy("b1",OnClose,DEf,((금액*(1/20))/C));
}
var : AE1(0),Vol1(0),sum1(0),sum2(0),Vol2(0),AE2(0);
var : Xcond1(False),Xcond2(False);
if MarketPosition == 1 Then
{
if CurrentContracts < CurrentContracts[1] Then
{
if LatestExitName(0) == "bx1" Then
Xcond1 = true;
if LatestExitName(0) == "bx2" Then
Xcond2 = true;
}
if MaxEntries <= 10 Then
{
AE1 = AvgEntryPrice;
vol1 = CurrentContracts;
}
if Xcond1 == False and Vol1 > 0 Then
ExitLong("bx1",AtLimit,AE1*1.01,"",vol1,1);
if MaxEntries >= 9 and MaxEntries <= 11 Then
{
if CurrentContracts > CurrentContracts[1] Then
{
sum1 = sum1 + (CurrentContracts-CurrentContracts[1])*LatestEntryPrice(0);
sum2 = sum2 + (CurrentContracts-CurrentContracts[1]);
AE2 = sum1/sum2;
}
}
if MaxEntries >= 11 Then
{
if CurrentContracts > CurrentContracts[1] Then
{
Vol2 = Vol2 + (CurrentContracts-CurrentContracts[1]);
}
if Xcond2 == false Then
ExitLong("bx2",AtLimit,AE2*1.01,"",vol2,1);
}
}
Else
{
AE1 = 0;
vol1 = 0;
sum1 = 0;
sum2 = 0;
vol2 = 0;
AE2 = 0;
Xcond1 = False;
Xcond2 = False;
}
즐거운 하루되세요
> 유경완 님이 쓴 글입니다.
> 제목 : 분할매수후 평단가 매도시 일괄매도가 아닌 원하는 부부만 평단가 매도 질의
> 아래의 수식중 현재는 분할매수후 원하는 평단가 수익율에 해당되면 일괄 매도가 되도록 되어 있는데,
1. 일괄매도 명령을 수정하여 10회까지의 분할매수 수량은 현재와 같이 평단가 기준 1% 수익이 발생하면 일괄매도 하고,
2. 11회부터 20회까지 분할매수 들어가는 수량은 11회분 부터 직전 3회 까지의 분할매수 수량(예; 9~11회분,이하 동일)만의 평단가를 산정하여 1% 평단가 익절을 하도록 하고 싶습니다.
# 이유는; 20회까지 전량 분할 매수시 계속하여 하락 하게 되면 원금 전액이 묶이게 되므로 투자금의 회전이 안되므로, 10회 이후 부터는 자금 회전을 위하여 최근 분할 매수분 3회 까지의 매수 부분만 평가하여 바로바로 매도하도록 하고 싶습니다. 부탁 드립니다.
---------------------------------------------------------------------------
input : 금액(10000000),원하는_평단가요율(1.01),시작날짜(20200101);
var : Bcond(False),x(False);
var1 = Highest(c,15);
Var2 = Lowest(c,20);
var3 = Highest(c,20);
Var4 = Lowest(c,20);
....이하생략
Var11 = Lowest(c,20);
var12 = Highest(c,20);
Var13 = Lowest(c,40);
var14 = Highest(c,40);
....이하생략
if MarketPosition == 1 Then
{
if CurrentContracts > CurrentContracts[1] Then
{
if LatestEntryName(0) == "a1" Then
Condition1 = true;
if LatestEntryName(0) == "a3" Then
Condition3 = true;
...이하생략
if LatestEntryName(0) == "b1" Then
Condition11 = true;
if LatestEntryName(0) == "b2" Then
Condition13 = true;
...이하생략
}
//////////////////////////////////////////////////////////////////////////////////
if MarketPosition == 1 Then
exitlong("평단매도",atlimit,AvgEntryPrice*원하는_평단가요율);
///////////////////////////////////////////////////////////////////////////////////
}
Else
{
x = False;
Condition1 = False;
Condition3 = False;
...이하생략
Condition11 = False;
Condition13 = False;
...이하생략
}
Bcond = False;
if Bcond == False and x == False and CrossUp(c,var1[1]) and sDate >= 시작날짜 and Condition1 == False Then
{
Bcond = true;
Buy("a1",OnClose,DEf,((금액*(1/20))/C));
}
if Bcond == False and X == false and CrossDown(c,var11[1]) and sDate >= 시작날짜 and Condition11 == False Then
{
Bcond = true;
Buy("b1",OnClose,DEf,((금액*(1/20))/C));
}
..이하생략