커뮤니티
수식부탁드립니다.
2012-03-03 13:25:59
608
글번호 48513
LSMA 라는 이동평균이 있던데요.
원문은
What is an LSMA? It stands for Least Squares Moving Average and
the indicator plots the endpoint of the linear regression line.
By comparing the current value to the prior value
a determination is made of a possible trend,
ie the linear regression line is pointing up or down.
Use the close of the current candle after it is finished and
the next candle is forming as the end point.
That avoids the problem of a candle changing the value of the indicator in real time.
LSMA란 최소자승이동평균으로 직선회귀선이 끝나는 지점값을 그린다.
현재값을 앞의 값과 비교해서 나온 값은 가능한 추세를 만든다.
예를 들면 직선회귀선은 상승이나 하락을 나타낸다.
현재 캔들이 완성된 뒤의 종가를 사용하여 다음 캔들의 종가를 나타내는 것이다.
이는 실시간에 캔들값의 변화가 지표값을 변화시키는 것을 예방해준다.
본문 원수식은
int start()
{
Draw4HowLong=Bars-Rperiod - 5;
length=Rperiod;
loopbegin=Draw4HowLong - length - 1;
//----
for(shift=loopbegin; shift>=0; shift--)
{
sum[1]=0;
for(i=length; i>=1 ;i--)
{
lengthvar=length + 1;
lengthvar/=3;
tmp=0;
tmp =(i - lengthvar)*Close[length-i+shift];
sum[1]+=tmp;
}
wt[shift]=sum[1]*6/(length*(length+1));
이동평균기간값을 3으로 나누어서 가중평균을 내는 것 같은데요.
그래서 제가 이를 유추해서 만들어 봤는데
====================================================================
input : period(21);
var : cnt(0),shift(0),tmp(0),length(0),lengthvar(0),wt(0),sum(0);
length = period;
sum[1] = 0;
for cnt = length to 1
{
lengthvar = length +1;
lengthvar = lengthvar/3;
tmp = 0;
tmp = (length - lengthvar)*C[length - cnt];
sum[1] = sum[1] + tmp;
}
wt = sum[1]*6/(length*(length+1));
plot1(wt);
어디가 잘못되었는지요..
부탁드립니다.
답변 1
예스스탁 예스스탁 답변
2012-03-05 10:51:06
안녕하세요
예스스탁입니다.
올리신 내용만으로는 정확한 내용이 파악이 되지 않습니다.
sum과 wt는 배열변수로 선언하셔야 하며
원수식에서 for문이 이중으로 되어 있습니다.
input : Rperiod(0),Bars(0);
var : Draw4HowLong(0),length(0),loopbegin(0),shift(0),ii(0),lengthvar(0),tmp(0);
Array : Sum[100](0),wt[100](0);
Draw4HowLong = Bars-Rperiod - 5;
length=Rperiod;
loopbegin=Draw4HowLong - length - 1;
for shift = loopbegin DownTo 0
{
sum[1] = 0;
for ii = length DownTo 1
{
lengthvar=length + 1;
tmp=0;
tmp =(ii - lengthvar/3)*Close[length-ii+shift];
sum[1] = sum[1]+tmp;
}
wt[shift]=sum[1]*6/(length*(length+1));
}
즐거운 하루되세요
> 무지개나날들 님이 쓴 글입니다.
> 제목 : 수식부탁드립니다.
> LSMA 라는 이동평균이 있던데요.
원문은
What is an LSMA? It stands for Least Squares Moving Average and
the indicator plots the endpoint of the linear regression line.
By comparing the current value to the prior value
a determination is made of a possible trend,
ie the linear regression line is pointing up or down.
Use the close of the current candle after it is finished and
the next candle is forming as the end point.
That avoids the problem of a candle changing the value of the indicator in real time.
LSMA란 최소자승이동평균으로 직선회귀선이 끝나는 지점값을 그린다.
현재값을 앞의 값과 비교해서 나온 값은 가능한 추세를 만든다.
예를 들면 직선회귀선은 상승이나 하락을 나타낸다.
현재 캔들이 완성된 뒤의 종가를 사용하여 다음 캔들의 종가를 나타내는 것이다.
이는 실시간에 캔들값의 변화가 지표값을 변화시키는 것을 예방해준다.
본문 원수식은
int start()
{
Draw4HowLong=Bars-Rperiod - 5;
length=Rperiod;
loopbegin=Draw4HowLong - length - 1;
//----
for(shift=loopbegin; shift>=0; shift--)
{
sum[1]=0;
for(i=length; i>=1 ;i--)
{
lengthvar=length + 1;
lengthvar/=3;
tmp=0;
tmp =(i - lengthvar)*Close[length-i+shift];
sum[1]+=tmp;
}
wt[shift]=sum[1]*6/(length*(length+1));
이동평균기간값을 3으로 나누어서 가중평균을 내는 것 같은데요.
그래서 제가 이를 유추해서 만들어 봤는데
====================================================================
input : period(21);
var : cnt(0),shift(0),tmp(0),length(0),lengthvar(0),wt(0),sum(0);
length = period;
sum[1] = 0;
for cnt = length to 1
{
lengthvar = length +1;
lengthvar = lengthvar/3;
tmp = 0;
tmp = (length - lengthvar)*C[length - cnt];
sum[1] = sum[1] + tmp;
}
wt = sum[1]*6/(length*(length+1));
plot1(wt);
어디가 잘못되었는지요..
부탁드립니다.
다음글
이전글