답변완료
수식 문의드립니다
안녕하세요 ?
변수선언이 맞게 작성 되었는지
확인부탁드립니다
고맙습니다
input: period1(20), period2(100);
var: mav1(0), mav2(0);
mav1=ma(c, period1);
mav2=ma(c, period2);
#매수진입
if !(sTime>=090000 and sTime < 093500) and MarketPosition() != -1 and
CrossUp(ma(c,20), ma(c,100)) and
c>ma(c,100)+PriceScale*10 and Highest(h,200)-c>PriceScale*100
Then Buy("매수",AtMarket);
#매수청산
if MarketPosition() == 1 Then
{
if Highest(h,BarsSinceEntry+1)>=(EntryPrice()+PriceScale*290)Then
ExitLong("수익1",AtStop, EntryPrice()+PriceScale*280,"매수");
if Highest(h,BarsSinceEntry+1)>=(EntryPrice()+PriceScale*240)Then
ExitLong("수익2",AtStop, EntryPrice()+PriceScale*190,"매수");
if Highest(h,BarsSinceEntry+1)>=(EntryPrice()+PriceScale*190)Then
ExitLong("수익3",AtStop, EntryPrice()+PriceScale*140,"매수");
if c<(EntryPrice()-PriceScale*190)Then
ExitLong("손절", AtStop, c, "매수");}
#매도 진입
if !(sTime >=090000 and sTime < 093500)and MarketPosition() != 1 and
CrossDown(ma(c,20),ma(c,100)) and
c<ma(c,100)-PriceScale*10 and
Highest(h,200)-c>PriceScale*100
Then Sell("매도",AtMarket);
#매도청산
if MarketPosition() == -1 Then
{
if Lowest(l,BarsSinceEntry +1)<=(EntryPrice()-PriceScale*490) Then
ExitShort("매도수익0",AtStop,EntryPrice()-PriceScale*440,"매도");
if Lowest(l,BarsSinceEntry +1)<=(EntryPrice()-PriceScale*390) Then
ExitShort("매도수익1",AtStop,EntryPrice()-PriceScale*340,"매도");
if Lowest(l,BarsSinceEntry +1)<=(EntryPrice()-PriceScale*190) Then
ExitShort("매도수익2",AtStop,EntryPrice()-PriceScale*140,"매도");
if Lowest(l,BarsSinceEntry +1)<=(EntryPrice()-PriceScale*140) Then
ExitShort("매도수익3",AtStop,EntryPrice()-PriceScale*90,"매도");
if Lowest(l,BarsSinceEntry +1)<=(EntryPrice()-PriceScale*50) Then
ExitShort("매도수익4",AtStop,EntryPrice()-PriceScale*30,"매도");
if c>(EntryPrice()+PriceScale*200) Then
ExitShort("매도손절",AtStop,c,"매도");}
2025-01-31
432
글번호 187601
시스템
답변완료
시스템식 요청드립니다.
아래의 식에서 오류가 있는데 어떤식으로 수정해야 할지 몰라 요청드립니다.
아래의 시스템식은 주가가 14 이평선위에 있다가 해당 이평선을 하향돌파했을때
매수하는 시스템식으로
그림 파일1을 보시면 14일선 아래에 있다가 갭하락으로 시가가 시작했을때 매수가 되었습니다.
그런데, 매도는 매수평단에서 3% 4% 5% 분할매도가 되어야 하는데, 분할매도가 안됩니다.
그림파일 2를 보시면 평소엔 잘 되는것 같습니다. 1번의 경우가 갭하락으로 인해서 문제가
발생한것 처럼 보이는데 혹시 어떤 부분에 문제가 있는지 확인 부탁드리겠습니다.
그리고 수정하기위해서 어떤 부분을 어떻게 수정해야하는지 부탁드리겠습니다.ㅜ.ㅜ
---------------------------------------------------------------
input : N(14),금액(2000000);
input : 시작날짜 (20250109);
Input : 기준선기간(120);
Var : 기준선(0);
var : cntt(0),H1(0),L1(0);
var : cnt(0),sum(0),mav(0),DD(0);
var : AP(0),TT(0),entry(False);
var : LL(0),RR(0),rate(0);
var : 저항(0), B1(0) ;
Var : day(0),EntryDay(0),ddd(0),ED(0);
#-------------------------------------
if sDate >= 시작날짜 Then
{
if Bdate != Bdate[1] Then
{
entry = true;
day = day+1;
dd = dd+1;
}
}
if TotalTrades > TotalTrades[1] Then
entry = False;
#-------------------------------------
#-------------------------------------
sum = 0;
For cnt = 0 to N-1
{
sum = sum + DayClose(cnt);
}
mav = (sum/N);
#-------------------------------------
#---------------------------------------
if (MarketPosition == 0) and (entry == true) and L > mav Then
Buy("1차매수",AtLimit,mav,Floor(금액/min(NextBarOpen,mav)));
if (LatestEntryName(0) == "1차매수") Then
Buy("2차매수",AtLimit,LatestEntryPrice(0)*0.95,Floor(금액*1.15/min(NextBarOpen,mav)));
if (LatestEntryName(0) == "2차매수") Then
Buy("3차매수",AtLimit,LatestEntryPrice(0)*0.95,Floor(금액*1.2/min(NextBarOpen,mav)));
if (LatestEntryName(0) == "3차매수") Then
Buy("4차매수",AtLimit,LatestEntryPrice(0)*0.95,Floor(금액*1.25/min(NextBarOpen,mav)));
if (LatestEntryName(0) == "4차매수") Then
Buy("5차매수",AtLimit,LatestEntryPrice(0)*0.95,Floor(금액*1.3/min(NextBarOpen,mav)));
if (LatestEntryName(0) == "5차매수") Then
Buy("6차매수",AtLimit,LatestEntryPrice(0)*0.95,Floor(금액*1.35/min(NextBarOpen,mav)));
#-----------------------------------
if MarketPosition == 1 Then
{
#전봉대비 수량 감소(일부 청산발생을 위미)
if CurrentContracts < CurrentContracts[1] Then
{
#청산가 저장
var1 = LatestExitPrice(0);
if LatestExitName(0) == "3%익절" or LatestExitName(0) == "3-D%익절" or LatestExitName(0) == "3-E%익절" Then
Condition1 = true;
if LatestExitName(0) == "4%익절" or LatestExitName(0) == "4-D%익절" or LatestExitName(0) == "4-E%익절" Then
Condition2 = true;
if LatestExitName(0) == "5%익절" or LatestExitName(0) == "5-D%익절" or LatestExitName(0) == "5-E%익절" Then
Condition3 = true;
if LatestExitName(0) == "7%익절" or LatestExitName(0) == "7-D%익절" Then
Condition4 = true;
}
#전봉대비 수량 증가(추가 진입발생을 의미)
if CurrentContracts > CurrentContracts[1] AND ((LatestEntryName(0) == "1차매수") OR (LatestEntryName(0) == "2차매수") or (LatestEntryName(0) == "3차매수") ) Then
{
#현재수량 저장
Var3 = CurrentContracts;
Var4 = AvgEntryPrice;
Condition1 = False;
Condition2 = False;
Condition3 = False;
Condition4 = False;
}
if CurrentContracts > CurrentContracts[1] AND ((LatestEntryName(0) == "4차매수")) Then
{
#현재수량 저장
Var3 = CurrentContracts;
Var4 = AvgEntryPrice;
Condition1 = False;
Condition2 = False;
Condition3 = False;
Condition4 = False;
}
if CurrentContracts > CurrentContracts[1] AND ((LatestEntryName(0) == "6차매수") or (LatestEntryName(0) == "5차매수")) Then
{
#현재수량 저장
Var3 = CurrentContracts;
Var4 = AvgEntryPrice;
Condition1 = False;
Condition2 = False;
Condition3 = False;
Condition4 = False;
}
if var1 > 0 and C < Var4 then
ExitLong("bx");
if Condition1 == False AND ((LatestEntryName(0) == "1차매수") OR (LatestEntryName(0) == "2차매수") or (LatestEntryName(0) == "3차매수") )Then
ExitLong("3%익절",AtLimit,Var4*1.03,"",Floor(Var3*0.2),1);
if Condition2 == False AND ((LatestEntryName(0) == "1차매수") OR (LatestEntryName(0) == "2차매수") or (LatestEntryName(0) == "3차매수") ) Then
ExitLong("4%익절",AtLimit,Var4*1.04,"",Floor(Var3*0.3),1);
if Condition3 == False AND ((LatestEntryName(0) == "1차매수") OR (LatestEntryName(0) == "2차매수") or (LatestEntryName(0) == "3차매수") ) Then
ExitLong("5%익절",AtLimit,Var4*1.05,"",Floor(Var3*0.4),1);
if Condition4 == False AND ((LatestEntryName(0) == "1차매수") OR (LatestEntryName(0) == "2차매수") or (LatestEntryName(0) == "3차매수") ) Then
ExitLong("7%익절",AtLimit,Var4*1.07,"",Floor(Var3*0.1),1);
ExitLong("10%익절",AtLimit,Var4*1.10);
if Condition1 == False AND ((LatestEntryName(0) == "4차매수"))Then
ExitLong("3-D%익절",AtLimit,Var4*1.03,"",Floor(Var3*0.5),1);
if Condition2 == False AND ((LatestEntryName(0) == "4차매수")) Then
ExitLong("4-D%익절",AtLimit,Var4*1.04,"",Floor(Var3*0.45),1);
if Condition3 == False AND ((LatestEntryName(0) == "4차매수")) Then
ExitLong("5-D%익절",AtLimit,Var4*1.05,"",Floor(Var3*0.1),1);
if Condition1 == False AND ((LatestEntryName(0) == "6차매수") or (LatestEntryName(0) == "5차매수"))Then
ExitLong("3-E%익절",AtLimit,Var4*1.03,"",Floor(Var3*0.5),1);
if Condition2 == False AND ((LatestEntryName(0) == "6차매수") or (LatestEntryName(0) == "5차매수")) Then
ExitLong("4-E%익절",AtLimit,Var4*1.04,"",Floor(Var3*0.45),1);
if Condition3 == False AND ((LatestEntryName(0) == "6차매수") or (LatestEntryName(0) == "5차매수")) Then
ExitLong("5-E%익절",AtLimit,Var4*1.05,"",Floor(Var3*0.1),1);
}
Else#매수진입중이 아니면
{
#변수 0으로 초기화
var1 = 0;
Var2 = 0;
}
2025-02-03
383
글번호 187593
시스템
답변완료
문의 드립니다
안녕하세요 새해 복 많이 받으시기 바랍니다.
응답해 주신 지난 아래 수식에서 지표속성창에서 선 굵기와 지표선 값을 표시하도록
체크를 해도 전혀 반응이 없습니다. 지표선 값을 알고싶습니다. 윗쪽 밴드선 값은 선 위에
아래쪽 밴드선 값은 선 아래에 표시해 주실 수 있는지요
감사합니다
======================================
input : hh(8),mult(3),repaint(true),upCss(red),dnCss(blue);
var : n(0),src(0),i(0),w(0),den(0),out(0),mae(0),upper(0),lower(0);
Array : ln[500](0),coefs[500](0);
Array : nwe[500](0),uptx[500](0),dntx[500](0),uptx1[500](0),dntx1[500](0);
src = close;
n = index;
den = 0;
for i = 0 to 499
{
ln[i] = 0;
w = exp(-(pow(i, 2)/(hh *hh * 2)));
coefs[i] = w;
den = den + coefs[i];
}
out = 0;
for i = 0 to 499
{
out = out +(src[i] * coefs[i]);
}
out = out/den;
mae = ma(abs(src - out), 499) * mult;
upper = out + mae;
lower = out - mae;
var : sae(0),y2(0),y1(0),j(0);
var : sum(0),sumw(0);
if Index >= 500 and repaint == true Then
{
for i = 0 to min(499,n - 1)
{
nwe[i] = 0;
Text_Delete(uptx[i]);
Text_Delete(dntx[i]);
Text_Delete(uptx1[i]);
Text_Delete(dntx1[i]);
}
sae = 0;
for i = 0 to min(499,n - 1)
{
sum = 0;
sumw = 0;
for j = 0 to min(499,n - 1)
{
w = exp(-(pow(i-j, 2)/(hh *hh * 2)));
sum = sum + src[j] * w;
sumw = sumw + w;
}
y2 = sum / sumw;
sae = sae + abs(src[i] - y2);
nwe[i] = y2;
}
sae = sae / min(499,n - 1) * mult;
for i = 0 to min(499,n - 1)
{
uptx[i] = text_new(sDate[i],sTime[i],nwe[i]+sae,"-");
Text_SetColor(uptx[i],upcss);
Text_SetStyle(uptx[i],2,2);
dntx[i] = text_new(sDate[i],sTime[i],nwe[i]-sae,"-");
Text_SetColor(dntx[i],dncss);
Text_SetStyle(dntx[i],2,2);
y1 = nwe[i];
}
}
if repaint == False Then
{
plot1(out + mae, "Upper", upCss);
plot2(out - mae, "Lower", dnCss);
}
=============================================
2025-01-31
446
글번호 187588
지표