本文整理汇总了C++中PlotLine类的典型用法代码示例。如果您正苦于以下问题:C++ PlotLine类的具体用法?C++ PlotLine怎么用?C++ PlotLine使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PlotLine类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
PlotLine * LOWPASS::raise2Power(PlotLine *x, double pad)
{
// Raise the caller's n up to the next power of two
// pad remainder with pad, default = 0;
PlotLine *result = new PlotLine;
int length = x->getSize();
int n = 0;
int i = 0;
for (n = 2 ; n < MAXNUM / 2 ; n *= 2)
{
if (n >= length)
break ;
}
for (i = 0; i < n; i++)
{
if (i < length)
result->append(x->getData(i));
else
result->append(pad); // pad with zero
}
return result;
}
示例2:
/* Modified/Relative Japanese Candlesticks */
PlotLine * BARS::calculateCandle ()
{
PlotLine *line = new PlotLine;
for (int loop = 0; loop < (int) data->count(); loop++)
{
double O = data->getOpen(loop);
double C = data->getClose(loop);
QColor color = barNeutralColor;
if (loop > 0)
{
if (C > data->getClose(loop - 1))
color = barUpColor;
if (C < data->getClose(loop - 1))
color = barDownColor;
}
bool fillFlag = C < O ? TRUE : FALSE;
line->append(color, O, data->getHigh(loop), data->getLow(loop), C, fillFlag);
QDateTime dt;
data->getDate(loop, dt);
line->append(dt);
}
line->setType(PlotLine::Candle);
line->setLabel(label);
return line;
}
示例3:
PlotLine * IndicatorPlugin::getWilderMA (PlotLine *d, int period)
{
PlotLine *wilderma = new PlotLine;
if (period >= (int) d->getSize())
return wilderma;
if (period < 1)
return wilderma;
double t = 0;
int loop;
for (loop = 0; loop < period; loop++)
t = t + d->getData(loop);
double yesterday = t / period;
wilderma->append(yesterday);
for (; loop < (int) d->getSize(); loop++)
{
double t = (yesterday * (period - 1) + d->getData(loop))/period;
yesterday = t;
wilderma->append(t);
}
return wilderma;
}
示例4: it
IndicatorPlugin::IndicatorPlugin()
{
saveFlag = FALSE;
dateFlag = FALSE;
logScale = FALSE;
PlotLine pl;
pl.getLineTypes(lineTypes);
BarData it(pluginName);
it.getInputFields(inputTypeList);
opList.append("EQ");
opList.append("LT");
opList.append("LTEQ");
opList.append("GT");
opList.append("GTEQ");
opList.append("AND");
opList.append("OR");
opList.append("XOR");
maList.append("SMA"); // TA_MAType_SMA =0,
maList.append("EMA"); // TA_MAType_EMA =1,
maList.append("WMA"); // TA_MAType_WMA =2,
maList.append("DEMA"); // TA_MAType_DEMA =3,
maList.append("TEMA"); // TA_MAType_TEMA =4,
maList.append("TRIMA"); // TA_MAType_TRIMA =5,
maList.append("KAMA"); // TA_MAType_KAMA =6,
maList.append("MAMA"); // TA_MAType_MAMA =7,
maList.append("T3"); // TA_MAType_T3 =8
maList.append("Wilder");
}
示例5: switch
PlotLine * TALIB::getMA (PlotLine *in, int type, int period)
{
PlotLine *ma = new PlotLine;
TA_Real input[in->getSize()];
TA_Real out[in->getSize()];
TA_Integer outBeg;
TA_Integer count;
TA_RetCode rc = TA_SUCCESS;
int loop;
for (loop = 0; loop < in->getSize(); loop++)
input[loop] = (TA_Real) in->getData(loop);
switch (type)
{
case 0:
rc = TA_MA(0, in->getSize()- 1, &input[0], period, TA_MAType_SMA, &outBeg, &count, &out[0]);
break;
case 1:
rc = TA_MA(0, in->getSize()- 1, &input[0], period, TA_MAType_EMA, &outBeg, &count, &out[0]);
break;
case 2:
rc = TA_MA(0, in->getSize()- 1, &input[0], period, TA_MAType_WMA, &outBeg, &count, &out[0]);
break;
case 3:
rc = TA_MA(0, in->getSize()- 1, &input[0], period, TA_MAType_DEMA, &outBeg, &count, &out[0]);
break;
case 4:
rc = TA_MA(0, in->getSize()- 1, &input[0], period, TA_MAType_TEMA, &outBeg, &count, &out[0]);
break;
case 5:
rc = TA_MA(0, in->getSize()- 1, &input[0], period, TA_MAType_TRIMA, &outBeg, &count, &out[0]);
break;
case 6:
rc = TA_MA(0, in->getSize()- 1, &input[0], period, TA_MAType_KAMA, &outBeg, &count, &out[0]);
break;
case 7:
rc = TA_MA(0, in->getSize()- 1, &input[0], period, TA_MAType_MAMA, &outBeg, &count, &out[0]);
break;
case 8:
rc = TA_MA(0, in->getSize()- 1, &input[0], period, TA_MAType_T3, &outBeg, &count, &out[0]);
break;
default:
break;
}
if (rc != TA_SUCCESS)
{
qDebug("TALIB::getMA:error on TALIB function call");
return ma;
}
for (loop = 0; loop < count; loop++)
ma->append((double) out[loop]);
return ma;
}
示例6:
PlotLine *qtsFFT::do_iFFTqts(PlotLine *f)
{
PlotLine * result = new PlotLine;
int i = 0;
for (i = 0; i < length; i++)
{
fftFreq[i] = f->getData(i);
}
_ftt_Real.do_ifft(fftFreq, fftReal);
_ftt_Real.rescale(fftReal);
for (i = 0; i < length; i++)
{
result->append(fftReal[i]);
}
return result;
}
示例7: qDebug
Indicator * LOWPASS::calculate ()
{
Indicator *output = new Indicator;
output->setDateFlag(dateFlag);
output->setLogScale(logScale);
PlotLine *in = data->getInput(input);
if (! in)
{
qDebug("LOWPASS::calculate: no input");
return output;
}
PlotLine *line = getLowpass(in, freq, width);
line->setColor(color);
line->setType(lineType);
line->setLabel(label);
output->addLine(line);
delete in;
return output;
}
示例8: qDebug
PlotLine * PP::calculateCustom (QString &p, QPtrList<PlotLine> &d)
{
// format1: PP_TYPE
if (checkFormat(p, d, 1, 1))
return 0;
int t = ppList.findIndex(formatStringList[0]);
if (t == -1)
{
qDebug("PP::calculateCustom: invalid PP_TYPE parm");
return 0;
}
QPtrList<PlotLine> pll;
pll.setAutoDelete(TRUE);
getPP(pll);
PlotLine *line = new PlotLine;
PlotLine *tline = pll.at(t);
line->copy(tline);
return line;
}
示例9: qDebug
void CUS::createPlot (QString &d, QDict<PlotLine> &lines, Indicator *output)
{
if (! d.contains("plot"))
return;
QStringList l = QStringList::split("(", d, FALSE);
if (l.count() != 2)
{
qDebug("CUS::createPlot: bad plot format: %s", d.ascii());
return;
}
QString parms = l[1];
parms.truncate(parms.find(")", -1, TRUE));
l = QStringList::split(",", parms, FALSE);
if (l.count() != 4)
{
qDebug("CUS::createPlot: missing plot parms: %s",d.ascii());
return;
}
// 1.var name
l[0] = l[0].stripWhiteSpace();
PlotLine *pl = lines.find(l[0]);
if (! pl)
{
qDebug("CUS::createPlot: bad plot parm 1: %s",d.ascii());
return;
}
// 2.color
l[1] = l[1].stripWhiteSpace();
pl->setColor(l[1]);
// 3.label
l[2] = l[2].stripWhiteSpace();
pl->setLabel(l[2]);
// 4.linetype
l[3] = l[3].stripWhiteSpace();
pl->setType(l[3]);
PlotLine *tline = new PlotLine;
tline->copy(pl);
output->addLine(tline);
}
示例10: getMA
void BARS::calculateMA (Indicator *output)
{
if (maPeriod > 1)
{
PlotLine *in = data->getInput(maInput);
if (in)
{
PlotLine *ma = getMA(in, maType, maPeriod);
ma->setColor(maColor);
ma->setType(maLineType);
ma->setLabel(maLabel);
output->addLine(ma);
delete in;
}
}
if (maPeriod2 > 1)
{
PlotLine *in = data->getInput(maInput2);
if (in)
{
PlotLine *ma = getMA(in, maType2, maPeriod2);
ma->setColor(maColor2);
ma->setType(maLineType2);
ma->setLabel(maLabel2);
output->addLine(ma);
delete in;
}
}
if (maPeriod3 > 1)
{
PlotLine *in = data->getInput(maInput3);
if (in)
{
PlotLine *ma = getMA(in, maType3, maPeriod3);
ma->setColor(maColor3);
ma->setType(maLineType3);
ma->setLabel(maLabel3);
output->addLine(ma);
delete in;
}
}
if (maPeriod4 > 1)
{
PlotLine *in = data->getInput(maInput4);
if (in)
{
PlotLine *ma = getMA(in, maType4, maPeriod4);
ma->setColor(maColor4);
ma->setType(maLineType4);
ma->setLabel(maLabel4);
output->addLine(ma);
delete in;
}
}
}
示例11: getPFSettings
/* Pont and Figure */
PlotLine * BARS::calculatePF ()
{
PlotLine *line = new PlotLine;
// determine start either x or o
if (data->count() < 2)
return line;
getPFSettings();
bool XOFlag = FALSE;
if (data->getHigh(1) > data->getHigh(0))
XOFlag = TRUE; // prices rising, we start with x's
double high = 0;
double d = data->getHigh(0) / pfBoxSize;
int t = (int) d;
if (t * pfBoxSize <= data->getHigh(0))
high = (t + 1) * pfBoxSize;
else
high = t * pfBoxSize;
double low = 0;
t = (int) (data->getLow(0) / pfBoxSize);
low = t * pfBoxSize;
int loop;
for (loop = 1; loop < (int) data->count(); loop++)
{
if (XOFlag)
{
if (data->getHigh(loop) > high)
{
// new high
d = data->getHigh(loop) / pfBoxSize;
t = (int) d;
if (t * pfBoxSize <= data->getHigh(loop))
high = (t + 1) * pfBoxSize;
else
high = t * pfBoxSize;
}
double reversal = high - (pfBoxSize * pfReversal);
if (data->getLow(loop) < reversal)
{
// reversal to O's
line->append(pfXColor, pfBoxSize, high, low, low, XOFlag);
high = high - pfBoxSize; // lower high 1 box
t = (int) (data->getLow(loop) / pfBoxSize);
low = t * pfBoxSize;
XOFlag = FALSE;
}
}
else
{
if (data->getLow(loop) < low)
{
// new low
t = (int) (data->getLow(loop) / pfBoxSize);
low = t * pfBoxSize;
}
double reversal = low + (pfBoxSize * pfReversal);
if (data->getHigh(loop) > reversal)
{
// reversal to X's
line->append(pfOColor, pfBoxSize, high, low, low, XOFlag);
low = low + pfBoxSize; // raise low 1 box
d = data->getHigh(loop) / pfBoxSize;
t = (int) d;
if (t * pfBoxSize <= data->getHigh(loop))
high = (t + 1) * pfBoxSize;
else
high = t * pfBoxSize;
XOFlag = TRUE;
}
}
}
if (XOFlag)
line->append(pfXColor, pfBoxSize, high, low, low, XOFlag);
else
line->append(pfOColor, pfBoxSize, high, low, low, XOFlag);
line->setType(PlotLine::PF);
line->setLabel(label);
return line;
}
示例12: tr
//.........这里部分代码省略.........
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();
}
示例13: PlotLine
void PP::getPP (QPtrList<PlotLine> &pll)
{
double high = data->getHigh(data->count() - 1);
double low = data->getLow(data->count() - 1);
double close = data->getClose(data->count() - 1);
PlotLine *fr = new PlotLine();
fr->setColor(resColor);
fr->setType(resLineType);
fr->setLabel(resLabel);
double pp = (high + low + close) / 3;
double t = (2 * pp) - low;
fr->append(t);
PlotLine *sr = new PlotLine();
sr->setColor(resColor);
sr->setType(resLineType);
sr->setLabel(resLabel2);
pp = (high + low + close) / 3;
t = pp + (high - low);
sr->append(t);
PlotLine *thr = new PlotLine();
thr->setColor(resColor);
thr->setType(resLineType);
thr->setLabel(resLabel3);
pp = (high + low + close) / 3;
t = (2 * pp) + (high - (2 * low));
thr->append(t);
PlotLine *fs = new PlotLine();
fs->setColor(supColor);
fs->setType(supLineType);
fs->setLabel(supLabel);
pp = (high + low + close) / 3;
t = (2 * pp) - high;
fs->append(t);
PlotLine *ss = new PlotLine();
ss->setColor(supColor);
ss->setType(supLineType);
ss->setLabel(supLabel2);
pp = (high + low + close) / 3;
t = pp - (high - low);
ss->append(t);
PlotLine *ts = new PlotLine();
ts->setColor(supColor);
ts->setType(supLineType);
ts->setLabel(supLabel3);
pp = (high + low + close) / 3;
t = (2 * pp) - ((2 * high) - low);
ts->append(t);
pll.append(fr);
pll.append(sr);
pll.append(thr);
pll.append(fs);
pll.append(ss);
pll.append(ts);
}
示例14: 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;
}
//.........这里部分代码省略.........
示例15: TA_GetFuncHandle
//.........这里部分代码省略.........
retCode = TA_SetOutputParamRealPtr(parmHolder, loop, &out2[0]);
if (retCode != TA_SUCCESS)
qDebug("TALIB::calculate:cannot set output2");
break;
case 2:
retCode = TA_SetOutputParamRealPtr(parmHolder, loop, &out3[0]);
if (retCode != TA_SUCCESS)
qDebug("TALIB::calculate:cannot set output3");
break;
default:
break;
}
}
// call the function
TA_Integer start = 0;
TA_Integer end = data->count() - 1;
TA_Integer outstart;
TA_Integer count;
retCode = TA_CallFunc(parmHolder, start, end, &outstart, &count);
if (retCode != TA_SUCCESS)
qDebug("TALIB::calculate:call function failed");
else
{
// create the plotlines
const TA_OutputParameterInfo *outInfo;
for (loop = 0; loop < (int) theInfo->nbOutput; loop++ )
{
TA_GetOutputParameterInfo(theInfo->handle, loop, &outInfo);
QString base = outInfo->paramName;
base = base.right(base.length() - 3);
if (! base.left(4).compare("Real"))
base = base.right(base.length() - 4);
if (! base.left(7).compare("Integer"))
base = base.right(base.length() - 7);
if (! base.length())
base = QObject::tr("Plot");
PlotLine *line = new PlotLine;
QString s = base + " " + QObject::tr("Color");
parms.getData(s, ts);
QColor color(ts);
line->setColor(color);
s = base + " " + QObject::tr("Label");
parms.getData(s, ts);
line->setLabel(ts);
s = base + " " + QObject::tr("Line Type");
line->setType((PlotLine::LineType)parms.getInt(s));
retCode = TA_GetOutputParameterInfo(handle, loop, &outInfo);
if (retCode != TA_SUCCESS)
{
qDebug("TALIB::calculate:cannot get output info");
delete line;
continue;
}
int loop2;
switch (loop)
{
case 0:
if (outInfo->type == TA_Output_Integer)
{
for (loop2 = 0; loop2 < count; loop2++)
line->append((double) out4[loop2]);
}
else
{
for (loop2 = 0; loop2 < count; loop2++)
line->append((double) out1[loop2]);
}
break;
case 1:
for (loop2 = 0; loop2 < count; loop2++)
line->append((double) out2[loop2]);
break;
case 2:
for (loop2 = 0; loop2 < count; loop2++)
line->append((double) out3[loop2]);
break;
default:
break;
}
if (line->getType() == PlotLine::Histogram || line->getType() == PlotLine::HistogramBar)
output->prependLine(line);
else
output->addLine(line);
}
}
retCode = TA_ParamHolderFree(parmHolder);
if (retCode != TA_SUCCESS)
qDebug("TALIB::calculate:can't delete parm holder");
return output;
}