Curve * OHLC::getMA (Entity *settings, int num) { QString key = "ma" + QString::number(num) + "Input"; QVariant *input = settings->get(key); if (! input) return 0; key = "ma" + QString::number(num) + "Type"; QVariant *type = settings->get(key); if (! type) return 0; key = "ma" + QString::number(num) + "Style"; QVariant *style = settings->get(key); if (! style) return 0; key = "ma" + QString::number(num) + "Width"; QVariant *width = settings->get(key); if (! width) return 0; key = "ma" + QString::number(num) + "Period"; QVariant *period = settings->get(key); if (! period) return 0; key = "ma" + QString::number(num) + "Color"; QVariant *color = settings->get(key); if (! color) return 0; key = "ma" + QString::number(num) + "Label"; QVariant *label = settings->get(key); if (! label) return 0; MAType mat; if (! getMA(input->toString(), label->toString(), mat.stringToIndex(type->toString()), period->toInt())) return 0; Curve *curve = new Curve(QString("CurveLine")); curve->setLabel(label->toString()); CurveLineType clt; curve->setStyle(clt.stringToIndex(style->toString())); curve->setPen(width->toInt()); curve->setColor(QColor(color->toString())); curve->fill(label->toString(), QString(), QString(), QString(), QColor()); return curve; }
Curve * RSI::getMA (Entity *settings) { QVariant *type = settings->get(QString("maType")); if (! type) return 0; QVariant *period = settings->get(QString("maPeriod")); if (! period) return 0; QVariant *var = settings->get(QString("maColor")); if (! var) return 0; QColor color(var->toString()); QVariant *label = settings->get(QString("maLabel")); if (! label) return 0; QVariant *style = settings->get(QString("maStyle")); if (! style) return 0; QVariant *width = settings->get(QString("maWidth")); if (! width) return 0; QVariant *rsiLabel = settings->get(QString("label")); if (! rsiLabel) return 0; if (! getMA(rsiLabel->toString(), label->toString(), type->toInt(), period->toInt())) return 0; CurveLineType clt; Curve *curve = new Curve(QString("CurveLine")); curve->setLabel(label->toString()); curve->setStyle(clt.stringToIndex(style->toString())); curve->setPen(width->toInt()); curve->setColor(color); curve->fill(label->toString(), QString(), QString(), QString(), color); return curve; }
int RSI::run (PluginData *pd) { if (! g_symbol) return 0; QVariant *input = pd->settings->get(QString("input")); if (! input) return 0; QVariant *period = pd->settings->get(QString("period")); if (! period) return 0; QVariant *label = pd->settings->get(QString("label")); if (! label) return 0; if (! getRSI(input->toString(), period->toInt(), label->toString())) return 0; // rsi QVariant *show = pd->settings->get(QString("rsiShow")); if (! show) return 0; if (show->toBool()) { QVariant *style = pd->settings->get(QString("style")); if (! style) return 0; QVariant *width = pd->settings->get(QString("width")); if (! width) return 0; QVariant *var = pd->settings->get(QString("color")); if (! var) return 0; QColor color(var->toString()); CurveLineType clt; Curve *rsi = new Curve(QString("CurveLine")); rsi->setColor(color); rsi->setLabel(label->toString()); rsi->setStyle(clt.stringToIndex(style->toString())); rsi->fill(label->toString(), QString(), QString(), QString(), color); rsi->setPen(width->toInt()); pd->curves << rsi; } // ma show = pd->settings->get(QString("maShow")); if (! show) return 0; if (show->toBool()) { Curve *ma = getMA(pd->settings); if (ma) pd->curves << ma; } // buy marker show = pd->settings->get(QString("buyMarkerShow")); if (! show) return 0; if (show->toBool()) { QVariant *var = pd->settings->get(QString("buyMarkerColor")); if (! var) return 0; QColor color(var->toString()); QVariant *price = pd->settings->get(QString("buyMarkerPrice")); if (! price) return 0; Marker *m = newMarker(color, price->toDouble()); if (! m) return 0; pd->markers << m; } // sell marker show = pd->settings->get(QString("sellMarkerShow")); if (! show) return 0; if (show->toBool()) { QVariant *var = pd->settings->get(QString("sellMarkerColor")); if (! var) return 0; QColor color(var->toString()); QVariant *price = pd->settings->get(QString("sellMarkerPrice")); if (! price) return 0; Marker *m = newMarker(color, price->toDouble()); if (! m) return 0; pd->markers << m; } return 1; }
int AROON::run (PluginData *pd) { if (! g_symbol) return 0; QVariant *period = pd->settings->get(QString("period")); if (! period) return 0; QVariant *ulabel = pd->settings->get(QString("upLabel")); if (! ulabel) return 0; QVariant *dlabel = pd->settings->get(QString("downLabel")); if (! dlabel) return 0; if (! getAROON(period->toInt(), ulabel->toString(), dlabel->toString())) return 0; // up QVariant *show = pd->settings->get(QString("upShow")); if (! show) return 0; if (show->toBool()) { QVariant *var = pd->settings->get(QString("upColor")); if (! var) return 0; QColor color(var->toString()); QVariant *style = pd->settings->get(QString("upStyle")); if (! style) return 0; QVariant *width = pd->settings->get(QString("upWidth")); if (! width) return 0; // up CurveLineType clt; Curve *c = new Curve(QString("CurveLine")); c->setColor(color); c->setLabel(ulabel->toString()); c->setStyle(clt.stringToIndex(style->toString())); c->fill(ulabel->toString(), QString(), QString(), QString(), QColor()); c->setPen(width->toInt()); pd->curves << c; } // down show = pd->settings->get(QString("downShow")); if (! show) return 0; if (show->toBool()) { QVariant *var = pd->settings->get(QString("downColor")); if (! var) return 0; QColor color(var->toString()); QVariant *style = pd->settings->get(QString("downStyle")); if (! style) return 0; QVariant *width = pd->settings->get(QString("downWidth")); if (! width) return 0; CurveLineType clt; Curve *c = new Curve(QString("CurveLine")); c->setColor(color); c->setLabel(dlabel->toString()); c->setStyle(clt.stringToIndex(style->toString())); c->fill(dlabel->toString(), QString(), QString(), QString(), QColor()); c->setPen(width->toInt()); pd->curves << c; } return 1; }