예스스탁
예스스탁 답변
2020-11-12 16:26:49
안녕하세요
예스스탁입니다.
문의하신 내용은 가능하지 않습니다.
도움을 드리지 못해 죄송합니다.
즐거운 하루되세요
> 이형지 님이 쓴 글입니다.
> 제목 : 수식에서 기존 보유 수량을 반영이 가능할까요?
> 국내 주식
예스트레이드(하이투자증권) 적용
모든 수식이 매수 후 매도 가 로직인데...
기존 보유 주식이 있는 것도 반영이 되려면 어떻게 하면 될까요?
예를 들어
RSI(14)< 30 일때 분할 매수 100개
RSI(14)> 80 일때 분할 매도 100개
이런 수식에서 기존 보유 수량이 100개 있을때
기존 보유 수량 100개
RSI(14)< 30 일때 분할 매수 100개
RSI(14)> 80 일때 분할 매도 200개
아래 수식은 현재 사용하고 있는 수식입니다.
기존 사용 수식에 보유주식 1000개 있는 상태에서 반영될수 있게 수식 수정 부탁드릴께요
input : 시작일(20200101);
input : 최대투자금액(2000);
input : 기준평균봉값(80);
input : 최초진입하락폭(0.97);
input : 추가진입하락폭(0.99);
input : MFI기간(15),MFI값(86);
input : 심리도기간(15),심리도값(80);
input : 분할매도횟수(4);
input : 분할매도율(2);
input : 제1매수금액(10);
input : 제2매수금액(20);
input : 제3매수금액(30);
input : 제4매수금액(40);
input : 제5매수금액(50);
input : 제6매수금액(60);
input : 제7매수금액(70);
input : 제8매수금액(80);
input : 제9매수금액(90);
input : 제10매수금액(100);
input : 제11매수금액(120);
input : 제12매수금액(140);
input : 제13매수금액(160);
input : 제14매수금액(180);
input : 제15매수금액(200);
input : 제16매수금액(200);
input : 제17매수금액(200);
input : 제18매수금액(200);
input : 제19매수금액(200);
input : 제20매수금액(200);
input : 제21매수금액(200);
input : 제22매수금액(200);
input : 제23매수금액(200);
input : 제24매수금액(200);
input : 제25매수금액(200);
input : 제26매수금액(250);
input : 제27매수금액(250);
input : 제28매수금액(250);
var : Xcond(False,data1);
var : mav(0,data2),MM(0,Data3),SS(0,Data3);
var : MMM(0,Data2),SSS(0,Data2),Xcnt(0,Data2),Xvol(0,data1);
mav = data2(ma(c,기준평균봉값));
MM = Data3(mfi(MFI기간));
SS = Data3(Simrido(심리도기간));
MMM = Data2(mfi(MFI기간));
SSS = Data2(Simrido(심리도기간));
if Data1(sDate) >= 시작일 Then
{
If AvgEntryPrice*CurrentContracts < 최대투자금액*10000 Then
{
if MarketPosition == 0 and (MarketPosition == 0 or (MarketPosition == 1 and Xcond == False)) and data2(CrossDown(c,mav*최초진입하락폭)) then
buy("b1",atlimit,C,Floor(제1매수금액*10000/min(NextBarOpen,C)));
if MarketPosition == 1 then
{
if MaxEntries == 1 then # 85
buy("b2",AtLimit,LatestEntryPrice(0)*추가진입하락폭,Floor(제2매수금액*10000/c));
if MaxEntries == 2 then # 80
buy("b3",AtLimit,LatestEntryPrice(0)*(추가진입하락폭-0.01),Floor(제3매수금액*10000/c));
if MaxEntries == 3 then # 75
buy("b4",AtLimit,LatestEntryPrice(0)*(추가진입하락폭-0.015),Floor(제4매수금액*10000/c));
if MaxEntries == 4 then # 70
buy("b5",AtLimit,LatestEntryPrice(0)*(추가진입하락폭-0.02),Floor(제5매수금액*10000/c));
if MaxEntries == 5 then # 65
buy("b6",AtLimit,LatestEntryPrice(0)*(추가진입하락폭-0.025),Floor(제6매수금액*10000/c));
if MaxEntries == 6 then # 85
buy("b7",AtLimit,LatestEntryPrice(0)*(추가진입하락폭-0.03),Floor(제7매수금액*10000/c));
if MaxEntries == 7 then # 80
buy("b8",AtLimit,LatestEntryPrice(0)*(추가진입하락폭-0.035),Floor(제8매수금액*10000/c));
if MaxEntries == 8 then # 75
buy("b9",AtLimit,LatestEntryPrice(0)*(추가진입하락폭-0.04),Floor(제9매수금액*10000/c));
if MaxEntries == 9 then # 70
buy("b10",AtLimit,LatestEntryPrice(0)*(추가진입하락폭-0.045),Floor(제10매수금액*10000/c));
if MaxEntries == 10 then # 65
buy("b11",AtLimit,LatestEntryPrice(0)*(추가진입하락폭-0.05),Floor(제11매수금액*10000/c));
if MaxEntries == 11 then # 80
buy("b12",AtLimit,LatestEntryPrice(0)*(추가진입하락폭-0.055),Floor(제12매수금액*10000/c));
if MaxEntries == 12 then # 75
buy("b13",AtLimit,LatestEntryPrice(0)*(추가진입하락폭-0.06),Floor(제13매수금액*10000/c));
if MaxEntries == 13 then # 70
buy("b14",AtLimit,LatestEntryPrice(0)*(추가진입하락폭-0.065),Floor(제14매수금액*10000/c));
if MaxEntries == 14 then # 65
buy("b15",AtLimit,LatestEntryPrice(0)*(추가진입하락폭-0.07),Floor(제15매수금액*10000/c));
if MaxEntries == 15 then # 80
buy("b16",AtLimit,LatestEntryPrice(0)*(추가진입하락폭-0.075),Floor(제16매수금액*10000/c));
if MaxEntries == 16 then # 75
buy("b17",AtLimit,LatestEntryPrice(0)*(추가진입하락폭-0.08),Floor(제17매수금액*10000/c));
if MaxEntries == 17 then # 70
buy("b18",AtLimit,LatestEntryPrice(0)*(추가진입하락폭-0.085),Floor(제18매수금액*10000/c));
if MaxEntries == 18 then # 65
buy("b19",AtLimit,LatestEntryPrice(0)*(추가진입하락폭-0.09),Floor(제19매수금액*10000/c));
if MaxEntries == 19 then # 85
buy("b20",AtLimit,LatestEntryPrice(0)*(추가진입하락폭-0.095),Floor(제20매수금액*10000/c));
if MaxEntries == 20 then # 80
buy("b21",AtLimit,LatestEntryPrice(0)*(추가진입하락폭-0.1),Floor(제21매수금액*10000/c));
if MaxEntries == 21 then # 75
buy("b22",AtLimit,LatestEntryPrice(0)*(추가진입하락폭-0.105),Floor(제22매수금액*10000/c));
if MaxEntries == 22 then # 70
buy("b23",AtLimit,LatestEntryPrice(0)*(추가진입하락폭-0.11),Floor(제23매수금액*10000/c));
if MaxEntries == 23 then # 65
buy("b24",AtLimit,LatestEntryPrice(0)*(추가진입하락폭-0.115),Floor(제24매수금액*10000/c));
if MaxEntries == 24 then # 80
buy("b25",AtLimit,LatestEntryPrice(0)*(추가진입하락폭-0.12),Floor(제25매수금액*10000/c));
if MaxEntries == 25 then # 75
buy("b26",AtLimit,LatestEntryPrice(0)*(추가진입하락폭-0.125),Floor(제26매수금액*10000/c));
if MaxEntries == 26 then # 70
buy("b27",AtLimit,LatestEntryPrice(0)*(추가진입하락폭-0.13),Floor(제27매수금액*10000/c));
if MaxEntries == 27 then # 65
buy("b28",AtLimit,LatestEntryPrice(0)*(추가진입하락폭-0.135),Floor(제28매수금액*10000/c));
}
}
}
#==================================================================================================
if MarketPosition == 1 Then
{
if Xcond == False and MM > MFI값 or SS > 심리도값 or MMM > MFI값 or SSS > 심리도값 Then
{
Xcond = true;
Xcnt = 0;
}
if Xcond == true Then
{
Xcnt = Xcnt+1;
if Xcnt < 분할매도횟수 then
Xvol = MaxContracts*분할매도율/100 ;
Else
Xvol = CurrentContracts;
ExitLong("bx",OnClose,DEf,"",Xvol,2);
}
}
Else
{
Xcnt = 0;
Xcond = False;
}