C++ 股票分析软件 EMA算法谁懂?

北极心 发布于 2016/09/01 16:26
阅读 352
收藏 0
c++
// ema
int CFormularComputeParent::Func8034() 
{
int cl,cr,ret;
ARRAY_BE fcl,fcr;

fcl.line = new float[m_MaxPoint];
fcr.line = new float[m_MaxPoint];

cl=m_table.pop_it();
GetData(cl,fcl);
cr=m_table.pop_it();
GetData(cr,fcr);
ret = fcr.b;
ret =(int)fcr.line[ret];
if(ret<1) 
{
delete[] fcl.line;
delete[] fcr.line;
return 34;
}


m_MidArray[m_MidNum].kind = ARRAY_BE::Normal;
m_MidArray[m_MidNum].line = new float[m_MaxPoint];
m_MidArray[m_MidNum].b =fcl.b+ret-1; 
m_MidArray[m_MidNum].e =fcl.e;


int bl = m_MidArray[m_MidNum].b;
int be = m_MidArray[m_MidNum].e;
//(该日DI -前一日的EMA_M)* 2 / (M+1) +前一日的EMA_M
//m_pData[i].close 
if(bl>be||be>m_MaxPoint-1||bl<0)
{
m_table.push_b(PCMB+m_MidNum);
m_MidNum++;
delete[] fcl.line;
delete[] fcr.line;
return 999;
}
m_MidArray[m_MidNum].line[bl]=fcl.line[bl];


double db = fcl.line[bl];
for(int i1=bl+1;i1<=be;i1++)
{
//add lmb ;20030301
ret = fcr.line[i1]+1;
if(ret<1) ret = 1;
//end add
db = (fcl.line[i1]-db)*2.0/(ret) + db;
m_MidArray[m_MidNum].line[i1]=db;
}


m_table.push_b(PCMB+m_MidNum);
m_MidNum++;

delete[] fcl.line;
delete[] fcr.line;
return 0;
}




ARRAY_BE对象

class ARRAY_BE
{ 
public:
	float *line;
	int b;
	int e;
	float *lineWidth;

	enum Kind
	{
		Normal = 0,
		DrawLine,
		DrawPolyLine,
		DrawStickLine,
		DrawIcon,
		StringData,//DrawString
		LineRt,
	};

	Kind kind;//0 is normal,1 is draw line,3 is line data of right box,2 is string
	WORD nLineWidth;
	WORD isVirtualLine;
	CString s;
	ARRAY_Right_Box lineRight;
	looseValueArray looseArr;

	ARRAY_BE()
	{
		s = "";
		line = NULL;
		lineWidth = NULL;
		kind = Normal;
		b=0;
		e = 0;
		nLineWidth = 1;
		isVirtualLine = 0;
	};






加载中
返回顶部
顶部