답변완료
수식 부탁드립니다
아래 수식을 하나의 수식으로 작성 부탁드립니다.
매매시간내에 data1. 기준에 따라 매매 되며 data2의 3, 4 번의 조건 충족시 매수진입되도록 원합니다.
예시) 매수진입 형식
If (data2의 sb < MD[0] and superTrend < C ) and CountIF(Close < BBBot, Bars) == Bars Then
Buy("B", AtStop, BBBot);
1. 매매시간설정.
9시 10분에 매매시작 15시 까지 매수 진입 허용됨.
15시 이전에 진입한 포지션은 15시 15분까지 Exitlong 신호 발생시 청산됨.
15시 15분까지 Exitlong 신호 발생하지않으면 15시 15분에 당일청산 됨.
input : starttime(91000),endtime(150000),XTime(151500);
var : Tcond(false);
if (sdate != sdate[1] and stime >= starttime) or
(sdate == sdate[1] and stime >= starttime and stime[1] < starttime) then
{
Tcond = true;
}
if (sdate != sdate[1] and stime >= endtime) or
(sdate == sdate[1] and stime >= endtime and stime[1] < endtime) then
{
Tcond = false;
}
if Tcond == true then
{
2. data1.신호에 매매
Inputs: Length(9), StdDev(2), Bars(2);
Variables: BBTop(0),BBBot(0);
BBTop = BollBandup(Length, StdDev);
BBBot = BollBanddown(Length, StdDev);
If CountIF(Close < BBBot, Bars) == Bars Then
Buy("B", AtStop, BBBot);
If CountIF(Close > BBTop, Bars) == Bars Then
Exitlong("Ex", AtStop, BBTop);
3. 아래 지표 data2 의 sb < MD[0] 일 때 매수진입 됨.
input : 타주기분(5),long(60),sig(9),P(9);
var : S1(0),D1(0),TM(0),TF(0),cnt(0),ii(0),ep(0);
var : hsum(0),lsum(0),hma(0),lma(0),hi(0),lo(0),hi1(0),lo1(0);
var : Ema1(0),Ema2(0),Ema11(0),Ema21(0),mi(0),sum(0),sb(0),sh(0),mdc(0);
Array : HH[100](0),LL[100](0),CC[100](0),src[100](0),md[100](Nan);
ep = 2/(long+1);
if Bdate != Bdate[1] Then
{
S1 = TimeToMinutes(stime);
D1 = sdate;
}
if D1 > 0 then
{
if sdate == D1 Then
TM = TimeToMinutes(stime)-S1;
Else
TM = TimeToMinutes(stime)+1440-S1;
TF = TM%타주기분;
if Bdate != Bdate[1] or
(Bdate == Bdate[1] and 타주기분 > 1 and TF < TF[1]) or
(Bdate == Bdate[1] and 타주기분 > 1 and TM >= TM[1]+타주기분) or
(Bdate == Bdate[1] and 타주기분 == 1 and TM > TM[1]) Then
{
ii = ii+1;
For cnt = 99 DownTo 1
{
hh[cnt] = hh[cnt-1];
ll[cnt] = ll[cnt-1];
src[cnt] = src[cnt-1];
md[cnt] = md[cnt-1];
}
hh[0] = h;
ll[0] = l;
hi1 = hi[1];
lo1 = lo[1];
Ema11 = Ema1[1];
Ema21 = Ema2[1];
}
cc[0] = c;
if hh[0] > 0 and h > hh[0] Then
hh[0] = h;
if ll[0] > 0 and l < ll[0] Then
ll[0] = l;
src[0] = (hh[0]+ll[0]+cc[0])/3;
if src[long-1] > 0 Then
{
if src[long] == 0 Then
{
hsum = 0;
lsum = 0;
For cnt = 0 to long-1
{
hsum = hsum + hh[cnt];
lsum = lsum + ll[cnt];
}
hi = (hsum/long)/long;
lo = (lsum/long)/long;
}
Else
{
hi = (hi1*(long-1)+hh[0])/long;
lo = (lo1*(long-1)+ll[0])/long;
}
}
if ii <= 1 Then
{
ema1 = src[0];
ema2 = ema1;
}
Else
{
ema1 = src[0] * EP + Ema11 * (1-EP);
ema2 = ema1 * EP + Ema21 * (1-EP);
}
mi = ema1+(ema1-ema2);
md[0] = iff((mi>hi), (mi-hi) , iff((mi<lo) , (mi - lo) , 0));
if md[sig-1] > 0 Then
{
sum = 0;
For cnt = 0 to sig-1
{
sum = sum + md[cnt];
}
sb = sum/sig;
sh = md[0]-sb;
}
4.아래 지표가 data2 의 superTrend < C 일 때 매수진입 됨.
input : ntime(5),factor(3), AtrPeriod(10);
var : S1(0),D1(0),TM(0),TF(0),HH(0),LL(0),C1(0);
var : src(0), AtrV(0),ATRv1(0),upperBand(0),lowerBand(0), prevLowerBand(0), prevUpperBand(0);
var : prevSuperTrend(0), superTrend(0), direction(0),alpha(0),source(0);
if Bdate != Bdate[1] Then
{
S1 = TimeToMinutes(stime);
D1 = sdate;
}
if D1 > 0 then
{
if sdate == D1 Then
TM = TimeToMinutes(stime)-S1;
Else
TM = TimeToMinutes(stime)+1440-S1;
TF = TM%ntime;
if Bdate != Bdate[1] or
(Bdate == Bdate[1] and ntime > 1 and TF < TF[1]) or
(Bdate == Bdate[1] and ntime > 1 and TM >= TM[1]+ntime) or
(Bdate == Bdate[1] and ntime == 1 and TM > TM[1]) Then
{
HH = H;
LL = L;
C1 = C[1];
ATRV1 = ATRV[1];
prevSuperTrend = superTrend[1];
prevLowerBand = lowerBand[1];
prevUpperBand = upperBand[1];
}
if H > HH Then
HH = H;
if L < LL Then
LL = L;
src = (HH+LL)/2;
if C1 > 0 Then
{
alpha = 1 / AtrPeriod ;
source = max(HH - LL, abs(HH - C1), abs(LL - C1));
ATrV = alpha * source + (1 - alpha) * ATrV1;
upperBand = src + factor * AtrV;
lowerBand = src - factor * AtrV;
if lowerBand > prevLowerBand or C1 < prevLowerBand Then
lowerBand = lowerBand;
Else
lowerBand = prevLowerBand;
if upperBand < prevUpperBand or C1 > prevUpperBand Then
upperBand = upperBand;
Else
upperBand = prevUpperBand;
if prevSuperTrend == prevUpperBand Then
{
if C > upperBand Then
direction = -1;
Else
direction = 1;
}
Else
{
if C < lowerBand Then
direction = 1;
Else
direction = -1;
}
if direction == -1 Then
superTrend = lowerBand;
Else
superTrend = upperBand;
2025-05-08
301
글번호 190658
시스템
답변완료
부탁드립니다
빠른답변 감사합니다
1. 진입수량10주단위로 진입식부탁드립니다,
2.진입금액이 처음만 적용되고2번부터는증액이안된것도있습니다.
진입금액에번호를붙여주세요.1번째 진입금액=첫진입금액. 2번진입금액=1번금액+(1번금액*A%)
3번진입금액=2번진입금액+(2번금액*A%)4번진입금액=3번진입금액+(3번진입금액*A%)..이런식으로부탁드립니다
3.data1중복진입이 안되네요.시스템식에서 체크하면 될수있도록부탁드립니다
늘감사드립니다~
> 예스스탁 님이 쓴 글입니다.
> 제목 : Re : 문의드립니다,
> 안녕하세요
예스스탁입니다.
1
inputs : P1(5),P2(20),RSILength(10), OverSold(30),OverBought(70);
input : 첫진입금액(1000000),A(10);
var : m1(0,Data2),m2(0,Data2), R(0,Data1);
var : TT(0,Data1),T1(0,Data1),entry(0,Data1),mm(0,data1),vol(0,Data1);
m1 = Data2(ma(C,P1));
m2 = Data2(ma(C,P2));
R = data1(RSI(RSILength));
TT = TotalTrades;
if Data1(Bdate != Bdate[1]) Then
{
T1 = TT[1];
}
entry = (TT-T1)+IFF(MarketPosition == 0,0,1);
If MarketPosition <= 0 and Data2(m1 > m2) and Crossup(R, OverSold) Then
{
if entry == 0 Then
mm = 첫진입금액;
Else
mm = mm*(1+A/100);
Buy("B",OnClose,Def,Floor(mm/C));
}
if Data2(CrossDown(m1,m2)) or Crossup(R, OverBought) Then
Sell("S");
2
inputs : P1(5),P2(20),RSILength(10), OverSold(30),OverBought(70);
input : 첫진입금액(1000000),A(10),B(20);
var : m1(0,Data2),m2(0,Data2), R(0,Data1);
var : TT(0,Data1),T1(0,Data1),entry(0,Data1),mm(0,data1),vol(0,Data1);
m1 = Data2(ma(C,P1));
m2 = Data2(ma(C,P2));
R = data1(RSI(RSILength));
TT = TotalTrades;
if Data1(Bdate != Bdate[1]) Then
{
T1 = TT[1];
}
entry = (TT-T1)+IFF(MarketPosition == 0,0,1);
If MarketPosition <= 0 and Data2(m1 > m2) and Crossup(R, OverSold) Then
{
if entry == 0 Then
mm = 첫진입금액;
Else
{
if EntryPrice(1) > C Then
mm = mm*(1+B/100);
Else
mm = mm*(1+A/100);
}
Buy("B",OnClose,Def,Floor(mm/C));
}
if Data2(CrossDown(m1,m2)) or Crossup(R, OverBought) Then
Sell("S");
2025-05-09
234
글번호 190657
시스템
답변완료
문의드립니다
input : 크기(10);
var : box(0),tx(0);
if Bdate != Bdate[1] Then
{
var1 = O;
box = Box_New(sDate,sTime,var1,NextBarSdate,NextBarStime,var1);
Box_SetFill(box,true);
}
Else
{
Box_SetEnd(box,sDate,Stime,C);
if C >= var1+크기 or C <= var1-크기 Then
{
var1 = C;
box = Box_New(sDate,sTime,var1,NextBarSdate,NextBarStime,var1);
Box_SetFill(box,true);
}
}
Box_SetColor(box,IFf(C > var1,Red,IFf(C<var1,Blue,Green)));
--------------------
당일용이 아닌것으로 하나 더 부탁드립니다
만들어봤는데 안되네요
감사합니다
2025-05-08
285
글번호 190656
지표
답변완료
지표전환 요청
안녕하세요
파인스크립트 지표입니다 예스랭귀지로 바꿔주시면 감사하겠습니다
부탁드립니다
study("Divergences v2.1 [LTB]", overlay=true)
calcmacd = input(true, title="MACD")
calcmacda = input(true, title="MACD Histogram")
calcrsi = input(true, title="RSI")
calcstoc = input(true, title="Stochastic")
calccci = input(true, title="CCI")
calcmom = input(true, title="Momentum")
calcobv = input(true, title="OBV")
calcdi = input(true, title="Diosc")
calcvwmacd = input(true, title="VWmacd")
calccmf = input(true, title="Chaikin Money Flow")
showhidden = input(false, title="Show Hidden Divergences")
htime = period == '1' ? '5' :
period == '3' ? '15' :
period == '5' ? '15' :
period == '15' ? '60' :
period == '30' ? '60' :
period == '45' ? '60' :
period == '60' ? '240' :
period == '120' ? '240' :
period == '180' ? '240' :
period == '240' ? 'D' :
period == 'D' ? 'W' :
'W'
_highestbars(ind) =>
highest = high
hb = 0
for i = 1 to ind
if highest < high[i]
highest := high[i]
hb := i
hb
_lowestbars(ind) =>
lowest = low
lb = 0
for i = 1 to ind
if lowest > low[i]
lowest := low[i]
lb := i
lb
TopsBots(tb) =>
tUp = close >= open
tDown = close <= open
dir = tUp[1] and tDown ? -1 : tDown[1] and tUp ? 1 : nz(dir[1])
TopsBots = tb == 1 ? tUp[1] and tDown and dir[1] != -1 ? highest(2) : na : tDown[1] and tUp and dir[1] != 1 ? lowest(2) : na
bb = nz(bb[1]) + 1
bb := change(time(htime)) != 0 ? 1 : bb
maxb = bb > nz(maxb[1]) ? bb : nz(maxb[1])
tops = bb==maxb ? security(tickerid, htime, TopsBots(1)) : na
bots = bb==maxb ? security(tickerid, htime, TopsBots(-1)) : na
// RSI
rsi = rsi(close, 14)
// MACD
fastMA = ema(close, 8)
slowMA = ema(close, 16)
macd = fastMA - slowMA
signal = sma(macd, 11)
deltamacd = macd - signal
// Momentum
moment = mom(close, 10)
// CCI
cci = cci(close, 10)
// OBV
obv = cum(change(close) > 0 ? volume : change(close) < 0 ? -volume : 0 * volume)
// Stoch
stk = sma(stoch(close, high, low, 14), 3)
// DIOSC
DI = change(high) - (-change(low))
trur = rma(tr, 14)
diosc = fixnan(100 * rma(DI, 14) / trur)
// volume weighted macd
maFast = vwma(close, 12)
maSlow = vwma(close, 26)
vwmacd = maFast - maSlow
// Chaikin money flow
Cmfm = ((close-low) - (high-close)) / (high - low)
Cmfv = Cmfm * volume
cmf = sma(Cmfv, 21) / sma(volume,21)
hib = _highestbars(maxb*2 - 1)
t2 = nz(t2[1]) + 1
divt = white
divth = white
if (not na(tops) or (na(tops) and _highestbars(t2+1) == 0))
t1 = na(tops) ? 0 : hib
divt := (calcrsi ? ((rsi[t1] < rsi[t2] and high[t1] >= high[t2]) ? red : divt) : divt)
divt := (calcmacd ? ((macd[t1] < macd[t2] and high[t1] >= high[t2]) ? red : divt) : divt)
divt := (calcmacda ? ((deltamacd[t1] < deltamacd[t2] and high[t1] >= high[t2]) ? red : divt) : divt)
divt := (calcmom ? ((moment[t1] < moment[t2] and high[t1] >= high[t2]) ? red : divt) : divt)
divt := (calccci ? ((cci[t1] < cci[t2] and high[t1] >= high[t2]) ? red : divt) : divt)
divt := (calcobv ? ((obv[t1] < obv[t2] and high[t1] >= high[t2]) ? red : divt) : divt)
divt := (calcstoc ? ((stk[t1] < stk[t2] and high[t1] >= high[t2]) ? red : divt) : divt)
divt := (calcdi ? ((diosc[t1] < diosc[t2] and high[t1] >= high[t2]) ? red : divt) : divt)
divt := (calcvwmacd ? ((vwmacd[t1] < vwmacd[t2] and high[t1] >= high[t2]) ? red : divt) : divt)
divt := (calccmf ? ((cmf[t1] < cmf[t2] and high[t1] >= high[t2]) ? red : divt) : divt)
//hidden
divth := (calcrsi ? ((rsi[t1] > rsi[t2] and high[t1] < high[t2]) ? gray : divth) : divth)
divth := (calcmacd ? ((macd[t1] > macd[t2] and high[t1] < high[t2]) ? gray : divth) : divth)
divth := (calcmacda ? ((deltamacd[t1] > deltamacd[t2] and high[t1] < high[t2]) ? gray : divth) : divth)
divth := (calcmom ? ((moment[t1] > moment[t2] and high[t1] < high[t2]) ? gray : divth) : divth)
divth := (calccci ? ((cci[t1] > cci[t2] and high[t1] < high[t2]) ? gray : divth) : divth)
divth := (calcobv ? ((obv[t1] > obv[t2] and high[t1] < high[t2]) ? gray : divth) : divth)
divth := (calcstoc ? ((stk[t1] > stk[t2] and high[t1] < high[t2]) ? gray : divth) : divth)
divth := (calcdi ? ((diosc[t1] > diosc[t2] and high[t1] < high[t2]) ? gray : divth) : divth)
divth := (calcvwmacd ? ((vwmacd[t1] > vwmacd[t2] and high[t1] < high[t2]) ? gray : divth) : divth)
divth := (calccmf ? ((cmf[t1] > cmf[t2] and high[t1] < high[t2]) ? gray : divth) : divth)
if (not na(tops))
t2 := hib
lob = _lowestbars(maxb*2 - 1)
b2 = nz(b2[1]) + 1
b1 = 0
divb = white
divbh = white
if (not na(bots) or (na(bots) and _lowestbars(b2+1) == 0))
b1 := na(bots) ? 0 : lob
divb := (calcrsi ? ((rsi[b1] > rsi[b2] and low[b1] <= low[b2]) ? lime : divb) : divb)
divb := (calcmacd ? ((macd[b1] > macd[b2] and low[b1] <= low[b2]) ? lime : divb) : divb)
divb := (calcmacda ? ((deltamacd[b1] > deltamacd[b2] and low[b1] <= low[b2]) ? lime : divb) : divb)
divb := (calcmom ? ((moment[b1] > moment[b2] and low[b1] <= low[b2]) ? lime : divb) : divb)
divb := (calccci ? ((cci[b1] > cci[b2] and low[b1] <= low[b2]) ? lime : divb) : divb)
divb := (calcobv ? ((obv[b1] > obv[b2] and low[b1] <= low[b2]) ? lime : divb) : divb)
divb := (calcstoc ? ((stk[b1] > stk[b2] and low[b1] <= low[b2]) ? lime : divb) : divb)
divb := (calcdi ? ((diosc[b1] > diosc[b2] and low[b1] <= low[b2]) ? lime : divb) : divb)
divb := (calcvwmacd ? ((vwmacd[b1] > vwmacd[b2] and low[b1] <= low[b2]) ? lime : divb) : divb)
divb := (calccmf ? ((cmf[b1] > cmf[b2] and low[b1] <= low[b2]) ? lime : divb) : divb)
//hidden
divbh := (calcrsi ? ((rsi[b1] < rsi[b2] and low[b1] > low[b2]) ? gray : divbh) : divbh)
divbh := (calcmacd ? ((macd[b1] < macd[b2] and low[b1] > low[b2]) ? gray : divbh) : divbh)
divbh := (calcmacda ? ((deltamacd[b1] < deltamacd[b2] and low[b1] > low[b2]) ? gray : divbh) : divbh)
divbh := (calcmom ? ((moment[b1] < moment[b2] and low[b1] > low[b2]) ? gray : divbh) : divbh)
divbh := (calccci ? ((cci[b1] < cci[b2] and low[b1] > low[b2]) ? gray : divbh) : divbh)
divbh := (calcobv ? ((obv[b1] < obv[b2] and low[b1] > low[b2]) ? gray : divbh) : divbh)
divbh := (calcstoc ? ((stk[b1] < stk[b2] and low[b1] > low[b2]) ? gray : divbh) : divbh)
divbh := (calcdi ? ((diosc[b1] < diosc[b2] and low[b1] > low[b2]) ? gray : divbh) : divbh)
divbh := (calcvwmacd ? ((vwmacd[b1] < vwmacd[b2] and low[b1] > low[b2]) ? gray : divbh) : divbh)
divbh := (calccmf ? ((cmf[b1] < cmf[b2] and low[b1] > low[b2]) ? gray : divbh) : divbh)
if (not na(bots))
b2 := lob
plot(tops, color = divt != white ? divt : na, linewidth = 3, offset = -3)
plot(tops, color = divth != white and showhidden ? divth : na, linewidth = 1, offset = -3)
plotshape(na(tops) and divt==red, style=shape.labeldown, color=red, location=location.abovebar, transp=20)
plot(bots, color = divb != white ? divb : na, linewidth = 3, offset = -3)
plot(bots, color = divbh != white and showhidden ? divbh : na, linewidth = 1, offset = -3)
plotshape(na(bots) and divb==lime, style=shape.labelup, color=lime, location=location.belowbar, transp=20)
buy = (divb == lime)
sell = (divt == red)
alertcondition(buy, title='Buy', message='Positive Divergence. Buy Signal')
alertcondition(sell, title='Sell', message='Negative Divergence. Sell Signal')
2025-05-08
318
글번호 190643
지표