本文整理汇总了C++中PlotLine::getSize方法的典型用法代码示例。如果您正苦于以下问题:C++ PlotLine::getSize方法的具体用法?C++ PlotLine::getSize怎么用?C++ PlotLine::getSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PlotLine
的用法示例。
在下文中一共展示了PlotLine::getSize方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: qDebug
PlotLine * TALIB::calculateCustom (QString &p, QPtrList<PlotLine> &d)
{
// format: METHOD, ..., ...., ..... etc (first parm must be the method)
QStringList l = QStringList::split(",", p, FALSE);
if (! l.count())
{
qDebug("TALIB::calculateCustom: no method parm");
return 0;
}
TA_Integer start = 0;
TA_Integer end = data->count() - 1;
if (d.count())
end = d.at(0)->getSize() - 1;
TA_Integer outstart;
TA_Integer count;
PlotLine *line = new PlotLine;
// sometimes are not enough data available
// to calc anything
if(end < 0)
return line;
// open a TALIB handle
const TA_FuncHandle *handle;
TA_RetCode retCode = TA_GetFuncHandle(l[0], &handle);
if (retCode != TA_SUCCESS)
{
qDebug("TALIB::calculateCustom:can't open handle");
return 0;
}
// get info on the function
const TA_FuncInfo *theInfo;
retCode = TA_GetFuncInfo(handle, &theInfo);
if (retCode != TA_SUCCESS)
{
qDebug("TALIB::calculateCustom:can't get function info");
return 0;
}
// create parm holder
TA_ParamHolder *parmHolder;
retCode = TA_ParamHolderAlloc(handle, &parmHolder);
if (retCode != TA_SUCCESS)
{
qDebug("TALIB::calculateCustom:can't create parm holder");
return 0;
}
// create and input arrays
int loop = data->count();
TA_Real open[loop];
TA_Real high[loop];
TA_Real low[loop];
TA_Real close[loop];
TA_Real volume[loop];
TA_Real oi[loop];
TA_Real treal[loop];
int sparmIndex = 1;
// setup the input arrays
const TA_InputParameterInfo *inputParms;
for (loop = 0; loop < (int) theInfo->nbInput; loop++ )
{
TA_GetInputParameterInfo(theInfo->handle, loop, &inputParms);
if (inputParms->type == TA_Input_Price)
{
// populate the input arrays
int loop2;
for (loop2 = 0; loop2 < data->count(); loop2++)
{
open[loop2] = (TA_Real) data->getOpen(loop2);
high[loop2] = (TA_Real) data->getHigh(loop2);
low[loop2] = (TA_Real) data->getLow(loop2);
close[loop2] = (TA_Real) data->getClose(loop2);
volume[loop2] = (TA_Real) data->getVolume(loop2);
oi[loop2] = (TA_Real) data->getOI(loop2);
}
retCode = TA_SetInputParamPricePtr(parmHolder, loop, &open[0], &high[0], &low[0], &close[0],
&volume[0], &oi[0]);
if (retCode != TA_SUCCESS)
{
qDebug("TALIB::calculateCustom:cannot set input prices");
return 0;
}
}
if (inputParms->type == TA_Input_Real)
{
if (! d.count())
{
qDebug("TALIB::calculateCustom: no input");
return 0;
}
//.........这里部分代码省略.........
示例2: scan
//.........这里部分代码省略.........
int loop;
dir.setPath(s);
for (loop = 2; loop < (int) dir.count(); loop++)
{
QString s2 = dir.absPath() + "/" + dir[loop];
if (! dir.remove(s2, TRUE))
qDebug("%s not removed", s2.latin1());
}
}
if (allSymbols->isChecked())
{
QString ts;
if (! basePath->currentText().compare(tr("Chart")))
config.getData(Config::DataPath, ts);
else
config.getData(Config::GroupPath, ts);
Traverse trav(Traverse::File);
trav.traverse(ts);
trav.getList(fileList);
}
QProgressDialog prog(tr("Scanning..."),
tr("Cancel"),
fileList.count(),
this,
"progress",
TRUE);
prog.show();
int minBars = bars->value();
emit message(QString("Scanning..."));
int loop;
for (loop = 0; loop < (int) fileList.count(); loop++)
{
prog.setProgress(loop);
emit message(QString());
if (prog.wasCancelled())
{
emit message(QString("Scan cancelled"));
break;
}
QFileInfo fi(fileList[loop]);
if (fi.isDir())
continue;
DbPlugin db;
QDir dir;
if (! dir.exists(fileList[loop]))
continue;
db.open(fileList[loop], chartIndex);
db.setBarRange(minBars);
db.setBarLength((BarData::BarLength) barLengthList.findIndex(period->currentText()));
BarData *recordList = new BarData(fileList[loop]);
QDateTime dt = QDateTime::currentDateTime();
db.getHistory(recordList, dt);
db.close();
// load the CUS plugin and calculate
plug->setIndicatorInput(recordList);
Indicator *i = plug->calculate();
if (! i->getLines())
{
delete recordList;
delete i;
continue;
}
PlotLine *line = i->getLine(0);
if (line && line->getSize() > 0)
{
if (line->getData(line->getSize() - 1) > 0)
{
QString ts;
config.getData(Config::GroupPath, ts);
QString s = "ln -s \"" + fileList[loop] + "\" " + ts + "/Scanner/" + scannerName;
system(s);
}
}
delete recordList;
delete i;
emit message(QString());
}
if (! prog.wasCancelled())
emit message(QString("Scan complete"));
config.closePlugin(iplugin);
this->setEnabled(TRUE);
emit scanComplete();
}
示例3: getTHERM
void THERM::getTHERM (QPtrList<PlotLine> &pll)
{
PlotLine *therm = new PlotLine();
int loop;
double thermometer = 0;
for (loop = 1; loop < (int) data->count(); loop++)
{
double high = fabs(data->getHigh(loop) - data->getHigh(loop - 1));
double lo = fabs(data->getLow(loop - 1) - data->getLow(loop));
if (high > lo)
thermometer = high;
else
thermometer = lo;
therm->append(thermometer);
}
if (smoothing > 1)
{
PlotLine *ma = getMA(therm, smoothType, smoothing);
pll.append(ma);
delete therm;
therm = ma;
}
else
pll.append(therm);
PlotLine *therm_ma = getMA(therm, maType, maPeriod);
therm_ma->setColor(maColor);
therm_ma->setType(maLineType);
therm_ma->setLabel(maLabel);
pll.append(therm_ma);
// assign the therm colors
therm->setColorFlag(TRUE);
therm->setType(lineType);
therm->setLabel(label);
int thermLoop = therm->getSize() - 1;
int maLoop = therm_ma->getSize() - 1;
while (thermLoop > -1)
{
if (maLoop > -1)
{
double thrm = therm->getData(thermLoop);
double thrmma = therm_ma->getData(maLoop);
if (thrm > (thrmma * threshold))
therm->setColorBar(thermLoop, threshColor);
else
{
if (thrm > thrmma)
therm->setColorBar(thermLoop, upColor);
else
therm->setColorBar(thermLoop, downColor);
}
}
else
therm->setColorBar(thermLoop, downColor);
thermLoop--;
maLoop--;
}
}
示例4: getSINWAV
void SINWAV::getSINWAV (Q3PtrList<PlotLine> &pll)
{
// Ehler's sine wave
PlotLine *Price = new PlotLine;
int i = 0;
// price = (h + l) / 2
for (i = 0; i < (int) data->count(); i++)
Price->append((data->getHigh(i) + data->getLow(i)) / 2);
//! VERSION 2
QVector<double> *smooth = new QVector<double>(Price->getSize());
smooth->fill(0.0);
QVector<double> *detrender = new QVector<double>(Price->getSize());
detrender->fill(0.0);
QVector<double> *period = new QVector<double>(Price->getSize());
period->fill(0.0);
QVector<double> *Q1 = new QVector<double>(Price->getSize());
Q1->fill(0.0);
QVector<double> *I1 = new QVector<double>(Price->getSize());
I1->fill(0.0);
QVector<double> *jI = new QVector<double>(Price->getSize());
jI->fill(0.0);
QVector<double> *jQ = new QVector<double>(Price->getSize());
jQ->fill(0.0);
QVector<double> *I2 = new QVector<double>(Price->getSize());
I2->fill(0.0);
QVector<double> *Q2 = new QVector<double>(Price->getSize());
Q2->fill(0.0);
QVector<double> *Re = new QVector<double>(Price->getSize());
Re->fill(0.0);
QVector<double> *Im = new QVector<double>(Price->getSize());
Im->fill(0.0);
QVector<double> *SmoothPrice = new QVector<double>(Price->getSize());
SmoothPrice->fill(0.0);
QVector<double> *DCPhase = new QVector<double>(Price->getSize());
DCPhase->fill(0.0);
PlotLine *out1 = new PlotLine;
PlotLine *out2 = new PlotLine;
double SmoothPeriod = 0;
double DCPeriod = 0;
for (i = 6; i< Price->getSize(); i++)
{
// Weighted price
(*smooth)[i] = ( 4 * Price->getData(i) + 3 * Price->getData(i-1) +
2 * Price->getData(i-2) + Price->getData(i-3)) /10.0;
(*detrender)[i] = (0.0962 * smooth->at(i) + 0.5769 * smooth->at(i-2) -
0.5769 * smooth->at(i-4) - 0.0962 * smooth->at(i-6)) *
(0.075 * period->at(i-1) + 0.54);
// Compute InPhase and Quadrature components
(*Q1)[i] = (0.0962 * detrender->at(i) + 0.5769 * detrender->at(i-2) -
0.5769 * detrender->at(i-4) - 0.0962 * detrender->at(i-6)) *
(0.075 * period->at(i-1) + 0.54);
(*I1)[i] = detrender->at(i-3);
//Advance the phase of I1 and Q1 by 90 degrees
(*jI)[i] = (0.0962 * I1->at(i) + 0.5769 * I1->at(i-2) -
0.5769 * I1->at(i-4) - 0.0962 * I1->at(i-6)) *
(0.075 * period->at(i-1) + 0.54);
(*Q1)[i] = (0.0962 * Q1->at(i) + 0.5769 * Q1->at(i-2) -
0.5769 * Q1->at(i-4) - 0.0962 * Q1->at(i-6)) *
(0.075 * period->at(i-1) + 0.54);
// Phasor addition for 3-bar averaging
(*I2)[i] = I1->at(i) - jQ->at(i);
(*Q2)[i] = Q1->at(i) + jI->at(i);
// Smooth the I and Q components before applying the discriminator
(*I2)[i] = 0.2 * I2->at(i) + 0.8 * I2->at(i-1);
(*Q2)[i] = 0.2 * Q2->at(i) + 0.8 * Q2->at(i-1);
// Homodyne Discriminator
(*Re)[i] = I2->at(i) * I2->at(i-1) + Q2->at(i) * Q2->at(i-1);
(*Im)[i] = I2->at(i) * Q2->at(i-1) - Q2->at(i) * I2->at(i-1);
(*Re)[i] = 0.2 * Re->at(i) + 0.8 * Re->at(i-1);
(*Im)[i] = 0.2 * Im->at(i) + 0.8 * Im->at(i-1);
if (Im->at(i) != 0 && Re->at(i) != 0 )
(*period)[i] = 360/(atan(Im->at(i) / Re->at(i)) * (180/PI));
if (period->at(i) > 1.5 * period->at(i-1))
(*period)[i] = 1.5 * period->at(i-1);
if (period->at(i) < 0.67 * period->at(i-1))
(*period)[i] = 0.67 * period->at(i-1);
if (period->at(i) < 6)
(*period)[i] = 6;
if (period->at(i) > 50)
(*period)[i] = 50;
(*period)[i] = 0.2 * period->at(i) + 0.8 * period->at(i-1);
SmoothPeriod = 0.33 * period->at(i) + 0.67 * SmoothPeriod;
//.........这里部分代码省略.........