답변완료
당일 고점 후 눌림목과 반등 고점 찾기
안녕하세요. 항상 큰 도움 감사드립니다.
지난번 특정 조건의 값을 배열에 저장하여 통계분석 하는 법을 알려주셨습니다.
해당 예시는 이미 확정된 과거의 값 (전일 고가/저가)여서 ii 변수로 매일의 값을 가져오는 문제이나, 이번에는 당일 고점과 눌림목을 찾아 가공 후 배열에 기록하고 해당 통계를 사용하여 매매하고자 합니다.
결과를 보았을때, 고점이 매 봉 실시간으로 갱신되어, 매 봉 신호가 나오는 문제가 있는 것으로 보여, 과거 데이터는 분석에만 사용하고, 실제 매매는 확정된 통계값 많을 사용하고 하고싶습니다.
혹시 일부 조건들이 모호하다면 임의로 추가해주셔도 무방하며 (예: 특정 시간동안의 저가를 눌림목으로 정의) 전반적인 분석과 매매 구조에 대해 검토해주시면 감사하겠습니다.
https://www.yesstock.com/Board/View.asp?db=board100036&Ext=0&startpage=1&pageno=1&num=164394&ref=164369&Sort=&KeyField=NickName&KeyWord=%B1%E2%BB%E7%B4%DC%C0%E5
#수수료율: 0.004%
#거래세: (매도시) 0.25%
Input: GrowthRate(0.15);
var: DayLowRate(0), AvgDayHigh(0),n(0),p(0),ii(0),jj(0),AL_Avg(0),AL_90(0),AL_99(0),AH(0),AvgDH(0),AvgDL(0);
Array: DL[500](0),DH[500](0);
#초기화
For ii = 1 to 499
{
DL[ii] = 0;
DH[ii] = 0;
}
n = 0;
p = 0;
For ii = 1 to 499
{
# 전일 상승률이 GrowthRate 이상이면
If ((DayHigh(ii-1)-DayClose(ii))/DayClose(ii)) >= GrowthRate
Then
{
# 당일 13시 이전 고가(Value1)와 봉의 위치(Value2) 저장
if DayHigh >= GrowthRate and
H[ii-1]>H[ii] and
sTime <= 130000 Then
{
#해당봉의 고가 저장
value1 = H[ii-1];
#해당봉 이후 경과된 봉 수를 저장한 변수 (초기값 0)
Value2 = 0;
}
Else
{
#Value2를 1씩 증가(조건만족이후 경과된 봉 수)
If value1 > 0 Then
value2 = Value2+1;
}
#저가와 위치 저장
If L[ii-1]<L[ii] Then
{
Value3 = L[ii-1];
Value4 = 0;
}
Else
{
if Value3 > 0 Then
Value4 = Value4+1;
}
#찾은 고가 위치 이후의 저가(눌림목)만 저장
If L[ii-1]<L[ii] and
Value1 >0 and
Value4 >= Value2 Then
{
Value5 = Value3;
}
#고가와 위치 저장
If H[ii-1]>H[ii] Then
{
Value6 = H;
Value7 = 0;
}
Else
{
If value6 > 0 Then
Value7 = Value7+1;
}
#눌림목 이후의 고가(반등)만 저장
If H[ii-1]>H[ii] and
value1 > 0 and
Value5 > 0 and
Value7 >= Value4 Then
{
Value8 = Value6;
}
#일 마지막 봉에서 최종 고가,눌림목, 반등 가격에 대한 비율 저장
if NextBarSdate <> sdate Then{ # 고가는 매 봉마다 갱신되므로, 최종 가격을 사후에 기록하기 위한 조건
# 상승 후 하락율을 Array에 기록
DayLowRate = ((Value5-value1)/value1);
DL[n] = DayLowRate;
AvgDL = AverageArray(DL,n+1);
n = n+1;
# 하락 후 반등율을 Array에 기록
AvgDayHigh = ((Value8-value5)/value5);
DH[p] = AvgDayHigh;
AvgDH = AverageArray(DH,p+1);
p = p+1;
}
}}
# 시가 기준 평균 하락율 도달 시 가격
AL_Avg = DayOpen*(1+AvgDL);
# 시가 기준 평균 상승률 도달 시 가격
AH = DayOpen*(1+AvgDH);
Buy("b1",AtLimit,AL_Avg);
ExitLong("S",Atlimit,AH);
2022-12-11
1159
글번호 164506
시스템
답변완료
문의드립니다
1 study("Supertrend", overlay = true, format=format.price, precision=2, resolution="")
2 Periods = input(title="ATR Period", type=input.integer, defval=10)
3 src = input(hl2, title="Source")
4 Multiplier = input(title="ATR Multiplier", type=input.float, step=0.1, defval=3.0)
5 changeATR= input(title="Change ATR Calculation Method ?", type=input.bool, defval=true)
6 showsignals = input(title="Show Buy/Sell Signals ?", type=input.bool, defval=true)
7 highlighting = input(title="Highlighter On/Off ?", type=input.bool, defval=true)
8 atr2 = sma(tr, Periods)
9 atr= changeATR ? atr(Periods) : atr2
10 up=src-(Multiplier*atr)
11 up1 = nz(up[1],up)
12 up := close[1] > up1 ? max(up,up1) : up
13 dn=src+(Multiplier*atr)
14 dn1 = nz(dn[1], dn)
15 dn := close[1] < dn1 ? min(dn, dn1) : dn
16 trend = 1
17 trend := nz(trend[1], trend)
18 trend := trend == -1 and close > dn1 ? 1 : trend == 1 and close < up1 ? -1 : trend
19 upPlot = plot(trend == 1 ? up : na, title="Up Trend", style=plot.style_linebr, linewidth=2, color=color.green)
20 buySignal = trend == 1 and trend[1] == -1
21 plotshape(buySignal ? up : na, title="UpTrend Begins", location=location.absolute, style=shape.circle, size=size.tiny, color=color.green, transp=0)
22 plotshape(buySignal and showsignals ? up : na, title="Buy", text="Buy", location=location.absolute, style=shape.labelup, size=size.tiny, color=color.green, textcolor=color.white, transp=0)
23 dnPlot = plot(trend == 1 ? na : dn, title="Down Trend", style=plot.style_linebr, linewidth=2, color=color.red)
24 sellSignal = trend == -1 and trend[1] == 1
25 plotshape(sellSignal ? dn : na, title="DownTrend Begins", location=location.absolute, style=shape.circle, size=size.tiny, color=color.red, transp=0)
26 plotshape(sellSignal and showsignals ? dn : na, title="Sell", text="Sell", location=location.absolute, style=shape.labeldown, size=size.tiny, color=color.red, textcolor=color.white, transp=0)
27 mPlot = plot(ohlc4, title="", style=plot.style_circles, linewidth=0)
28 longFillColor = highlighting ? (trend == 1 ? color.green : color.white) : color.white
29 shortFillColor = highlighting ? (trend == -1 ? color.red : color.white) : color.white
30 fill(mPlot, upPlot, title="UpTrend Highligter", color=longFillColor)
31 fill(mPlot, dnPlot, title="DownTrend Highligter", color=shortFillColor)
32 alertcondition(buySignal, title="SuperTrend Buy", message="SuperTrend Buy!")
33 alertcondition(sellSignal, title="SuperTrend Sell", message="SuperTrend Sell!")
34 changeCond = trend != trend[1]
35 alertcondition(changeCond, title="SuperTrend Direction Change", message="SuperTrend has changed direction!")
위수식을예스트레이더로변경부탁드립니다~~
2022-12-11
918
글번호 164504
지표
답변완료
수식 수정 좀 해주세요.
input : st_mult(2),st_period(14),len(20);
var : price(0),up_lev(0),dn_lev(0),upz(0),downv(0);
var : trur(0),plus(0),minus(0),sum(0),adxv(0);
var : di(0),x(0),zz(0);
price = (H+L)/2;
up_lev = price - (st_mult * atr(st_period));
dn_lev = price + (st_mult * atr(st_period));
if CurrentBar >= 1 then
{
upz = up_lev-up_lev[1];
downv = -(dn_lev-dn_lev[1]);
trur = (TrueRange + (len - 1) * trur) / len;
var1 = iff(upz > downv and upz > 0 , upz , 0);
var11 = (var1 + (len - 1) * var11) / len;
plus = var11/trur;
var2 = iff(downv > upz and downv > 0 , downv , 0);
var22 = (var2 + (len - 1) * var22) / len;
minus = var22/trur;
sum = plus + minus;
var3 = abs(plus - minus) / iff(sum == 0 , 1 , sum);
adxv = (var3 + (len - 1) * adxv) / len;
di = plus - minus;
x=adxv-di*100;
zz=x/-1;
plot1(zz,"시그널");
plot2(20,"상단");
plot3(-20,"하단");
plot4(0,"중심");
오류 메세지가 나옵니다.
내용은 올린 이미지입니다.
정상적으로 나오도록 수정 좀 해주세요.
2022-12-11
970
글번호 164502
지표