这个 C++ 函数为什么不会输出图线?/////中间的代码去掉。是可以显示正确的图线的。为什么,怎么改。让pData->m_pResultBuf3[i2]=priceup;输出 [金字塔]
- 咨询内容:
__declspec(dllexport) int WINAPI AMA(CALCINFO* pData)
{
if(pData->m_pfParam1 && pData->m_pfParam2 && //参数1,2有效
pData->m_nParam1Start>=0 && //参数1为序列数
pData->m_pfParam3==NULL) //有2个参数
{
const float* pValue = pData->m_pfParam1; //参数1
int nFirst = pData->m_nParam1Start; //有效值起始位
float fParam = *pData->m_pfParam2; //参数2
int nPeriod = (int)fParam;
if( nFirst >= 0 && nPeriod > 0 )
{
float fTotal;
float noise,diff,signal,erc;
int i, k;
int datacount;
datacount= pData->m_nNumData;
if (datacount<nPeriod)
for (i=0;i<nPeriod-1;i++)
fTotal=pData->m_pData[i].m_fClose;
else
i=nPeriod-1;
fTotal=pData->m_pData[i-1].m_fClose;
while (i<=datacount)
{
noise=0.0f;
diff=0.0f;
for (k=1;k<nPeriod;k++)
{
diff=fabs(pValue[i-k+1]-pValue[i-k]);
noise+=diff;
}
signal=fabs(pValue[i]-pValue[i-nPeriod+1]);
if (noise==0.0f)
erc=0.0f;
else
{
erc=(signal/noise);
}
fTotal+=erc*(pValue[i]-fTotal);
pData->m_pResultBuf[i] = fTotal;//--------------------------------------------
////////下面插入pricedn值 and priceup值 的计算:
int i2;
float pricedn;
float priceup;
int k1,k2;
double mindiff;
float noise1,diff1,signal1,erc1;
i2=i;
mindiff=0.01;
if (pData->m_pResultBuf[i2]>=pData->m_pResultBuf[i2-1])
for (k1=1;k1<=1000000;k1++)
{
pricedn=pData->m_pData[i2-1].m_fClose-k1*mindiff;
noise1=0;
diff1=0;
signal1=0;
for (k2=1;k2<=nPeriod-1;k2++)
{
diff1=fabs(pValue[i2-k2+1]-pValue[i2-k2]);
noise1=noise1+diff1;
}
noise1=noise1+fabs(pricedn-pValue[i2-1]);
signal1=fabs(pricedn-pValue[i-nPeriod+1]);
if (noise1==0)
erc1=0;
else
erc1=signal1/noise1;
pData->m_pResultBuf1[i2]=pData->m_pResultBuf[i2-1]+erc1*(pricedn-pData->m_pResultBuf[i2-1]);
if (pData->m_pResultBuf1[i2] < pData->m_pResultBuf[i2-1])
k1=1000001;
pData->m_pResultBuf2[i2]=pricedn;
}else
for (k1=1;k1<=1000000;k1++)
{
priceup=pData->m_pData[i2-1].m_fClose+k1*mindiff;
noise1=0;
diff1=0;
signal1=0;
for (k2=1;k2<=nPeriod-2;k2++)
{
diff1=fabs(pValue[i2-k2+1]-pValue[i2-k2]);
noise1=noise1+diff1;
}
noise1=noise1+fabs(priceup-pData->m_pData[i2-1].m_fClose);
signal1=fabs(priceup-pData->m_pData[i2-(nPeriod-1)].m_fClose);
if (noise1==0)
erc1=0;
else
erc1=signal1/noise1;
pData->m_pResultBuf1[i2]=pData->m_pResultBuf[i2-1]+erc1*(priceup-pData->m_pResultBuf[i2-1]);
if (pData->m_pResultBuf1[i2]>=pData->m_pResultBuf[i2-1])
k1=1000001;
pData->m_pResultBuf3[i2]=priceup;
}//pricedn值 and priceup值 计算结束
//----------------------------------------------
i++;
}
return nFirst+nPeriod-1;
}
}
return -1;
} - 金字塔客服:
return nFirst+nPeriod-1;和return -1;
有什么作用
- 用户回复:
pResultBuf1,pResultBuf2等这些都不是金字塔支持的类型。
返回值的定义问题,请参考 http://www.weistock.com/bbs/dispbbs.asp?boardid=4&Id=10616
相关文章
-
没有相关内容