안녕하세요 문의사항이 있어 글을 남깁니다.
아래의 시스템식을 보시면 1차 매수 후 5일 뒤 11시에 청산 하게 되어있는데
1차 매수와 2차 매수일이 다르면 제대로 작동하나
1차 매수와 2차 매수일이 동일하면 시스템식이 작동을 안합니다.
어떻게 수정해야 할까요?
--------------------------------------------------
input : Xdate1(5),Xtime1(110000);
input : 시작날짜 (20250307);
var : cnt(0),sum(0),mav(0),DD(0),entry(False),day(0);
if sDate >= 시작날짜 Then
{
if Bdate != Bdate[1] Then
{
entry = true;
day = day+1;
dd = dd+1;
Condition1 = False;
}
}
if MarketPosition == 0 and TotalTrades > TotalTrades[1] Then
Condition1 = true;
if Condition1 == False and (entry == true) and MarketPosition == 0 and L > mav Then
Buy("1차매수",AtLimit,mav,Floor(금액1/min(NextBarOpen,mav)));
# 매수 후 포지션 관리
if MarketPosition == 1 Then
{
# 5일차 11시 청산
if DD == DD[BarsSinceEntry]+Xdate1 and sTime == xtime1 Then
{
Condition1 = true;
ExitLong("매수한지5일차 청산");
}
# --- 2차 매수 ---
if MaxEntries == 1 and Condition1 == False Then
{
Buy("2차매수",AtLimit,
LatestEntryPrice(0)*(1+추가진입/100),
Floor(금액2/min(NextBarOpen,LatestEntryPrice(0)*(1+추가진입/100))));
if Condition2 == False Then
ExitLong("1차매수익절",AtLimit,avgEntryPrice*(1+익절1/100));
}
답변 1
예스스탁
예스스탁 답변
2025-09-08 15:17:21.0
안녕하세요
예스스탁입니다.
올려주신 수식은 적용해 보았지만
1차와 2차가 동일한 날짜에 발생해도 첨부한 그림과 같이
5일째 청산하는 식호가 발생합니다.
수식상에도 해당 부분을 별도로 막는 부분이 없습니다.
즐거운 하루되세요
> 맴맴잉 님이 쓴 글입니다.
> 제목 : 시스템식 요청드립니다.
> 안녕하세요 문의사항이 있어 글을 남깁니다.
아래의 시스템식을 보시면 1차 매수 후 5일 뒤 11시에 청산 하게 되어있는데
1차 매수와 2차 매수일이 다르면 제대로 작동하나
1차 매수와 2차 매수일이 동일하면 시스템식이 작동을 안합니다.
어떻게 수정해야 할까요?
--------------------------------------------------
input : Xdate1(5),Xtime1(110000);
input : 시작날짜 (20250307);
var : cnt(0),sum(0),mav(0),DD(0),entry(False),day(0);
if sDate >= 시작날짜 Then
{
if Bdate != Bdate[1] Then
{
entry = true;
day = day+1;
dd = dd+1;
Condition1 = False;
}
}
if MarketPosition == 0 and TotalTrades > TotalTrades[1] Then
Condition1 = true;
if Condition1 == False and (entry == true) and MarketPosition == 0 and L > mav Then
Buy("1차매수",AtLimit,mav,Floor(금액1/min(NextBarOpen,mav)));
# 매수 후 포지션 관리
if MarketPosition == 1 Then
{
# 5일차 11시 청산
if DD == DD[BarsSinceEntry]+Xdate1 and sTime == xtime1 Then
{
Condition1 = true;
ExitLong("매수한지5일차 청산");
}
# --- 2차 매수 ---
if MaxEntries == 1 and Condition1 == False Then
{
Buy("2차매수",AtLimit,
LatestEntryPrice(0)*(1+추가진입/100),
Floor(금액2/min(NextBarOpen,LatestEntryPrice(0)*(1+추가진입/100))));
if Condition2 == False Then
ExitLong("1차매수익절",AtLimit,avgEntryPrice*(1+익절1/100));
}