예스스탁
예스스탁 답변
2025-06-19 13:23:52
안녕하세요
예스스탁입니다.
var : xClose(0),xOpen(0),xHigh(0),xLow(0);
var : A(0),B(0),B1(0),B2(0),B3(0) ;
var : do(0),dh(0),dl(0),do1(0),dh1(0),dl1(0);
if index == 0 then
{
xClose = (O+H+L+C)/4;
xOpen = open;
xHigh = MaxList( high, xOpen, xClose);
xLow = MinList( low, xOpen,xClose);
}
else
{
xClose = (O+H+L+C)/4;
xOpen = (xOpen [1] + xClose [1])/2 ;
xHigh = MaxList(High, xOpen, xClose) ;
xLow = MinList(Low, xOpen, xClose) ;
}
input : cumulativePeriod(30);
var : typicalPrice(0),typicalPriceVolume(0),cumulativeTypicalPriceVolume(0);
var : cumulativeVolume(0),vwapValue(0);
typicalPrice = (xhigh + xlow + xclose) / 3;
typicalPriceVolume = typicalPrice * volume;
cumulativeTypicalPriceVolume = AccumN(typicalPriceVolume, cumulativePeriod);
cumulativeVolume = AccumN(volume, cumulativePeriod);
vwapValue = cumulativeTypicalPriceVolume / cumulativeVolume;
//VWMA
input : shortlen(10);
input : longlen(30);
var : short(0),long(0),osc(0);
short = ema(volume, shortlen);
long = ema(volume, longlen);
osc = 100 * (short - long) / long;
//ATR-Stop
input : p(200);
input : n(5);
var : mx(0),mn(0),stop(0),hi(0);
var : c1(0),atrcolor(0);
var : alpha(0),ATRV(0);
var : TH(0),TL(0),TR(0);
If xClose[1] > xHigh then
TH = xClose[1];
else
TH = xHigh;
If xClose[1] < xlow then
TL = xClose[1];
else
TL = xlow;
TR = TH-TL;
alpha = 1 / p ;
ATrV = IFf(IsNan(ATrV[1]) == true, ma(TR,p) , alpha * TR + (1 - alpha) * IFf(isnan(ATrV[1])==true,0,ATrV[1]));
mx=xclose[1]+atrv[1]*n;
mn=xclose[1]-atrv[1]*n;
stop=mn;
hi = 1;
hi = iff(hi[1] == 1, iff(xhigh[1]>=stop[1] , 0 , 1) ,IFf(xlow[1]<=stop[1],1,0));
stop = iff(hi == 1, mx, mn);
stop = iff(hi == 1, IFf(hi[1]==0 , stop ,IFf(stop>stop[1],stop[1], stop)), IFf(hi[1] == 1, stop, IFf(stop<stop[1] , stop[1],stop)));
c1 =(stop+osc+vwapValue)/2;
atrcolor=IFf(c1>xclose,red,green);
plot1(c1, "Adapted-ATR",atrcolor);
즐거운 하루되세요
> 해암 님이 쓴 글입니다.
> 제목 : 문의드립니다.
> 아래의 1번 지표수식에 2번의 heikin ashi(이하 ha) 고가 저가 종가를 적용하는 수식으로 변경 가능할까요?
차트에 ha캔들은 나타내지 않고 1번수식의 typicalprice 에서 high low close를
ha캔들 값으로 변경적용해서 차트에 나타내고자 하는 것이 목적입니다.
부탁드립니다. 그리고 감사드립니다. 수고하세요!!!
=========================
1.
//@version=4
study(title="VWAP-VWMA-ATR", shorttitle="Adapted-ATR", overlay=true)
//VWAP
cumulativePeriod = input(30, "Period")
typicalPrice = (high + low + close) / 3
typicalPriceVolume = typicalPrice * volume
cumulativeTypicalPriceVolume = sum(typicalPriceVolume, cumulativePeriod)
cumulativeVolume = sum(volume, cumulativePeriod)
vwapValue = cumulativeTypicalPriceVolume / cumulativeVolume
//VWMA
shortlen = input(10, minval=1)
longlen = input(30, minval=1)
short = ema(volume, shortlen)
long = ema(volume, longlen)
osc = 100 * (short - long) / long
//ATR-Stop
p=input(200,"Period")
m=input(5,"Multiplier")
max=close[1]+atr(p)[1]*m
min=close[1]-atr(p)[1]*m
stop=min
hi=true
hi:=hi[1]?high[1]>=stop[1]?false:true:low[1]<=stop[1]?true:false
stop:=hi?max:min
stop:=hi?hi[1]==false?stop:stop>stop[1]?stop[1]:stop:hi[1]?stop:stop<stop[1]?stop[1]:stop
//VWAP-VWMA-ATR
c1 =(stop+osc+vwapValue)/2
//ATRCOLOR
atrcolor=(c1>close?color.red:color.green)
//Plot
plot(c1, title="Adapted-ATR", linewidth=2, color=atrcolor, transp=0)
//BarColor
barcolor(close>c1 ? color.green : color.red)
===========================
2.
indicator('Heiken Ashi Candles', 'Heiken Ashi', overlay = true)
//Heiken Ashi
isHA = input(true, 'HA Candles')
heikenashi_1 = ticker.heikinashi(syminfo.tickerid)
data = isHA ? heikenashi_1 : syminfo.tickerid
o = request.security(data, timeframe.period, open)
h = request.security(data, timeframe.period, high)
l = request.security(data, timeframe.period, low)
c = request.security(data, timeframe.period, close)
col = c > o ? color.green : color.red
plotcandle(o, h, l, c, 'Heiken Ashi', col, color.black)