qtstalker-cvs-commits Mailing List for Qtstalker
Brought to you by:
sstratos
You can subscribe to this list here.
2004 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(7) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2005 |
Jan
(82) |
Feb
(145) |
Mar
(254) |
Apr
(19) |
May
(260) |
Jun
(15) |
Jul
|
Aug
(5) |
Sep
(38) |
Oct
(166) |
Nov
(33) |
Dec
|
2006 |
Jan
(5) |
Feb
(49) |
Mar
|
Apr
|
May
(2) |
Jun
|
Jul
|
Aug
|
Sep
(87) |
Oct
(12) |
Nov
(57) |
Dec
(79) |
2007 |
Jan
(58) |
Feb
(38) |
Mar
(12) |
Apr
(4) |
May
(66) |
Jun
(69) |
Jul
(4) |
Aug
|
Sep
(36) |
Oct
(23) |
Nov
(11) |
Dec
(2) |
2008 |
Jan
|
Feb
(5) |
Mar
|
Apr
(65) |
May
(44) |
Jun
(4) |
Jul
(30) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2009 |
Jan
(6) |
Feb
|
Mar
(3) |
Apr
(26) |
May
(29) |
Jun
(47) |
Jul
(30) |
Aug
(8) |
Sep
(113) |
Oct
(47) |
Nov
(29) |
Dec
(4) |
2010 |
Jan
(33) |
Feb
(228) |
Mar
(317) |
Apr
(104) |
May
(214) |
Jun
(232) |
Jul
(163) |
Aug
|
Sep
(217) |
Oct
(240) |
Nov
(156) |
Dec
(418) |
2011 |
Jan
(161) |
Feb
(20) |
Mar
(122) |
Apr
(113) |
May
(1) |
Jun
|
Jul
(4) |
Aug
(19) |
Sep
(32) |
Oct
(11) |
Nov
|
Dec
(3) |
2012 |
Jan
(26) |
Feb
(14) |
Mar
|
Apr
|
May
|
Jun
(17) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2013 |
Jan
|
Feb
(57) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Steve S. <sst...@us...> - 2013-02-20 22:20:02
|
Update of /cvsroot/qtstalker/qtstalker In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv18489/qtstalker Modified Files: qtstalker.pro Log Message: Index: qtstalker.pro =================================================================== RCS file: /cvsroot/qtstalker/qtstalker/qtstalker.pro,v retrieving revision 1.167 retrieving revision 1.168 diff -C2 -d -r1.167 -r1.168 *** qtstalker.pro 19 Feb 2013 00:26:33 -0000 1.167 --- qtstalker.pro 20 Feb 2013 22:19:59 -0000 1.168 *************** *** 102,117 **** # compile plugins ! SUBDIRS += plugins/AD ! SUBDIRS += plugins/ADX ! SUBDIRS += plugins/ADXR ! SUBDIRS += plugins/Arithmetic ! SUBDIRS += plugins/AROON ! SUBDIRS += plugins/ATR ! SUBDIRS += plugins/BBANDS ! SUBDIRS += plugins/BOP SUBDIRS += plugins/CompareValues ! SUBDIRS += plugins/CCI ! SUBDIRS += plugins/CDL ! SUBDIRS += plugins/CMO SUBDIRS += plugins/CSV SUBDIRS += plugins/CurveBar --- 102,117 ---- # compile plugins ! #SUBDIRS += plugins/AD ! #SUBDIRS += plugins/ADX ! #SUBDIRS += plugins/ADXR ! #SUBDIRS += plugins/Arithmetic ! #SUBDIRS += plugins/AROON ! #SUBDIRS += plugins/ATR ! #SUBDIRS += plugins/BBANDS ! #SUBDIRS += plugins/BOP SUBDIRS += plugins/CompareValues ! #SUBDIRS += plugins/CCI ! #SUBDIRS += plugins/CDL ! #SUBDIRS += plugins/CMO SUBDIRS += plugins/CSV SUBDIRS += plugins/CurveBar *************** *** 123,135 **** SUBDIRS += plugins/CurveOHLC SUBDIRS += plugins/DataBase ! SUBDIRS += plugins/FI SUBDIRS += plugins/Group ! SUBDIRS += plugins/HT SUBDIRS += plugins/Indicator SUBDIRS += plugins/IndicatorPlot ! SUBDIRS += plugins/LINEARREG SUBDIRS += plugins/MA ! SUBDIRS += plugins/MACD ! SUBDIRS += plugins/MAMA SUBDIRS += plugins/MarkerBuy SUBDIRS += plugins/MarkerHLine --- 123,135 ---- SUBDIRS += plugins/CurveOHLC SUBDIRS += plugins/DataBase ! #SUBDIRS += plugins/FI SUBDIRS += plugins/Group ! #SUBDIRS += plugins/HT SUBDIRS += plugins/Indicator SUBDIRS += plugins/IndicatorPlot ! #SUBDIRS += plugins/LINEARREG SUBDIRS += plugins/MA ! #SUBDIRS += plugins/MACD ! #SUBDIRS += plugins/MAMA SUBDIRS += plugins/MarkerBuy SUBDIRS += plugins/MarkerHLine *************** *** 139,167 **** SUBDIRS += plugins/MarkerTLine SUBDIRS += plugins/MarkerVLine ! SUBDIRS += plugins/MDI ! SUBDIRS += plugins/MFI ! SUBDIRS += plugins/MOM ! SUBDIRS += plugins/PDI ! SUBDIRS += plugins/PHASOR SUBDIRS += plugins/Plot ! SUBDIRS += plugins/ROC ! SUBDIRS += plugins/RSI ! SUBDIRS += plugins/SAR ! SUBDIRS += plugins/SINE ! SUBDIRS += plugins/STDDEV ! SUBDIRS += plugins/STOCHF ! SUBDIRS += plugins/STOCHRSI ! SUBDIRS += plugins/STOCHS ! SUBDIRS += plugins/SZ SUBDIRS += plugins/Symbol ! SUBDIRS += plugins/T3 ! SUBDIRS += plugins/TRIX ! SUBDIRS += plugins/ULTOSC ! SUBDIRS += plugins/VAR SUBDIRS += plugins/ValuesDialog ! SUBDIRS += plugins/WILLR SUBDIRS += plugins/YahooHistory # install docs and i18n ! SUBDIRS += docs --- 139,167 ---- SUBDIRS += plugins/MarkerTLine SUBDIRS += plugins/MarkerVLine ! #SUBDIRS += plugins/MDI ! #SUBDIRS += plugins/MFI ! #SUBDIRS += plugins/MOM ! #SUBDIRS += plugins/PDI ! #SUBDIRS += plugins/PHASOR SUBDIRS += plugins/Plot ! #SUBDIRS += plugins/ROC ! #SUBDIRS += plugins/RSI ! #SUBDIRS += plugins/SAR ! #SUBDIRS += plugins/SINE ! #SUBDIRS += plugins/STDDEV ! #SUBDIRS += plugins/STOCHF ! #SUBDIRS += plugins/STOCHRSI ! #SUBDIRS += plugins/STOCHS ! #SUBDIRS += plugins/SZ SUBDIRS += plugins/Symbol ! #SUBDIRS += plugins/T3 ! #SUBDIRS += plugins/TRIX ! #SUBDIRS += plugins/ULTOSC ! #SUBDIRS += plugins/VAR SUBDIRS += plugins/ValuesDialog ! #SUBDIRS += plugins/WILLR SUBDIRS += plugins/YahooHistory # install docs and i18n ! #SUBDIRS += docs |
From: Steve S. <sst...@us...> - 2013-02-20 00:24:52
|
Update of /cvsroot/qtstalker/qtstalker/i18n In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv1437/qtstalker/i18n Modified Files: qtstalker_xx.ts Log Message: Index: qtstalker_xx.ts =================================================================== RCS file: /cvsroot/qtstalker/qtstalker/i18n/qtstalker_xx.ts,v retrieving revision 1.122 retrieving revision 1.123 diff -C2 -d -r1.122 -r1.123 *** qtstalker_xx.ts 19 Feb 2013 00:26:34 -0000 1.122 --- qtstalker_xx.ts 20 Feb 2013 00:24:50 -0000 1.123 *************** *** 842,857 **** </message> <message> ! <source>Continue Cancel</source> ! <translation type="unfinished"></translation> ! </message> ! </context> ! <context> ! <name>DockWidget</name> ! <message> ! <source>&Lock</source> ! <translation type="unfinished"></translation> ! </message> ! <message> ! <source>&Unlock</source> <translation type="unfinished"></translation> </message> --- 842,846 ---- </message> <message> ! <source>Are you sure you want to discard changes ?</source> <translation type="unfinished"></translation> </message> *************** *** 1087,1090 **** --- 1076,1083 ---- <translation type="unfinished"></translation> </message> + <message> + <source>Tab Row</source> + <translation type="unfinished"></translation> + </message> </context> <context> *************** *** 1806,1825 **** </message> <message> - <source>&Edit</source> - <translation type="unfinished"></translation> - </message> - <message> - <source>Edit Plot</source> - <translation type="unfinished"></translation> - </message> - <message> - <source>&Delete</source> - <translation type="unfinished"></translation> - </message> - <message> - <source>Delete Plot</source> - <translation type="unfinished"></translation> - </message> - <message> <source>&X Grid</source> <translation type="unfinished"></translation> --- 1799,1802 ---- *************** *** 1853,1860 **** <translation type="unfinished"></translation> </message> - <message> - <source>Remove</source> - <translation type="unfinished"></translation> - </message> </context> <context> --- 1830,1833 ---- *************** *** 2334,2378 **** </message> <message> ! <source>Perform search</source> <translation type="unfinished"></translation> </message> <message> ! <source>Search</source> <translation type="unfinished"></translation> </message> <message> ! <source>Search Results</source> <translation type="unfinished"></translation> </message> <message> ! <source>Symbol</source> <translation type="unfinished"></translation> </message> <message> ! <source>Name</source> <translation type="unfinished"></translation> </message> <message> ! <source>Add selected to symbols</source> <translation type="unfinished"></translation> </message> <message> ! <source>Remove selected from symbols</source> <translation type="unfinished"></translation> </message> <message> ! <source>Select all symbols</source> <translation type="unfinished"></translation> </message> <message> ! <source>Unselect all symbols</source> <translation type="unfinished"></translation> </message> <message> ! <source>Symbols</source> <translation type="unfinished"></translation> </message> <message> ! <source>Settings</source> <translation type="unfinished"></translation> </message> --- 2307,2359 ---- </message> <message> ! <source>Search Results</source> <translation type="unfinished"></translation> </message> <message> ! <source>Symbol</source> <translation type="unfinished"></translation> </message> <message> ! <source>Name</source> <translation type="unfinished"></translation> </message> <message> ! <source>Select all symbols</source> <translation type="unfinished"></translation> </message> <message> ! <source>Unselect all symbols</source> <translation type="unfinished"></translation> </message> <message> ! <source>Symbols</source> <translation type="unfinished"></translation> </message> <message> ! <source>Settings</source> <translation type="unfinished"></translation> </message> <message> ! <source>Select Symbols</source> <translation type="unfinished"></translation> </message> <message> ! <source>Add</source> <translation type="unfinished"></translation> </message> <message> ! <source>Add selected to symbol list</source> <translation type="unfinished"></translation> </message> <message> ! <source>Remove</source> ! <translation type="unfinished"></translation> ! </message> ! <message> ! <source>Remove selected from symbol list</source> ! <translation type="unfinished"></translation> ! </message> ! <message> ! <source>Perform Search</source> <translation type="unfinished"></translation> </message> *************** *** 2413,2416 **** --- 2394,2420 ---- </context> <context> + <name>TabBar</name> + <message> + <source>Edit Indicator</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Move Indicator</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Delete Indicator</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Move Indicator Row</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Row</source> + <translation type="unfinished"></translation> + </message> + </context> + <context> <name>ULTOSCDialog</name> <message> |
From: Steve S. <sst...@us...> - 2013-02-19 00:38:24
|
Update of /cvsroot/qtstalker/qtstalker/plugins/IndicatorPlot In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv2547/qtstalker/plugins/IndicatorPlot Added Files: AddIndicator.cpp AddIndicator.h EditIndicator.cpp EditIndicator.h TabBar.cpp TabBar.h TabWidget.cpp TabWidget.h Log Message: --- NEW FILE: AddIndicator.h --- /* * Qtstalker stock charter * * Copyright (C) 2001-2010 Stefan S. Stratigakos * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. */ #ifndef PLUGIN_INDICATOR_PLOT_ADD_INDICATOR_HPP #define PLUGIN_INDICATOR_PLOT_ADD_INDICATOR_HPP #include <QObject> #include <QString> class AddIndicator : public QObject { Q_OBJECT signals: void signalDone (QString, QString, int); public: AddIndicator (QString profile); ~AddIndicator (); void run (); public slots: void start (); void start2 (void *); void quit (); protected: QString _name; QString _profile; QString _path; int _row; }; #endif --- NEW FILE: TabWidget.cpp --- /* * Qtstalker stock charter * * Copyright (C) 2001-2010 Stefan S. Stratigakos * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. */ #include "TabWidget.h" #include "TabBar.h" #include <QtDebug> TabWidget::TabWidget (QWidget *parent, QString profile, int row) : QTabWidget (parent) { _profile = profile; _row = row; QTabBar* tb = new TabBar; connect(tb, SIGNAL(tabMoveRequested(int, int)), this, SLOT(moveTab(int, int))); connect(this, SIGNAL(currentChanged(int)), this, SLOT(tabChanged(int))); connect(tb, SIGNAL(signalMoveRow(QString, int, int)), this, SLOT(moveIndicator(QString, int, int))); connect(tb, SIGNAL(signalRemove(QString, int)), this, SLOT(removeIndicator(QString, int))); connect(tb, SIGNAL(signalEdit(QString)), this, SIGNAL(signalEditIndicator(QString))); setTabBar(tb); } void TabWidget::moveTab (int fromIndex, int toIndex) { QWidget *w = widget(fromIndex); QIcon icon = tabIcon(fromIndex); QString text = tabText(fromIndex); removeTab(fromIndex); insertTab(toIndex, w, icon, text); setCurrentIndex(toIndex); } void TabWidget::tabChanged (int index) { if (isVisible()) emit signalTabChanged(this, index); } void TabWidget::moveIndicator (QString name, int ocol, int nrow) { if (_row == nrow) return; // ignore move if old and new are the same emit signalMoveIndicator(name, _row, ocol, nrow); } void TabWidget::removeIndicator (QString name, int col) { emit signalRemoveIndicator(name, _row, col); } --- NEW FILE: TabWidget.h --- /* * Qtstalker stock charter * * Copyright (C) 2001-2010 Stefan S. Stratigakos * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. */ #ifndef PLUGIN_INDICATOR_PLOT_TAB_WIDGET_HPP #define PLUGIN_INDICATOR_PLOT_TAB_WIDGET_HPP #include <QtGui> class TabWidget : public QTabWidget { Q_OBJECT signals: void signalTabChanged (QTabWidget *, int); void signalEditIndicator (QString); void signalRemoveIndicator (QString, int, int); void signalMoveIndicator (QString, int, int, int); public: TabWidget (QWidget *parent, QString profile, int row); public slots: void moveTab (int fromIndex, int toIndex); void tabChanged (int index); void moveIndicator (QString, int ocol, int nrow); void removeIndicator (QString, int col); private: QString _profile; int _row; }; #endif --- NEW FILE: TabBar.cpp --- /* * Qtstalker stock charter * * Copyright (C) 2001-2010 Stefan S. Stratigakos * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. */ #include "TabBar.h" #include "../../pics/delete.xpm" #include "../../pics/insert.xpm" #include <QtDebug> TabBar::TabBar (QWidget *parent) : QTabBar(parent) { setAcceptDrops(true); _menu = new QMenu(this); _menu->addAction(QIcon(insert_xpm), tr("Edit Indicator"), this, SLOT(edit()), 0); _menu->addSeparator(); _menu->addAction(QIcon(insert_xpm), tr("Move Indicator"), this, SLOT(moveRow()), 0); _menu->addSeparator(); _menu->addAction(QIcon(delete_xpm), tr("Delete Indicator"), this, SLOT(remove()), 0); setContextMenuPolicy(Qt::CustomContextMenu); connect(this, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(contextMenu())); } void TabBar::mousePressEvent (QMouseEvent *event) { if (event->button() == Qt::LeftButton) m_dragStartPos = event->pos(); // m_dragStartPos is a QPoint defined in the header QTabBar::mousePressEvent(event); } void TabBar::mouseMoveEvent (QMouseEvent *event) { // If the left button isn't pressed anymore then return if (! (event->buttons() & Qt::LeftButton)) return; // If the distance is too small then return if ((event->pos() - m_dragStartPos).manhattanLength() < QApplication::startDragDistance()) return; // initiate Drag QDrag* drag = new QDrag(this); QMimeData *mimeData = new QMimeData; // a crude way to distinguish tab-reodering drops from other ones mimeData->setData("action", "tab-reordering"); drag->setMimeData(mimeData); drag->exec(); } void TabBar::dragEnterEvent (QDragEnterEvent *event) { // Only accept if it's an tab-reordering request const QMimeData *m = event->mimeData(); QStringList formats = m->formats(); if (formats.contains("action") && (m->data("action") == "tab-reordering")) event->acceptProposedAction(); } void TabBar::dropEvent (QDropEvent *event) { int fromIndex = tabAt(m_dragStartPos); int toIndex = tabAt(event->pos()); // Tell interested objects that if (fromIndex != toIndex) emit tabMoveRequested(fromIndex, toIndex); event->acceptProposedAction(); } void TabBar::remove () { QMessageBox msgBox; msgBox.setText("Remove Indicator."); msgBox.setInformativeText("Are you sure ?"); msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No); msgBox.setDefaultButton(QMessageBox::No); if (msgBox.exec() == QMessageBox::No) return; emit signalRemove(tabText(tabAt(_tabMenu)), tabAt(_tabMenu)); } void TabBar::contextMenu () { _tabMenu = mapFromGlobal(QCursor::pos()); _menu->exec(QCursor::pos()); } void TabBar::moveRow () { bool ok = FALSE; int row = QInputDialog::getInt(this, tr("Move Indicator Row"), tr("Row"), 1, 1, 10, 1, &ok, 0); if (! ok) return; emit signalMoveRow(tabText(tabAt(_tabMenu)), tabAt(_tabMenu), row); } void TabBar::edit () { emit signalEdit(tabText(tabAt(_tabMenu))); } --- NEW FILE: AddIndicator.cpp --- /* * Qtstalker stock charter * * Copyright (C) 2001-2010 Stefan S. Stratigakos * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. */ #include "AddIndicator.h" #include "Util.h" #include "IndicatorPlotDialog.h" #include <QtDebug> #include <QSettings> AddIndicator::AddIndicator (QString profile) { _profile = profile; _row = -1; QStringList tl; QDir dir(QDir::homePath()); tl << dir.absolutePath() << QString("OTA") << QString("IndicatorPlot") << QString("indicator"); _path = tl.join("/"); } AddIndicator::~AddIndicator () { } void AddIndicator::quit () { deleteLater(); } void AddIndicator::run () { QTimer::singleShot(10, this, SLOT(start())); } void AddIndicator::start () { IndicatorPlotDialog *dialog = new IndicatorPlotDialog; dialog->setIndicator(); dialog->setName(QString()); dialog->setRow(1); connect(dialog, SIGNAL(signalDone(void *)), this, SLOT(start2(void *))); dialog->setModified(FALSE); dialog->show(); } void AddIndicator::start2 (void *dialog) { IndicatorPlotDialog *d = (IndicatorPlotDialog *) dialog; _name = d->name(); _row = d->row(); QString file = d->indicator(); // copy from master indicator dir to profile directory QString ofile = _path + "/" + file; QStringList tl; QDir dir(QDir::homePath()); tl << dir.absolutePath() << QString("OTA") << QString("IndicatorPlot") << _profile << QString("indicator"); QString nfile = tl.join("/"); if (! dir.mkpath(nfile)) { qDebug() << "AddIndicator::start2: path create error" << nfile; quit(); return; } nfile.append("/" + _name); if (dir.exists(nfile)) { QMessageBox msgBox; msgBox.setText("Indicator already exists."); msgBox.setInformativeText("Overwrite existing indicator ?"); msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No); msgBox.setDefaultButton(QMessageBox::No); if (msgBox.exec() == QMessageBox::No) { quit(); return; } dir.remove(nfile); } if (! QFile::copy(ofile, nfile)) { qDebug() << "AddIndicator::indicatorObjectMessage: copy file error" << ofile << nfile; quit(); return; } emit signalDone(nfile, _name, _row); } --- NEW FILE: TabBar.h --- /* * Qtstalker stock charter * * Copyright (C) 2001-2010 Stefan S. Stratigakos * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. */ #ifndef PLUGIN_INDICATOR_PLOT_TAB_BAR_HPP #define PLUGIN_INDICATOR_PLOT_TAB_BAR_HPP #include <QtGui> class TabBar : public QTabBar { Q_OBJECT public: TabBar (QWidget * parent = 0); public slots: void remove (); void contextMenu (); void moveRow (); void edit (); protected: void mousePressEvent (QMouseEvent *event); void mouseMoveEvent (QMouseEvent *event); void dragEnterEvent (QDragEnterEvent *event); // void dragMoveEvent(QDragMoveEvent *event); void dropEvent (QDropEvent *event); private: QPoint m_dragStartPos; int m_dragCurrentIndex; QMenu *_menu; QPoint _tabMenu; signals: void tabMoveRequested(int fromIndex, int toIndex); void signalMoveRow(QString, int, int); void signalRemove(QString, int); void signalEdit(QString); }; #endif --- NEW FILE: EditIndicator.cpp --- /* * Qtstalker stock charter * * Copyright (C) 2001-2010 Stefan S. Stratigakos * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. */ #include "EditIndicator.h" #include "Util.h" #include "IndicatorPlotDialog.h" #include <QtDebug> EditIndicator::EditIndicator (bool flag) { _newFlag = flag; _indicator = 0; QStringList tl; QDir dir(QDir::homePath()); tl << dir.absolutePath() << QString("OTA") << QString("IndicatorPlot") << QString("indicator"); _path = tl.join("/"); } EditIndicator::~EditIndicator () { if (_indicator) delete _indicator; } void EditIndicator::quit () { deleteLater(); } void EditIndicator::run () { QTimer::singleShot(10, this, SLOT(start())); } void EditIndicator::start () { IndicatorPlotDialog *dialog = new IndicatorPlotDialog(); if (_newFlag) dialog->setName(QString()); else dialog->setIndicator(); connect(dialog, SIGNAL(signalDone(void *)), this, SLOT(start2(void *))); dialog->setModified(FALSE); dialog->show(); } void EditIndicator::start2 (void *dialog) { IndicatorPlotDialog *d = (IndicatorPlotDialog *) dialog; QString path = _path + "/"; if (_newFlag) // new path.append(d->name()); else path.append(d->indicator()); if (_newFlag) { QDir dir; if (dir.exists(path)) { QMessageBox msgBox; msgBox.setText("Indicator already exists."); msgBox.setInformativeText("Overwrite existing indicator ?"); msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No); msgBox.setDefaultButton(QMessageBox::No); if (msgBox.exec() == QMessageBox::No) { quit(); return; } dir.remove(path); } _name = d->name(); } Util util; _indicator = util.object(QString("Indicator"), _profile, _name); if (! _indicator) { qDebug() << "EditIndicator::start2: invalid Indicator object"; quit(); return; } ObjectCommand toc(QString("load")); toc.setValue(QString("file"), path); if (! _indicator->message(&toc)) { qDebug() << "EditIndicator::start2: message error" << _indicator->plugin() << toc.command(); quit(); return; } toc.setCommand(QString("dialog")); if (! _indicator->message(&toc)) { qDebug() << "EditIndicator::start2: message error" << _indicator->plugin() << toc.command(); quit(); return; } } --- NEW FILE: EditIndicator.h --- /* * Qtstalker stock charter * * Copyright (C) 2001-2010 Stefan S. Stratigakos * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. */ #ifndef PLUGIN_INDICATOR_PLOT_EDIT_INDICATOR_HPP #define PLUGIN_INDICATOR_PLOT_EDIT_INDICATOR_HPP #include <QObject> #include <QString> #include "Object.h" class EditIndicator : public QObject { Q_OBJECT public: EditIndicator (bool); ~EditIndicator (); void run (); public slots: void start (); void start2 (void *); void quit (); void directoryChanged (); protected: Object *_indicator; QString _name; QString _profile; QString _path; bool _newFlag; }; #endif |
From: Steve S. <sst...@us...> - 2013-02-19 00:36:22
|
Update of /cvsroot/qtstalker/qtstalker/plugins/IndicatorPlot In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv2185/qtstalker/plugins/IndicatorPlot Modified Files: .cvsignore Log Message: Index: .cvsignore =================================================================== RCS file: /cvsroot/qtstalker/qtstalker/plugins/IndicatorPlot/.cvsignore,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** .cvsignore 15 Feb 2013 04:01:47 -0000 1.1 --- .cvsignore 19 Feb 2013 00:35:50 -0000 1.2 *************** *** 1,2 **** --- 1,5 ---- + build Makefile moc_*.cpp + *.so + *~ |
From: Steve S. <sst...@us...> - 2013-02-19 00:36:21
|
Update of /cvsroot/qtstalker/qtstalker/plugins/BBANDS In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv2185/qtstalker/plugins/BBANDS Modified Files: .cvsignore Log Message: Index: .cvsignore =================================================================== RCS file: /cvsroot/qtstalker/qtstalker/plugins/BBANDS/.cvsignore,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** .cvsignore 25 Jun 2012 22:28:00 -0000 1.1 --- .cvsignore 19 Feb 2013 00:35:48 -0000 1.2 *************** *** 1,2 **** --- 1,5 ---- + build Makefile moc_*.cpp + *.so + *~ |
From: Steve S. <sst...@us...> - 2013-02-19 00:35:55
|
Update of /cvsroot/qtstalker/qtstalker/plugins/VAR In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv2185/qtstalker/plugins/VAR Modified Files: .cvsignore Log Message: Index: .cvsignore =================================================================== RCS file: /cvsroot/qtstalker/qtstalker/plugins/VAR/.cvsignore,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** .cvsignore 15 Feb 2013 04:48:55 -0000 1.1 --- .cvsignore 19 Feb 2013 00:35:52 -0000 1.2 *************** *** 1,2 **** --- 1,5 ---- + build Makefile moc_*.cpp + *.so + *~ |
From: Steve S. <sst...@us...> - 2013-02-19 00:35:54
|
Update of /cvsroot/qtstalker/qtstalker/plugins/RSI In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv2185/qtstalker/plugins/RSI Modified Files: .cvsignore Log Message: Index: .cvsignore =================================================================== RCS file: /cvsroot/qtstalker/qtstalker/plugins/RSI/.cvsignore,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** .cvsignore 25 Jun 2012 22:28:03 -0000 1.1 --- .cvsignore 19 Feb 2013 00:35:51 -0000 1.2 *************** *** 1,2 **** --- 1,5 ---- + build Makefile moc_*.cpp + *.so + *~ |
From: Steve S. <sst...@us...> - 2013-02-19 00:35:53
|
Update of /cvsroot/qtstalker/qtstalker/plugins/MarkerRetracement In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv2185/qtstalker/plugins/MarkerRetracement Modified Files: .cvsignore Log Message: Index: .cvsignore =================================================================== RCS file: /cvsroot/qtstalker/qtstalker/plugins/MarkerRetracement/.cvsignore,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** .cvsignore 25 Jun 2012 22:28:02 -0000 1.1 --- .cvsignore 19 Feb 2013 00:35:51 -0000 1.2 *************** *** 1,2 **** --- 1,5 ---- + build Makefile moc_*.cpp + *.so + *~ |
From: Steve S. <sst...@us...> - 2013-02-19 00:29:00
|
Update of /cvsroot/qtstalker/qtstalker/src In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv1800/qtstalker/src Modified Files: .cvsignore Log Message: Index: .cvsignore =================================================================== RCS file: /cvsroot/qtstalker/qtstalker/src/.cvsignore,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** .cvsignore 19 Jun 2007 04:32:31 -0000 1.2 --- .cvsignore 19 Feb 2013 00:28:58 -0000 1.3 *************** *** 1,4 **** Makefile moc_* ! qtstalker ! qtstalker.app --- 1,4 ---- Makefile moc_* ! ota ! build |
From: Steve S. <sst...@us...> - 2013-02-19 00:26:36
|
Update of /cvsroot/qtstalker/qtstalker/docs In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv1639/qtstalker/docs Modified Files: CHANGELOG-0.37 docs.pro Log Message: Index: CHANGELOG-0.37 =================================================================== RCS file: /cvsroot/qtstalker/qtstalker/docs/CHANGELOG-0.37,v retrieving revision 1.225 retrieving revision 1.226 diff -C2 -d -r1.225 -r1.226 *** CHANGELOG-0.37 28 Jun 2012 02:12:31 -0000 1.225 --- CHANGELOG-0.37 19 Feb 2013 00:26:33 -0000 1.226 *************** *** 1,1387 **** ! 20080505: Bar length buttons and combobox were not synchronized. Applied patch #1957299. Thanks to rgf. ! ! 20080505: Add Preferences options to show buttons for 60-minute and 5-minute bar length. Applied patch #1908413. Thanks to rgf. ! ! 20080529: Chart object "FiboLine" now shows all line values as they are being added. Applied patch #1965845. Thanks to blshkv. ! ! 20080708: Improved parsing of comma-separated values for CSV and Yahoo plugins. If there is a "Name" field, then it can now contain commas. Applied patch #2010375. Thanks to blshkv. ! ! 20090909: Completed qt4 port. ! Removed Scanner and Backtesting functions. Perhaps redo in future. [...1441 lines suppressed...] ! into the OTA home directory. This removes DLL hell and makes removal/copying simple. ! The directory structure currently is: ! bin/ - executables (the ota binary is here) ! lib/ - plugins ! docs/ - docs ! */ - each plugin gets its own sub directory to store all its data ! If you delete a plugin sub directory you delete everything associated with it. ie. YahooHistory ! directory contains all your yahoo quotes! Be warned. ! Everything with the exception of quote data is stored in text files for simplicity. ! Index: docs.pro =================================================================== RCS file: /cvsroot/qtstalker/qtstalker/docs/docs.pro,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** docs.pro 31 Jan 2012 01:00:59 -0000 1.27 --- docs.pro 19 Feb 2013 00:26:33 -0000 1.28 *************** *** 3,67 **** CONFIG += thread ! # install the example indicator html files and pics ! idocs.path = "$${INSTALL_DOCS_DIR}/qtstalker/html/indicator" ! idocs.files = indicator/*.html ! idocs.files += indicator/*.png ! INSTALLS += idocs ! ! # install the past CHANGELOG files ! pcl.path = "$${INSTALL_DOCS_DIR}/qtstalker/html/pastchanges" ! pcl.files = pastchanges/*.html ! pcl.files += pastchanges/CHANGELOG* ! INSTALLS += pcl ! ! # install the html files and pics ! docs.path = "$${INSTALL_DOCS_DIR}/qtstalker/html" ! docs.files = *.html *.png CHANGELOG* ! docs.files += doc.qhc doc.qch doc-doxygen.qch ! INSTALLS += docs # install the license file ! lic.path = "$${INSTALL_DOCS_DIR}/qtstalker" lic.files = COPYING INSTALLS += lic # install the translation files ! i18n.path = "$${INSTALL_DATA_DIR}/qtstalker/i18n" i18n.files = ../i18n/*.qm INSTALLS += i18n - # install the db update files - #dbUpdate.path = "$${INSTALL_DATA_DIR}/qtstalker/db" - #dbUpdate.files = *.csv - #dbUpdate.files += default_indicators - #INSTALLS += dbUpdate - - # install the alert script files - #alert.path = "$${INSTALL_DATA_DIR}/qtstalker/alert" - #alert.files = ../Scripts/alert/*.pl - #INSTALLS += alert - - # install the indicator script files - indicator.path = "$${INSTALL_DATA_DIR}/qtstalker/indicator" - indicator.files = ../Scripts/indicator/*.pl - INSTALLS += indicator - - # install the quote script files - quote.path = "$${INSTALL_DATA_DIR}/qtstalker/quote" - quote.files = ../Scripts/quote/*.pl - INSTALLS += quote - - # install the scanner script files - #scanner.path = "$${INSTALL_DATA_DIR}/qtstalker/scanner" - #scanner.files = ../Scripts/scanner/*.pl - #INSTALLS += scanner - - # install the system script files - system.path = "$${INSTALL_DATA_DIR}/qtstalker/system" - system.files = ../Scripts/system/*.pl - INSTALLS += system - - # install the test script files - #tester.path = "$${INSTALL_DATA_DIR}/qtstalker/test" - #tester.files = ../Scripts/test/*.pl - #INSTALLS += tester --- 3,16 ---- CONFIG += thread ! HOME=$$system(echo $HOME) # install the license file ! lic.path = $${HOME}/OTA/docs/LICENSE lic.files = COPYING INSTALLS += lic # install the translation files ! i18n.path = $${HOME}/OTA/docs/i18n i18n.files = ../i18n/*.qm INSTALLS += i18n |
From: Steve S. <sst...@us...> - 2013-02-19 00:26:08
|
Update of /cvsroot/qtstalker/qtstalker/plugins/IndicatorPlot/examples In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv1603/examples Log Message: Directory /cvsroot/qtstalker/qtstalker/plugins/IndicatorPlot/examples added to the repository |
From: Steve S. <sst...@us...> - 2013-02-15 05:45:07
|
Update of /cvsroot/qtstalker/qtstalker/pics In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv13702/qtstalker/pics Added Files: download.xpm Log Message: --- NEW FILE: download.xpm --- /* XPM */ static const char * download_xpm[] = { "16 16 147 2", " c None", ". c #454F9A", "+ c #4D569E", "@ c #44509B", "# c #364394", "$ c #363F90", "% c #8791C2", "& c #909DC9", "* c #4E5FA5", "= c #6A80BC", "- c #47559E", "; c #768DC3", "> c #323F91", ", c #283189", "' c #7C84B8", ") c #B8C9E5", "! c #AFC6E4", "~ c #6281BD", "{ c #7695C9", "] c #4D66AA", "^ c #465DA5", "/ c #99AED7", "( c #2A358C", "_ c #6169AB", ": c #98A6CE", "< c #CDE1F4", "[ c #9ABBE1", "} c #8CB2DD", "| c #456DB1", "1 c #3159A4", "2 c #1C4195", "3 c #5E7BB8", "4 c #40509D", "5 c #12197E", "6 c #6371AE", "7 c #ABC0E0", "8 c #BED9F3", "9 c #B3D5F2", "0 c #74A0D1", "a c #235FAA", "b c #245BA7", "c c #20509F", "d c #5175B6", "e c #A4BEE0", "f c #2A338F", "g c #1F2786", "h c #1D378F", "i c #8DAAD4", "j c #8EB2DA", "k c #98BCE0", "l c #77A4D0", "m c #4C88C2", "n c #286BB2", "o c #245DA9", "p c #5D85C0", "q c #B8CFEA", "r c #303B94", "s c #1F2687", "t c #1C3A90", "u c #4B74B4", "v c #8EB5DD", "w c #619DCE", "x c #3989C6", "y c #3385C4", "z c #2B79BC", "A c #2669B2", "B c #648CC2", "C c #C0CEE6", "D c #9C9EC9", "E c #151A82", "F c #233E94", "G c #3566AD", "H c #3E82C0", "I c #5FA5D7", "J c #7DBBE4", "K c #3B97D0", "L c #2D85C5", "M c #2B74B9", "N c #89A5CE", "O c #3562AB", "P c #1E53A2", "Q c #194E9E", "R c #2455A0", "S c #182B8B", "T c #2758A5", "U c #4A8CC5", "V c #9CCDED", "W c #B8E1F8", "X c #B8E0FA", "Y c #7EBDE3", "Z c #4486C1", "` c #85A1CB", " . c #1B4A93", ".. c #A5C0CF", "+. c #A8C4D3", "@. c #154287", "#. c #101582", "$. c #264EA0", "%. c #2770B6", "&. c #64AEDA", "*. c #C4E8FD", "=. c #CCEAFC", "-. c #BCDEF5", ";. c #77A4D2", ">. c #849ACD", ",. c #174081", "'. c #7B97B1", "). c #7F9BB3", "!. c #113874", "~. c #1C2088", "{. c #375CAB", "]. c #579DD1", "^. c #D5F3FE", "/. c #BBE5F8", "(. c #ABCDE9", "_. c #466DA0", ":. c #1B3E75", "<. c #0D3168", "[. c #5E7A97", "}. c #607D9A", "|. c #072656", "1. c #10305F", "2. c #102F5C", "3. c #071384", "4. c #213396", "5. c #0E2891", "6. c #676FB6", "7. c #2C4579", "8. c #1D3B68", "9. c #49678D", "0. c #55759F", "a. c #44638D", "b. c #163157", "c. c #0A254C", "d. c #325283", "e. c #6389BF", "f. c #678CC2", "g. c #3A5A8A", "h. c #041836", "i. c #031126", "j. c #7C9FD2", "k. c #85A8DB", "l. c #051024", "m. c #172234", "n. c #182434", "o. c #041022", "p. c #040F21", " . + @ # ", " $ % & * = - ; > ", " , ' ) ! ~ { ] ^ / ( ", " _ : < [ } | 1 2 3 4 ", "5 6 7 8 9 0 a b c d e f ", "g h i j k l m n o p q r ", "s t u v w x y z A B C D ", "E F G H I J K L M N O P Q R ", " S T U V W X Y Z ` ...+.@. ", " #.$.%.&.*.=.-.;.>.,.'.).!. ", " ~.{.].^./.(._.:.<.[.}.|.1.2.", " 3.4.5.6.7.8.9.0.0.a.b. ", " c.d.e.f.g.h. ", " i.j.k.l. ", " m.n. ", " o.p. "}; |
From: Steve S. <sst...@us...> - 2013-02-15 05:15:53
|
Update of /cvsroot/qtstalker/qtstalker/pics In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv12468/qtstalker/pics Added Files: trend.xpm Log Message: --- NEW FILE: trend.xpm --- /* XPM */ static const char *trend_xpm[]={ "16 16 2 1", ". c None", "# c #303030", "...#............", "....#...........", ".....#..........", "......#.........", ".......#.......#", "........#.....#.", ".........#...#..", "..........#.#...", "...........#....", "..........#.#...", ".........#...#..", "........#.....#.", ".......#.......#", "......#.........", ".....#..........", "....#..........."}; |
From: Steve S. <sst...@us...> - 2013-02-15 05:04:48
|
Update of /cvsroot/qtstalker/qtstalker/pics In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv11487/qtstalker/pics Added Files: stop.xpm Log Message: --- NEW FILE: stop.xpm --- /* XPM */ static const char *stop_xpm[]={ "24 24 129 2", "Qt c None", ".t c #000000", "#M c #5c2920", ".e c #5e2921", ".f c #5e2a21", ".s c #66342c", ".d c #682720", ".c c #73241f", ".b c #7d221e", ".a c #881f1d", ".k c #89605f", "#X c #901616", "#7 c #901717", ".Z c #911a1a", ".# c #921c1c", ".g c #931d1d", "#L c #a00e0b", "#C c #a1100d", ".6 c #a1110e", "#c c #a1120f", ".Q c #adadad", "#O c #b04e44", ".N c #b30f0f", ".Y c #b41212", ".r c #b4594f", ".C c #b51515", "#8 c #b51717", "#K c #bc140f", "#W c #bc1510", "#B c #bc1611", ".5 c #bd1813", "#b c #bd1914", "#6 c #c03122", "#J c #c03223", "#5 c #c21a1a", ".X c #c23728", "#x c #c25951", "#4 c #c44032", ".M c #c54d44", ".K c #c5655d", "a. c #c63935", "#o c #c65148", "#A c #c72e2e", "#9 c #c73c38", ".4 c #c7564a", "#N c #c77d7d", "#u c #c83939", "#V c #c84a3d", "#z c #c94f42", "#Y c #c95656", "#t c #c95a52", "#w c #c97068", "#F c #c9726a", "#a c #ca5b53", "#E c #ca6865", "#h c #cb5f57", "#I c #cb6258", "#g c #cb6259", "#3 c #cc4848", ".L c #cc5d5d", ".A c #cc5f59", "#P c #cc6262", "#n c #cc675d", "#v c #cc716e", "#U c #cd5e52", "#2 c #cd6055", ".B c #cd6060", "#Z c #cd6155", "#G c #cd665f", "#H c #cd695e", "#T c #cd6962", "#0 c #cf6359", "#Q c #cf6459", "#1 c #cf685d", "#m c #cf6f65", "#s c #cf6f66", "#R c #cf6f67", ".V c #cf736b", ".U c #cf7b76", ".j c #cfbfbf", "#S c #d07169", "## c #d07267", "#q c #d07871", ".z c #d1706a", ".y c #d1716a", "#f c #d17469", ".W c #d1746b", ".P c #d1776f", "#l c #d17771", "#y c #d17872", ".q c #d17e7e", ".x c #d2736a", "#r c #d37066", ".9 c #d4766e", "#j c #d47b74", ".J c #d5786f", ".O c #d57973", ".E c #d57976", "#d c #d57e77", ".3 c #d58681", ".w c #d67a72", "#k c #d77b74", ".I c #d77c74", "#p c #d7837b", ".p c #d88787", ".H c #d97f79", "#e c #d9807a", ".7 c #d98884", ".v c #dc7d77", ".G c #dc827c", ".o c #dc928b", ".T c #dd8782", ".h c #dd8b8b", ".D c #dd9089", "#i c #dd938c", ".8 c #de847e", ".F c #df817d", ".1 c #e0817d", ".S c #e08b86", ".n c #e0968f", "#D c #e0d0d0", ".0 c #e1837e", ".2 c #e69490", ".R c #e7928c", ".m c #e79d95", ".u c #e99f97", ".i c #f8e8e8", "#. c #fdf9f9", ".l c #ffffff", "QtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQt", "QtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQt", "QtQtQtQtQtQtQt.#.a.b.c.d.e.f.f.fQtQtQtQtQtQtQtQt", "QtQtQtQtQtQt.g.h.i.i.i.i.i.i.j.k.fQtQtQtQtQtQtQt", "QtQtQtQtQt.g.h.l.m.m.n.o.o.p.q.r.s.tQtQtQtQtQtQt", "QtQtQtQt.g.h.l.u.v.w.x.y.z.A.B.C.g.f.tQtQtQtQtQt", "QtQtQt.g.h.l.D.E.F.G.H.I.J.K.L.M.N.#.f.tQtQtQtQt", "QtQt.#.h.l.u.O.P.Q.R.S.T.U.V.Q.W.X.Y.Z.f.tQtQtQt", "QtQt.#.i.m.0.1.Q.l.l.2.3.V.Q.l.l.4.5.6.f.tQtQtQt", "QtQt.#.i.m.7.8.R.l.l.l.9.Q#..l###a#b#c.f.tQtQtQt", "QtQt.a.i.n#d#e.S.2.l.l.l.l.l#f#g#h#b#c.f.tQtQtQt", "QtQt.b.i#i#j#k.T.3.9.l.l.l#l#m#n#o#b#c.f.tQtQtQt", "QtQt.c.i#p#q#r.U.V.Q.l.l.l.l#s#t#u#b.6.f.tQtQtQt", "QtQt.d.i#v#w#x.V.Q#..l#y.l.l.l#z#A#B#C.f.tQtQtQt", "QtQt.f#D#E#F#G.Q.l.l#f#H#I.l.l.l#J#K#L.f.tQtQtQt", "QtQt#M#N#O#P#Q#G.l#R#S#T#U#V.l#b#W#C#X.f.tQtQtQt", "QtQtQt.f.f.g#Y#Z#0#1#2#3#4#5#6#W#C#7.f.tQtQtQtQt", "QtQtQtQt.t.f.##8#9a.a.a..5#B#K#C#7.f.tQtQtQtQtQt", "QtQtQtQtQt.t.f.Z.6#c#c#c.6#C#L#X.f.tQtQtQtQtQtQt", "QtQtQtQtQtQt.t.f.f.f.f.f.f.f.f.f.tQtQtQtQtQtQtQt", "QtQtQtQtQtQtQt.t.t.t.t.t.t.t.t.tQtQtQtQtQtQtQtQt", "QtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQt", "QtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQt", "QtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQt"}; |
Update of /cvsroot/qtstalker/qtstalker/plugins/WILLR In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv10101/qtstalker/plugins/WILLR Added Files: .cvsignore WILLR.cpp WILLR.h WILLR.pro WILLRDialog.cpp WILLRDialog.h WILLRObject.cpp WILLRObject.h Log Message: --- NEW FILE: .cvsignore --- Makefile moc_*.cpp --- NEW FILE: WILLRObject.cpp --- /* * Qtstalker stock charter * * Copyright (C) 2001-2010 Stefan S. Stratigakos * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. */ #include "WILLRObject.h" #include "ta_libc.h" #include "WILLRDialog.h" #include "Util.h" #include <QtDebug> WILLRObject::WILLRObject (QString profile, QString name) { TA_RetCode rc = TA_Initialize(); if (rc != TA_SUCCESS) qDebug() << "WILLRObject::WILLRObject: error on TA_Initialize"; _profile = profile; _name = name; _plugin = QString("WILLR"); _type = QString("indicator"); _period = 10; _outputKey = QString("v"); _hasOutput = TRUE; _inputObject = QString("symbol"); _highKey = QString("H"); _lowKey = QString("L"); _closeKey = QString("C"); _commandList << QString("update"); _commandList << QString("dialog"); _commandList << QString("output"); _commandList << QString("load"); _commandList << QString("save"); _commandList << QString("output_keys"); } WILLRObject::~WILLRObject () { clear(); } void WILLRObject::clear () { qDeleteAll(_bars); _bars.clear(); } int WILLRObject::message (ObjectCommand *oc) { int rc = 0; switch (_commandList.indexOf(oc->command())) { case 0: rc = update(oc); break; case 1: rc = dialog(oc); break; case 2: rc = output(oc); break; case 3: rc = load(oc); break; case 4: rc = save(oc); break; case 5: rc = outputKeys(oc); break; default: break; } return rc; } int WILLRObject::update (ObjectCommand *oc) { clear(); // input object Object *io = (Object *) oc->getObject(_inputObject); if (! io) { qDebug() << "WILLRObject::update: invalid input" << _inputObject; return 0; } // get input bars ObjectCommand toc(QString("output")); if (! io->message(&toc)) { qDebug() << "WILLRObject::update: message error" << io->plugin() << toc.command(); return 0; } QMap<int, Data *> data = toc.map(); int size = data.size(); TA_Real high[size]; TA_Real low[size]; TA_Real close[size]; TA_Real out[size]; TA_Integer outBeg; TA_Integer outNb; int dpos = 0; QMapIterator<int, Data *> it(data); while (it.hasNext()) { it.next(); Data *d = it.value(); if (! d->contains(_highKey)) continue; if (! d->contains(_lowKey)) continue; if (! d->contains(_closeKey)) continue; high[dpos] = (TA_Real) d->value(_highKey).toDouble(); low[dpos] = (TA_Real) d->value(_lowKey).toDouble(); close[dpos++] = (TA_Real) d->value(_closeKey).toDouble(); } TA_RetCode rc = TA_WILLR(0, dpos - 1, &high[0], &low[0], &close[0], _period, &outBeg, &outNb, &out[0]); if (rc != TA_SUCCESS) { qDebug() << "WILLRObject::update: TA-Lib error" << rc; return 0; } int outLoop = outNb - 1; it.toBack(); while (it.hasPrevious() && outLoop > -1) { it.previous(); Data *b = new Data; b->insert(_outputKey, out[outLoop--]); _bars.insert(it.key(), b); } return 1; } int WILLRObject::dialog (ObjectCommand *oc) { WILLRDialog *dialog = new WILLRDialog(oc->getObjects(), _name); dialog->setSettings(_inputObject, _highKey, _lowKey, _closeKey, _period); connect(dialog, SIGNAL(signalDone(void *)), this, SLOT(dialogDone(void *))); dialog->setModified(FALSE); dialog->show(); return 1; } void WILLRObject::dialogDone (void *dialog) { WILLRDialog *d = (WILLRDialog *) dialog; d->settings(_inputObject, _highKey, _lowKey, _closeKey, _period); ObjectCommand oc(QString("modified")); emit signalMessage(oc); } int WILLRObject::outputKeys (ObjectCommand *oc) { QStringList keys; keys << _outputKey; oc->setValue(QString("output_keys"), keys); return 1; } int WILLRObject::output (ObjectCommand *oc) { outputKeys(oc); oc->setMap(_bars); return 1; } int WILLRObject::load (ObjectCommand *oc) { QSettings *settings = (QSettings *) oc->getObject(QString("QSettings")); if (! settings) { qDebug() << "WILLRObject::load: invalid QSettings"; return 0; } _inputObject = settings->value(QString("input_object")).toString(); _highKey = settings->value(QString("high_key")).toString(); _lowKey = settings->value(QString("low_key")).toString(); _closeKey = settings->value(QString("close_key")).toString(); _period = settings->value(QString("period")).toInt(); return 1; } int WILLRObject::save (ObjectCommand *oc) { QSettings *settings = (QSettings *) oc->getObject(QString("QSettings")); if (! settings) { qDebug() << "WILLRObject::save: invalid QSettings"; return 0; } settings->setValue(QString("plugin"), _plugin); settings->setValue(QString("input_object"), _inputObject); settings->setValue(QString("high_key"), _highKey); settings->setValue(QString("low_key"), _lowKey); settings->setValue(QString("close_key"), _closeKey); settings->setValue(QString("period"), _period); return 1; } --- NEW FILE: WILLR.h --- /* * Qtstalker stock charter * * Copyright (C) 2001-2007 Stefan S. Stratigakos * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. */ #ifndef PLUGIN_WILLR_H #define PLUGIN_WILLR_H #include "Plugin.h" class WILLR : public QObject, public Plugin { Q_OBJECT Q_INTERFACES(Plugin) public: WILLR (); int command (PluginCommand *); protected: QStringList _commandList; }; #endif --- NEW FILE: WILLR.cpp --- /* * Qtstalker stock charter * * Copyright (C) 2001-2007 Stefan S. Stratigakos * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. */ #include "WILLR.h" #include "WILLRObject.h" WILLR::WILLR () { _commandList << QString("type"); _commandList << QString("object"); } int WILLR::command (PluginCommand *pc) { int rc = 0; switch (_commandList.indexOf(pc->command)) { case 0: // type pc->type = QString("indicator"); rc = 1; break; case 1: // object pc->object = new WILLRObject(pc->profile, pc->name); rc = 1; break; default: break; } return rc; } // do not remove Q_EXPORT_PLUGIN2(WILLR, WILLR); --- NEW FILE: WILLRDialog.cpp --- /* * Qtstalker stock charter * * Copyright (C) 2001-2010 Stefan S. Stratigakos * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. */ #include "WILLRDialog.h" #include "Util.h" WILLRDialog::WILLRDialog (QHash<QString, void *> objects, QString name) : Dialog (0, name) { QStringList tl; QDir dir(QDir::homePath()); tl << dir.absolutePath() << QString("OTA") << QString("WILLR") << QString("settings") << QString("dialog"); _settingsPath = tl.join("/"); createTab(objects); loadSettings(); } WILLRDialog::~WILLRDialog () { saveSettings(); } void WILLRDialog::createTab (QHash<QString, void *> l) { QHash<QString, void *> ol; QHashIterator<QString, void *> it(l); while (it.hasNext()) { it.next(); Object *o = (Object *) it.value(); if (o->hasOutput()) ol.insert(it.key(), it.value()); } QWidget *w = new QWidget; QFormLayout *form = new QFormLayout; form->setSpacing(2); form->setMargin(10); w->setLayout(form); _input = new InputObjectWidget; _input->setObjects(ol); connect(_input, SIGNAL(valueChanged()), this, SLOT(modified())); form->addRow(tr("Input"), _input); // period _period = new QSpinBox; _period->setRange(1, 999999); connect(_period, SIGNAL(valueChanged(int)), this, SLOT(modified())); form->addRow(tr("Period"), _period); _tabs->addTab(w, tr("Settings")); } void WILLRDialog::done () { emit signalDone((void *) this); Dialog::done(); } void WILLRDialog::loadSettings () { QSettings settings(_settingsPath, QSettings::NativeFormat); Dialog::loadSettings(settings); } void WILLRDialog::saveSettings() { QSettings settings(_settingsPath, QSettings::NativeFormat); Dialog::saveSettings(settings); } void WILLRDialog::setSettings (QString i, QString hk, QString lk, QString ck, int p) { _input->setInput(i); _input->setKey(tr("High"), hk); _input->setKey(tr("Low"), lk); _input->setKey(tr("Close"), ck); _period->setValue(p); } void WILLRDialog::settings (QString &i, QString &hk, QString &lk, QString &ck, int &p) { i = _input->input(); hk = _input->key(tr("High")); lk = _input->key(tr("Low")); ck = _input->key(tr("Close")); p = _period->value(); } --- NEW FILE: WILLR.pro --- TEMPLATE = lib CONFIG += plugin MOC_DIR += build OBJECTS_DIR += build INCLUDEPATH += ../../src HEADERS += WILLR.h SOURCES += WILLR.cpp HEADERS += WILLRObject.h SOURCES += WILLRObject.cpp HEADERS += WILLRDialog.h SOURCES += WILLRDialog.cpp HEADERS += ../../src/Object.h SOURCES += ../../src/Object.cpp HEADERS += ../../src/Util.h SOURCES += ../../src/Util.cpp HEADERS += ../../src/Plugin.h HEADERS += ../../src/PluginCommand.h HEADERS += ../../src/ObjectCommand.h SOURCES += ../../src/ObjectCommand.cpp SOURCES += ../../src/Dialog.cpp HEADERS += ../../src/Dialog.h SOURCES += ../../src/InputObjectWidget.cpp HEADERS += ../../src/InputObjectWidget.h HOME=$$system(echo $HOME) target.path = $${HOME}/OTA/lib INSTALLS += target QT += core QT += gui --- NEW FILE: WILLRObject.h --- /* * Qtstalker stock charter * * Copyright (C) 2001-2010 Stefan S. Stratigakos * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. */ #ifndef PLUGIN_WILLR_OBJECT_HPP #define PLUGIN_WILLR_OBJECT_HPP #include <QStringList> #include <QMap> #include "Object.h" #include "WILLRDialog.h" class WILLRObject : public Object { Q_OBJECT public: WILLRObject (QString profile, QString name); ~WILLRObject (); void clear (); int update (ObjectCommand *); int dialog (ObjectCommand *); int output (ObjectCommand *); int load (ObjectCommand *); int save (ObjectCommand *); int outputKeys (ObjectCommand *); public slots: int message (ObjectCommand *); void dialogDone (void *); private: QStringList _commandList; QMap<int, Data *> _bars; QString _inputObject; QString _highKey; QString _lowKey; QString _closeKey; QString _outputKey; int _period; }; #endif --- NEW FILE: WILLRDialog.h --- /* * Qtstalker stock charter * * Copyright (C) 2001-2010 Stefan S. Stratigakos * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. */ #ifndef PLUGIN_WILLR_DIALOG_HPP #define PLUGIN_WILLR_DIALOG_HPP #include <QtGui> #include "Dialog.h" #include "InputObjectWidget.h" class WILLRDialog : public Dialog { Q_OBJECT public: WILLRDialog (QHash<QString, void *> objects, QString name); ~WILLRDialog (); void createTab (QHash<QString, void *>); void setSettings(QString i, QString hk, QString lk, QString ck, int p); void settings(QString &i, QString &hk, QString &lk, QString &ck, int &p); public slots: void done (); void loadSettings (); void saveSettings (); protected: InputObjectWidget *_input; QSpinBox *_period; }; #endif |
Update of /cvsroot/qtstalker/qtstalker/plugins/ULTOSC In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv10101/qtstalker/plugins/ULTOSC Added Files: .cvsignore ULTOSC.cpp ULTOSC.h ULTOSC.pro ULTOSCDialog.cpp ULTOSCDialog.h ULTOSCObject.cpp ULTOSCObject.h Log Message: --- NEW FILE: .cvsignore --- Makefile moc_*.cpp --- NEW FILE: ULTOSCDialog.cpp --- /* * Qtstalker stock charter * * Copyright (C) 2001-2010 Stefan S. Stratigakos * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. */ #include "ULTOSCDialog.h" #include "Util.h" ULTOSCDialog::ULTOSCDialog (QHash<QString, void *> objects, QString name) : Dialog (0, name) { QStringList tl; QDir dir(QDir::homePath()); tl << dir.absolutePath() << QString("OTA") << QString("ULTOSC") << QString("settings") << QString("dialog"); _settingsPath = tl.join("/"); createTab(objects); loadSettings(); } ULTOSCDialog::~ULTOSCDialog () { saveSettings(); } void ULTOSCDialog::createTab (QHash<QString, void *> l) { QHash<QString, void *> ol; QHashIterator<QString, void *> it(l); while (it.hasNext()) { it.next(); Object *o = (Object *) it.value(); if (o->hasOutput()) ol.insert(it.key(), it.value()); } QWidget *w = new QWidget; QFormLayout *form = new QFormLayout; form->setSpacing(2); form->setMargin(10); w->setLayout(form); _input = new InputObjectWidget; _input->setObjects(ol); connect(_input, SIGNAL(valueChanged()), this, SLOT(modified())); form->addRow(tr("Input"), _input); // speriod _speriod = new QSpinBox; _speriod->setRange(1, 999999); connect(_speriod, SIGNAL(valueChanged(int)), this, SLOT(modified())); form->addRow(tr("Short Period"), _speriod); // mperiod _mperiod = new QSpinBox; _mperiod->setRange(1, 999999); connect(_mperiod, SIGNAL(valueChanged(int)), this, SLOT(modified())); form->addRow(tr("Medium Period"), _mperiod); // lperiod _lperiod = new QSpinBox; _lperiod->setRange(1, 999999); connect(_lperiod, SIGNAL(valueChanged(int)), this, SLOT(modified())); form->addRow(tr("Long Period"), _lperiod); _tabs->addTab(w, tr("Settings")); } void ULTOSCDialog::done () { emit signalDone((void *) this); Dialog::done(); } void ULTOSCDialog::loadSettings () { QSettings settings(_settingsPath, QSettings::NativeFormat); Dialog::loadSettings(settings); } void ULTOSCDialog::saveSettings() { QSettings settings(_settingsPath, QSettings::NativeFormat); Dialog::saveSettings(settings); } void ULTOSCDialog::setSettings (QString i, QString hk, QString lk, QString ck, int sp, int mp, int lp) { _input->setInput(i); _input->setKey(tr("High"), hk); _input->setKey(tr("Low"), lk); _input->setKey(tr("Close"), ck); _speriod->setValue(sp); _mperiod->setValue(mp); _lperiod->setValue(lp); } void ULTOSCDialog::settings (QString &i, QString &hk, QString &lk, QString &ck, int &sp, int &mp, int &lp) { i = _input->input(); hk = _input->key(tr("High")); lk = _input->key(tr("Low")); ck = _input->key(tr("Close")); sp = _speriod->value(); mp = _mperiod->value(); lp = _lperiod->value(); } --- NEW FILE: ULTOSCObject.cpp --- /* * Qtstalker stock charter * * Copyright (C) 2001-2010 Stefan S. Stratigakos * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. */ #include "ULTOSCObject.h" #include "ta_libc.h" #include "ULTOSCDialog.h" #include "Util.h" #include <QtDebug> ULTOSCObject::ULTOSCObject (QString profile, QString name) { TA_RetCode rc = TA_Initialize(); if (rc != TA_SUCCESS) qDebug() << "ULTOSCObject::ULTOSCObject: error on TA_Initialize"; _profile = profile; _name = name; _plugin = QString("ULTOSC"); _type = QString("indicator"); _speriod = 7; _mperiod = 14; _lperiod = 28; _outputKey = QString("v"); _hasOutput = TRUE; _inputObject = QString("symbol"); _highKey = QString("H"); _lowKey = QString("L"); _closeKey = QString("C"); _commandList << QString("update"); _commandList << QString("dialog"); _commandList << QString("output"); _commandList << QString("load"); _commandList << QString("save"); _commandList << QString("output_keys"); } ULTOSCObject::~ULTOSCObject () { clear(); } void ULTOSCObject::clear () { qDeleteAll(_bars); _bars.clear(); } int ULTOSCObject::message (ObjectCommand *oc) { int rc = 0; switch (_commandList.indexOf(oc->command())) { case 0: rc = update(oc); break; case 1: rc = dialog(oc); break; case 2: rc = output(oc); break; case 3: rc = load(oc); break; case 4: rc = save(oc); break; case 5: rc = outputKeys(oc); break; default: break; } return rc; } int ULTOSCObject::update (ObjectCommand *oc) { clear(); // input object Object *io = (Object *) oc->getObject(_inputObject); if (! io) { qDebug() << "ULTOSCObject::update: invalid input" << _inputObject; return 0; } // get input bars ObjectCommand toc(QString("output")); if (! io->message(&toc)) { qDebug() << "ULTOSCObject::update: message error" << io->plugin() << toc.command(); return 0; } QMap<int, Data *> data = toc.map(); int size = data.size(); TA_Real high[size]; TA_Real low[size]; TA_Real close[size]; TA_Real out[size]; TA_Integer outBeg; TA_Integer outNb; int dpos = 0; QMapIterator<int, Data *> it(data); while (it.hasNext()) { it.next(); Data *d = it.value(); if (! d->contains(_highKey)) continue; if (! d->contains(_lowKey)) continue; if (! d->contains(_closeKey)) continue; high[dpos] = (TA_Real) d->value(_highKey).toDouble(); low[dpos] = (TA_Real) d->value(_lowKey).toDouble(); close[dpos++] = (TA_Real) d->value(_closeKey).toDouble(); } TA_RetCode rc = TA_ULTOSC(0, dpos - 1, &high[0], &low[0], &close[0], _speriod, _mperiod, _lperiod, &outBeg, &outNb, &out[0]); if (rc != TA_SUCCESS) { qDebug() << "ULTOSCObject::update: TA-Lib error" << rc; return 0; } int outLoop = outNb - 1; it.toBack(); while (it.hasPrevious() && outLoop > -1) { it.previous(); Data *b = new Data; b->insert(_outputKey, out[outLoop--]); _bars.insert(it.key(), b); } return 1; } int ULTOSCObject::dialog (ObjectCommand *oc) { ULTOSCDialog *dialog = new ULTOSCDialog(oc->getObjects(), _name); dialog->setSettings(_inputObject, _highKey, _lowKey, _closeKey, _speriod, _mperiod, _lperiod); connect(dialog, SIGNAL(signalDone(void *)), this, SLOT(dialogDone(void *))); dialog->setModified(FALSE); dialog->show(); return 1; } void ULTOSCObject::dialogDone (void *dialog) { ULTOSCDialog *d = (ULTOSCDialog *) dialog; d->settings(_inputObject, _highKey, _lowKey, _closeKey, _speriod, _mperiod, _lperiod); ObjectCommand oc(QString("modified")); emit signalMessage(oc); } int ULTOSCObject::outputKeys (ObjectCommand *oc) { QStringList keys; keys << _outputKey; oc->setValue(QString("output_keys"), keys); return 1; } int ULTOSCObject::output (ObjectCommand *oc) { outputKeys(oc); oc->setMap(_bars); return 1; } int ULTOSCObject::load (ObjectCommand *oc) { QSettings *settings = (QSettings *) oc->getObject(QString("QSettings")); if (! settings) { qDebug() << "ULTOSCObject::load: invalid QSettings"; return 0; } _inputObject = settings->value(QString("input_object")).toString(); _highKey = settings->value(QString("high_key")).toString(); _lowKey = settings->value(QString("low_key")).toString(); _closeKey = settings->value(QString("close_key")).toString(); _speriod = settings->value(QString("speriod")).toInt(); _mperiod = settings->value(QString("mperiod")).toInt(); _lperiod = settings->value(QString("lperiod")).toInt(); return 1; } int ULTOSCObject::save (ObjectCommand *oc) { QSettings *settings = (QSettings *) oc->getObject(QString("QSettings")); if (! settings) { qDebug() << "ULTOSCObject::save: invalid QSettings"; return 0; } settings->setValue(QString("plugin"), _plugin); settings->setValue(QString("input_object"), _inputObject); settings->setValue(QString("high_key"), _highKey); settings->setValue(QString("low_key"), _lowKey); settings->setValue(QString("close_key"), _closeKey); settings->setValue(QString("speriod"), _speriod); settings->setValue(QString("mperiod"), _mperiod); settings->setValue(QString("lperiod"), _lperiod); return 1; } --- NEW FILE: ULTOSCObject.h --- /* * Qtstalker stock charter * * Copyright (C) 2001-2010 Stefan S. Stratigakos * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. */ #ifndef PLUGIN_ULTOSC_OBJECT_HPP #define PLUGIN_ULTOSC_OBJECT_HPP #include <QStringList> #include <QMap> #include "Object.h" #include "ULTOSCDialog.h" class ULTOSCObject : public Object { Q_OBJECT public: ULTOSCObject (QString profile, QString name); ~ULTOSCObject (); void clear (); int update (ObjectCommand *); int dialog (ObjectCommand *); int output (ObjectCommand *); int load (ObjectCommand *); int save (ObjectCommand *); int outputKeys (ObjectCommand *); public slots: int message (ObjectCommand *); void dialogDone (void *); private: QStringList _commandList; QMap<int, Data *> _bars; QString _inputObject; QString _highKey; QString _lowKey; QString _closeKey; QString _outputKey; int _speriod; int _mperiod; int _lperiod; }; #endif --- NEW FILE: ULTOSC.h --- /* * Qtstalker stock charter * * Copyright (C) 2001-2007 Stefan S. Stratigakos * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. */ #ifndef PLUGIN_ULTOSC_H #define PLUGIN_ULTOSC_H #include "Plugin.h" class ULTOSC : public QObject, public Plugin { Q_OBJECT Q_INTERFACES(Plugin) public: ULTOSC (); int command (PluginCommand *); protected: QStringList _commandList; }; #endif --- NEW FILE: ULTOSC.cpp --- /* * Qtstalker stock charter * * Copyright (C) 2001-2007 Stefan S. Stratigakos * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. */ #include "ULTOSC.h" #include "ULTOSCObject.h" ULTOSC::ULTOSC () { _commandList << QString("type"); _commandList << QString("object"); } int ULTOSC::command (PluginCommand *pc) { int rc = 0; switch (_commandList.indexOf(pc->command)) { case 0: // type pc->type = QString("indicator"); rc = 1; break; case 1: // object pc->object = new ULTOSCObject(pc->profile, pc->name); rc = 1; break; default: break; } return rc; } // do not remove Q_EXPORT_PLUGIN2(ULTOSC, ULTOSC); --- NEW FILE: ULTOSC.pro --- TEMPLATE = lib CONFIG += plugin MOC_DIR += build OBJECTS_DIR += build INCLUDEPATH += ../../src HEADERS += ULTOSC.h SOURCES += ULTOSC.cpp HEADERS += ULTOSCObject.h SOURCES += ULTOSCObject.cpp HEADERS += ULTOSCDialog.h SOURCES += ULTOSCDialog.cpp HEADERS += ../../src/Object.h SOURCES += ../../src/Object.cpp HEADERS += ../../src/Util.h SOURCES += ../../src/Util.cpp HEADERS += ../../src/Plugin.h HEADERS += ../../src/PluginCommand.h HEADERS += ../../src/ObjectCommand.h SOURCES += ../../src/ObjectCommand.cpp SOURCES += ../../src/Dialog.cpp HEADERS += ../../src/Dialog.h SOURCES += ../../src/InputObjectWidget.cpp HEADERS += ../../src/InputObjectWidget.h HOME=$$system(echo $HOME) target.path = $${HOME}/OTA/lib INSTALLS += target QT += core QT += gui --- NEW FILE: ULTOSCDialog.h --- /* * Qtstalker stock charter * * Copyright (C) 2001-2010 Stefan S. Stratigakos * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. */ #ifndef PLUGIN_ULTOSC_DIALOG_HPP #define PLUGIN_ULTOSC_DIALOG_HPP #include <QtGui> #include "Dialog.h" #include "InputObjectWidget.h" class ULTOSCDialog : public Dialog { Q_OBJECT public: ULTOSCDialog (QHash<QString, void *> objects, QString name); ~ULTOSCDialog (); void createTab (QHash<QString, void *>); void setSettings(QString i, QString hk, QString lk, QString ck, int sp, int mp, int lp); void settings(QString &i, QString &hk, QString &lk, QString &ck, int &sp, int &mp, int &lp); public slots: void done (); void loadSettings (); void saveSettings (); protected: InputObjectWidget *_input; QSpinBox *_speriod; QSpinBox *_mperiod; QSpinBox *_lperiod; }; #endif |
From: Steve S. <sst...@us...> - 2013-02-15 04:47:54
|
Update of /cvsroot/qtstalker/qtstalker/plugins/T3 In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv10004/T3 Log Message: Directory /cvsroot/qtstalker/qtstalker/plugins/T3 added to the repository |
From: Steve S. <sst...@us...> - 2013-02-15 04:39:57
|
Update of /cvsroot/qtstalker/qtstalker/plugins/Symbol In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv9667/qtstalker/plugins/Symbol Added Files: .cvsignore Symbol.cpp Symbol.h Symbol.pro SymbolDialog.cpp SymbolDialog.h SymbolObject.cpp SymbolObject.h SymbolSelectDialog.cpp SymbolSelectDialog.h Log Message: --- NEW FILE: .cvsignore --- Makefile moc_*.cpp --- NEW FILE: SymbolObject.h --- /* * Qtstalker stock charter * * Copyright (C) 2001-2010 Stefan S. Stratigakos * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. */ #ifndef PLUGIN_SYMBOL_OBJECT_HPP #define PLUGIN_SYMBOL_OBJECT_HPP #include <QStringList> #include <QDateTime> #include <QMap> #include "Object.h" #include "Data.h" #include "SymbolDialog.h" class SymbolObject : public Object { Q_OBJECT public: SymbolObject (QString profile, QString name); ~SymbolObject (); int loadBars (ObjectCommand *); int saveBars (ObjectCommand *); int values (ObjectCommand *); int search (ObjectCommand *); int size (ObjectCommand *); int dialog (ObjectCommand *); int symbol (ObjectCommand *); int load (ObjectCommand *); int save (ObjectCommand *); int copy (ObjectCommand *); int outputKeys (ObjectCommand *); int info (ObjectCommand *); int exchanges (ObjectCommand *); int searchDialog (ObjectCommand *); int getBars (QDateTime &startDate, QDateTime &endDate, QString table, QString length); int getInterval (QString &length, int interval, QDateTime &sd, QDateTime &ed); int getInfo (QString symbol, Data &); int setInfo (Data &); public slots: int message (ObjectCommand *); void dialogDone (void *); void searchDialogDone (void *); private: QStringList _commands; QStringList _lengths; QMap<int, Data *> _bars; QString _path; QString _file; QString _exchange; QString _ticker; Data _info; int _interval; Object *_db; }; #endif --- NEW FILE: SymbolDialog.cpp --- /* * Qtstalker stock charter * * Copyright (C) 2001-2010 Stefan S. Stratigakos * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. */ #include "SymbolDialog.h" #include "Util.h" #include "Object.h" SymbolDialog::SymbolDialog (QString name) : Dialog (0, name) { QStringList tl; QDir dir(QDir::homePath()); tl << dir.absolutePath() << QString("OTA") << QString("Symbol") << QString("settings") << QString("dialog"); _settingsPath = tl.join("/"); createSymbolTab(); loadSettings(); } SymbolDialog::~SymbolDialog () { saveSettings(); } void SymbolDialog::createSymbolTab () { QWidget *w = new QWidget; QFormLayout *form = new QFormLayout; form->setSpacing(2); form->setMargin(10); w->setLayout(form); // exchange _exchange = new QLineEdit; connect(_exchange, SIGNAL(textEdited(const QString &)), this, SLOT(modified())); form->addRow(tr("Exchange"), _exchange); // ticker _ticker = new QLineEdit; connect(_ticker, SIGNAL(textEdited(const QString &)), this, SLOT(modified())); form->addRow(tr("Ticker"), _ticker); _tabs->addTab(w, tr("Settings")); } void SymbolDialog::done () { emit signalDone((void *) this); Dialog::done(); } void SymbolDialog::loadSettings () { QSettings settings(_settingsPath, QSettings::NativeFormat); Dialog::loadSettings(settings); } void SymbolDialog::saveSettings() { QSettings settings(_settingsPath, QSettings::NativeFormat); Dialog::saveSettings(settings); } void SymbolDialog::setSettings (QString e, QString t) { _exchange->setText(e); _ticker->setText(t); } void SymbolDialog::settings (QString &e, QString &t) { e = _exchange->text(); t = _ticker->text(); } --- NEW FILE: SymbolDialog.h --- /* * Qtstalker stock charter * * Copyright (C) 2001-2010 Stefan S. Stratigakos * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. */ #ifndef PLUGIN_SYMBOL_DIALOG_HPP #define PLUGIN_SYMBOL_DIALOG_HPP #include <QtGui> #include "Dialog.h" class SymbolDialog : public Dialog { Q_OBJECT public: SymbolDialog (QString name); ~SymbolDialog (); void createSymbolTab (); void setSettings (QString exchange, QString ticker); void settings (QString &exchange, QString &ticker); public slots: void done (); void loadSettings (); void saveSettings (); protected: QLineEdit *_exchange; QLineEdit *_ticker; }; #endif --- NEW FILE: SymbolSelectDialog.h --- /* * Qtstalker stock charter * * Copyright (C) 2001-2010 Stefan S. Stratigakos * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. */ #ifndef PLUGIN_SYMBOL_SELECT_DIALOG_HPP #define PLUGIN_SYMBOL_SELECT_DIALOG_HPP #include <QtGui> #include "Dialog.h" #include "Object.h" class SymbolSelectDialog : public Dialog { Q_OBJECT public: SymbolSelectDialog (QString name); ~SymbolSelectDialog (); void createTab (); void loadExchanges (); void setSettings (QString exchange, QString ticker, QString type, QString name); void settings (QHash<QString, Data> &, QString &exchange, QString &ticker, QString &type, QString &name); void setSearchList (QStringList); public slots: void done (); void searchSelectionChanged (); void symbolSelectionChanged (); void searchButtonPressed (); void addButtonPressed (); void deleteButtonPressed (); void loadSettings (); void saveSettings (); private: QTreeWidget *_searchList; QTreeWidget *_symbolList; QComboBox *_exchanges; QLineEdit *_search; QLineEdit *_symbolType; QLineEdit *_symbolName; QPushButton *_searchButton; QToolButton *_addButton; QToolButton *_deleteButton; Object *_symbolObject; }; #endif --- NEW FILE: SymbolSelectDialog.cpp --- /* * Qtstalker stock charter * * Copyright (C) 2001-2010 Stefan S. Stratigakos * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. */ #include "SymbolSelectDialog.h" #include "Util.h" #include "../pics/search.xpm" #include "../pics/select_all.xpm" #include "../pics/unselect_all.xpm" #include "../pics/add.xpm" #include "../pics/delete.xpm" #include <QtDebug> SymbolSelectDialog::SymbolSelectDialog (QString name) : Dialog (0, name) { QStringList tl; QDir dir(QDir::homePath()); tl << dir.absolutePath() << QString("OTA") << QString("Symbol") << QString("settings") << QString("select_dialog"); _settingsPath = tl.join("/"); Util util; _symbolObject = util.object(QString("Symbol"), QString(), QString()); createTab(); loadExchanges(); loadSettings(); searchSelectionChanged(); symbolSelectionChanged(); _search->setFocus(); } SymbolSelectDialog::~SymbolSelectDialog () { saveSettings(); if (_symbolObject) delete _symbolObject; } void SymbolSelectDialog::createTab () { QWidget *w = new QWidget; QVBoxLayout *vbox = new QVBoxLayout; vbox->setSpacing(2); vbox->setMargin(10); w->setLayout(vbox); QFormLayout *form = new QFormLayout; form->setSpacing(2); form->setMargin(0); vbox->addLayout(form); _exchanges = new QComboBox; _exchanges->setToolTip(tr("Select a specific exchange or % for all")); connect(_exchanges, SIGNAL(currentIndexChanged(int)), this, SLOT(modified())); form->addRow(tr("Exchange"), _exchanges); _search = new QLineEdit("%"); _search->setToolTip(tr("Enter a partial search like %OOG% or * for all")); connect(_search, SIGNAL(textChanged(const QString &)), this, SLOT(modified())); form->addRow(tr("Symbol pattern"), _search); _symbolType = new QLineEdit("%"); connect(_symbolType, SIGNAL(textChanged(const QString &)), this, SLOT(modified())); form->addRow(tr("Symbol Type"), _symbolType); _symbolName = new QLineEdit("%"); connect(_symbolName, SIGNAL(textChanged(const QString &)), this, SLOT(modified())); form->addRow(tr("Symbol Name"), _symbolName); _searchButton = new QPushButton; _searchButton->setIcon(QIcon(search_xpm)); _searchButton->setToolTip(tr("Perform search")); connect(_searchButton, SIGNAL(clicked()), this, SLOT(searchButtonPressed())); form->addRow(tr("Search"), _searchButton); QHBoxLayout *hbox = new QHBoxLayout; hbox->setSpacing(2); hbox->setMargin(0); vbox->addLayout(hbox); QGroupBox *gbox = new QGroupBox; gbox->setTitle(tr("Search Results")); hbox->addWidget(gbox); QVBoxLayout *tvbox = new QVBoxLayout; tvbox->setSpacing(0); tvbox->setMargin(0); gbox->setLayout(tvbox); QStringList l; l << tr("Symbol") << tr("Name"); _searchList = new QTreeWidget; _searchList->setSortingEnabled(FALSE); _searchList->setRootIsDecorated(FALSE); _searchList->setHeaderLabels(l); _searchList->setSelectionMode(QAbstractItemView::ExtendedSelection); connect(_searchList, SIGNAL(itemSelectionChanged()), this, SLOT(searchSelectionChanged())); // connect(_searchList, SIGNAL(itemDoubleClicked(QListWidgetItem *)), this, SLOT(done())); tvbox->addWidget(_searchList); tvbox = new QVBoxLayout; tvbox->setSpacing(0); tvbox->setMargin(0); hbox->addLayout(tvbox); tvbox->addStretch(1); QToolBar *tb = new QToolBar; tb->setOrientation(Qt::Vertical); tvbox->addWidget(tb); _addButton = new QToolButton; _addButton->setIcon(QIcon(add_xpm)); _addButton->setToolTip(tr("Add selected to symbols")); connect(_addButton, SIGNAL(clicked()), this, SLOT(addButtonPressed())); tb->addWidget(_addButton); _deleteButton = new QToolButton; _deleteButton->setIcon(QIcon(delete_xpm)); _deleteButton->setToolTip(tr("Remove selected from symbols")); connect(_deleteButton, SIGNAL(clicked()), this, SLOT(deleteButtonPressed())); tb->addWidget(_deleteButton); QToolButton *b = new QToolButton; b->setIcon(QIcon(select_all_xpm)); b->setToolTip(tr("Select all symbols")); connect(b, SIGNAL(clicked()), _searchList, SLOT(selectAll())); tb->addWidget(b); b = new QToolButton; b->setIcon(QIcon(unselect_all_xpm)); b->setToolTip(tr("Unselect all symbols")); connect(b, SIGNAL(clicked()), _searchList, SLOT(clearSelection())); tb->addWidget(b); tvbox->addStretch(1); gbox = new QGroupBox; gbox->setTitle(tr("Symbols")); hbox->addWidget(gbox); tvbox = new QVBoxLayout; tvbox->setSpacing(0); tvbox->setMargin(0); gbox->setLayout(tvbox); _symbolList = new QTreeWidget; _symbolList->setSortingEnabled(FALSE); _symbolList->setRootIsDecorated(FALSE); _symbolList->setHeaderLabels(l); _symbolList->setSelectionMode(QAbstractItemView::ExtendedSelection); connect(_symbolList, SIGNAL(itemSelectionChanged()), this, SLOT(symbolSelectionChanged())); tvbox->addWidget(_symbolList); _tabs->addTab(w, tr("Settings")); } void SymbolSelectDialog::searchSelectionChanged () { int status = 0; QList<QTreeWidgetItem *> sl = _searchList->selectedItems(); if (sl.count()) status = 1; _addButton->setEnabled(status); } void SymbolSelectDialog::symbolSelectionChanged () { int status = 0; QList<QTreeWidgetItem *> sl = _symbolList->selectedItems(); if (sl.count()) status = 1; _deleteButton->setEnabled(status); status = FALSE; if (_symbolList->topLevelItemCount()) status = TRUE; setModified(status); } void SymbolSelectDialog::done () { emit signalDone((void *) this); Dialog::done(); } void SymbolSelectDialog::addButtonPressed () { QList<QTreeWidgetItem *> sl = _searchList->selectedItems(); int loop = 0; for (; loop < sl.count(); loop++) { QTreeWidgetItem *item = sl.at(loop); QTreeWidgetItem *nitem = new QTreeWidgetItem(_symbolList); nitem->setText(0, item->text(0)); nitem->setText(1, item->text(1)); } for (loop = 0; loop < _symbolList->columnCount(); loop++) _symbolList->resizeColumnToContents(loop); symbolSelectionChanged(); } void SymbolSelectDialog::deleteButtonPressed () { QList<QTreeWidgetItem *> sl = _symbolList->selectedItems(); int loop = 0; for (; loop < sl.count(); loop++) { QTreeWidgetItem *item = sl.at(loop); delete item; } for (loop = 0; loop < _symbolList->columnCount(); loop++) _symbolList->resizeColumnToContents(loop); symbolSelectionChanged(); } void SymbolSelectDialog::searchButtonPressed () { if (! _symbolObject) return; ObjectCommand toc(QString("search")); toc.setValue(QString("exchange"), _exchanges->currentText()); toc.setValue(QString("ticker"), _search->text()); toc.setValue(QString("type"), _symbolType->text()); toc.setValue(QString("name"), _symbolName->text()); if (! _symbolObject->message(&toc)) { qDebug() << "SymbolSelectDialog::searchButtonPressed: message error" << _symbolObject->plugin() << toc.command(); return; } setSearchList(toc.getList(QString("list"))); } void SymbolSelectDialog::loadExchanges () { if (! _symbolObject) return; ObjectCommand toc(QString("exchanges")); if (! _symbolObject->message(&toc)) { qDebug() << "SymbolSelectDialog::loadExchanges: message error" << _symbolObject->plugin() << toc.command(); return; } QStringList l = toc.getList(QString("names")); l.prepend(QString("%")); _exchanges->clear(); _exchanges->addItems(l); _exchanges->setCurrentIndex(0); } void SymbolSelectDialog::setSettings (QString exchange, QString ticker, QString type, QString name) { if (! exchange.isEmpty()) _exchanges->setCurrentIndex(_exchanges->findText(exchange)); if (! ticker.isEmpty()) _search->setText(ticker); if (! type.isEmpty()) _symbolType->setText(type); if (! name.isEmpty()) _symbolName->setText(name); setModified(FALSE); } void SymbolSelectDialog::settings (QHash<QString, Data> &d, QString &exchange, QString &ticker, QString &type, QString &name) { d.clear(); for (int pos = 0; pos < _symbolList->topLevelItemCount(); pos++) { QTreeWidgetItem *i = _symbolList->topLevelItem(pos); Data symbol; symbol.insert(QString("name"), i->text(1)); d.insert(i->text(0), symbol); } exchange = _exchanges->currentText(); ticker = _search->text(); type = _symbolType->text(); name = _symbolName->text(); } void SymbolSelectDialog::setSearchList (QStringList l) { if (! _symbolObject) return; ObjectCommand toc(QString("info")); toc.setValue(QString("names"), l); if (! _symbolObject->message(&toc)) { qDebug() << "SymbolSelectDialog::setSearchList: message error" << _symbolObject->plugin() << toc.command(); return; } _searchList->clear(); QHashIterator<QString, Data> it(toc.getDatas()); while (it.hasNext()) { it.next(); Data d = it.value(); QTreeWidgetItem *item = new QTreeWidgetItem(_searchList); item->setText(0, it.key()); item->setText(1, d.value(QString("name")).toString()); } for (int pos = 0; pos < _searchList->columnCount(); pos++) _searchList->resizeColumnToContents(pos); } void SymbolSelectDialog::loadSettings () { QSettings settings(_settingsPath, QSettings::NativeFormat); Dialog::loadSettings(settings); } void SymbolSelectDialog::saveSettings() { QSettings settings(_settingsPath, QSettings::NativeFormat); Dialog::saveSettings(settings); } --- NEW FILE: Symbol.pro --- TEMPLATE = lib CONFIG += plugin MOC_DIR += build OBJECTS_DIR += build INCLUDEPATH += ../../src HEADERS += Symbol.h SOURCES += Symbol.cpp HEADERS += SymbolDialog.h SOURCES += SymbolDialog.cpp HEADERS += SymbolObject.h SOURCES += SymbolObject.cpp HEADERS += SymbolSelectDialog.h SOURCES += SymbolSelectDialog.cpp HEADERS += ../../src/Object.h SOURCES += ../../src/Object.cpp HEADERS += ../../src/Util.h SOURCES += ../../src/Util.cpp HEADERS += ../../src/PluginCommand.h HEADERS += ../../src/ObjectCommand.h SOURCES += ../../src/ObjectCommand.cpp HEADERS += ../../src/Plugin.h SOURCES += ../../src/Dialog.cpp HEADERS += ../../src/Dialog.h HOME=$$system(echo $HOME) target.path = $${HOME}/OTA/lib INSTALLS += target QT += core QT += gui --- NEW FILE: Symbol.cpp --- /* * Qtstalker stock charter * * Copyright (C) 2001-2007 Stefan S. Stratigakos * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. */ #include "Symbol.h" #include "SymbolObject.h" Symbol::Symbol () { _commands << QString("type"); _commands << QString("object"); } int Symbol::command (PluginCommand *pc) { int rc = 0; switch (_commands.indexOf(pc->command)) { case 0: // type pc->type = QString("system"); rc = 1; break; case 1: // object pc->object = new SymbolObject(pc->profile, pc->name); rc = 1; break; default: break; } return rc; } // do not remove Q_EXPORT_PLUGIN2(Symbol, Symbol); --- NEW FILE: SymbolObject.cpp --- /* * Qtstalker stock charter * * Copyright (C) 2001-2010 Stefan S. Stratigakos * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. */ #include <QtDebug> #include "SymbolObject.h" #include "SymbolSelectDialog.h" #include "Util.h" SymbolObject::SymbolObject (QString profile, QString name) { _profile = profile; _name = name; _plugin = QString("Symbol"); _type = QString("system"); _hasOutput = TRUE; _commands << QString("get"); _commands << QString("list"); _commands << QString("set"); _commands << QString("output"); _commands << QString("search"); _commands << QString("size"); _commands << QString("dialog"); _commands << QString("symbol"); _commands << QString("load"); _commands << QString("save"); _commands << QString("copy"); _commands << QString("output_keys"); _commands << QString("info"); _commands << QString("exchanges"); _commands << QString("search_dialog"); _lengths << "T"; _lengths << "D"; _lengths << "W"; _lengths << "M"; _interval = 1; // db path QStringList tl; QDir dir(QDir::homePath()); tl << dir.absolutePath() << QString("OTA") << QString("Symbol") << QString("db"); _path = tl.join("/"); _file = QString("db"); // get db object Util util; _db = util.object(QString("DataBase"), QString(), QString()); if (_db) { // open db ObjectCommand oc(QString("open")); oc.setValue(QString("path"), _path); oc.setValue(QString("file"), _file); if (! _db->message(&oc)) qDebug() << "SymbolObject::SymbolObject: message error" << _db->plugin() << oc.command(); } else qDebug() << "SymbolObject::SymbolObject: invalid db object"; } SymbolObject::~SymbolObject () { qDeleteAll(_bars); if (_db) delete _db; } int SymbolObject::message (ObjectCommand *oc) { int rc = 0; switch (_commands.indexOf(oc->command())) { case 0: rc = loadBars(oc); break; case 1: oc->setValue(QString("list"), _lengths); rc = 1; break; case 2: rc = saveBars(oc); break; case 3: rc = values(oc); break; case 4: rc = search(oc); break; case 5: rc = size(oc); break; case 6: rc = dialog(oc); break; case 7: rc = symbol(oc); break; case 8: rc = load(oc); break; case 9: rc = save(oc); break; case 10: rc = copy(oc); break; case 11: rc = outputKeys(oc); break; case 12: rc = info(oc); break; case 13: rc = exchanges(oc); break; case 14: rc = searchDialog(oc); break; default: break; } return rc; } int SymbolObject::loadBars (ObjectCommand *oc) { qDeleteAll(_bars); _bars.clear(); _info.clear(); if (! _db) { qDebug() << "SymbolObject::load: invalid db object"; return 0; } QString key("exchange"); QString exchange = oc->getString(key); if (exchange.isEmpty()) { qDebug() << "SymbolObject::load: invalid" << key; return 0; } key = QString("ticker"); QString ticker = oc->getString(key); if (ticker.isEmpty()) { qDebug() << "SymbolObject::load: invalid" << key; return 0; } key = QString("length"); QString length = oc->getString(key); if (length.isEmpty()) { qDebug() << "SymbolObject::load: invalid" << key; return 0; } key = QString("start_date"); QDateTime sd = oc->getDate(key); if (! sd.isValid()) { qDebug() << "SymbolObject::load: invalid" << key << sd; return 0; } key = QString("end_date"); QDateTime ed = oc->getDate(key); if (! ed.isValid()) { qDebug() << "SymbolObject::load: invalid" << key << ed; return 0; } QString symbol = exchange + ":" + ticker; Data info; if (! getInfo(symbol, info)) { qDebug() << "SymbolObject::load: getInfo error"; return 0; } else _info = info; QString table = _info.value(QString("table")).toString(); if (! getBars(sd, ed, table, length)) { qDebug() << "SymbolObject::load: getBars error"; return 0; } //qDebug() << "SymbolObject::load" << _bars.size(); return 1; } int SymbolObject::saveBars (ObjectCommand *oc) { if (! _db) { qDebug() << "SymbolObject::save: invalid db object"; return 0; } QString key("exchange"); QString exchange = oc->getString(key); if (exchange.isEmpty()) { qDebug() << "SymbolObject::save: invalid" << key; return 0; } key = QString("ticker"); QString ticker = oc->getString(key); if (ticker.isEmpty()) { qDebug() << "SymbolObject::save: invalid" << key; return 0; } Data info; QString symbol = exchange + ":" + ticker; if (! getInfo(symbol, info)) { qDebug() << "SymbolObject::save: getInfo error"; return 0; } // are we adding a new symbol? QString table = info.value("table").toString(); if (table.isEmpty()) { info.insert(QString("exchange"), QVariant(exchange)); info.insert(QString("ticker"), QVariant(ticker)); key = QString("type"); QString type = oc->getString(key); if (type.isEmpty()) { qDebug() << "SymbolObject::save: invalid" << key; return 0; } info.insert(key, QVariant(type)); key = QString("name"); QString name = oc->getString(key); if (name.isEmpty()) { qDebug() << "SymbolObject::save: invalid" << key; return 0; } info.insert(key, QVariant(name)); table = "Q" + QUuid::createUuid().toString(); table.remove("{"); table.remove("}"); table.remove("-"); info.insert(QString("table"), QVariant(table)); if (! setInfo(info)) { qDebug() << "SymbolObject::save: DataBase object error"; return 0; } } ObjectCommand toc(QString("transaction")); if (! _db->message(&toc)) { qDebug() << "SymbolObject::save: message error" << toc.command(); return 0; } toc.setCommand(QString("set")); toc.setValue(QString("table"), table); toc.setDatas(oc->getDatas()); if (! _db->message(&toc)) { qDebug() << "SymbolObject::save: message error" << toc.command(); return 0; } toc.setCommand(QString("commit")); if (! _db->message(&toc)) { qDebug() << "SymbolObject::save: message error" << toc.command(); return 0; } return 1; } int SymbolObject::search (ObjectCommand *oc) { if (! _db) { qDebug() << "SymbolObject::search: invalid db object"; return 0; } ObjectCommand toc(QString("search")); toc.setValue(QString("table"), QString("symbolIndex")); Data search; search.insert(QString("exchange"), oc->getString(QString("exchange"))); search.insert(QString("ticker"), oc->getString(QString("ticker"))); search.insert(QString("type"), oc->getString(QString("type"))); search.insert(QString("name"), oc->getString(QString("name"))); toc.setValue(QString("search"), search); if (! _db->message(&toc)) { qDebug() << "SymbolObject::search: message error" << toc.command(); return 0; } oc->setValue(QString("list"), toc.getList(QString("list"))); return 1; } int SymbolObject::exchanges (ObjectCommand *oc) { if (! _db) { qDebug() << "SymbolObject::exchanges: invalid db object"; return 0; } ObjectCommand toc(QString("search")); toc.setValue(QString("table"), QString("symbolIndex")); Data search; search.insert(QString("exchange"), oc->getString(QString("%"))); toc.setValue(QString("search"), search); if (! _db->message(&toc)) { qDebug() << "SymbolObject::search: message error" << toc.command(); return 0; } oc->setValue(QString("list"), toc.getList(QString("list"))); return 1; } int SymbolObject::values (ObjectCommand *oc) { oc->setMap(_bars); oc->setValue(QString("exchange"), _exchange); oc->setValue(QString("ticker"), _ticker); return 1; } int SymbolObject::size (ObjectCommand *oc) { oc->setValue(QString("size"), _bars.size()); return 1; } int SymbolObject::dialog (ObjectCommand *) { SymbolDialog *dialog = new SymbolDialog(_name); dialog->setSettings(_exchange, _ticker); connect(dialog, SIGNAL(signalDone(void *)), this, SLOT(dialogDone(void *))); dialog->show(); return 1; } void SymbolObject::dialogDone (void *dialog) { SymbolDialog *d = (SymbolDialog *) dialog; d->settings(_exchange, _ticker); ObjectCommand oc(QString("modified")); emit signalMessage(oc); } int SymbolObject::symbol (ObjectCommand *oc) { QString ts = _exchange + ":" + _ticker; oc->setValue(QString("symbol"), ts); return 1; } int SymbolObject::load (ObjectCommand *oc) { QString key("QSettings"); QSettings *settings = (QSettings *) oc->getObject(key); if (! settings) { qDebug() << "SymbolObject::load: invalid" << key; return 0; } _exchange = settings->value(QString("exchange")).toString(); _ticker = settings->value(QString("ticker")).toString(); return 1; } int SymbolObject::save (ObjectCommand *oc) { QString key("QSettings"); QSettings *settings = (QSettings *) oc->getObject(key); if (! settings) { qDebug() << "SymbolObject::save: invalid" << key; return 0; } settings->setValue(QString("plugin"), _plugin); settings->setValue(QString("exchange"), _exchange); settings->setValue(QString("ticker"), _ticker); return 1; } int SymbolObject::copy (ObjectCommand *oc) { QString key("input"); Object *input = (Object *) oc->getObject(key); if (! input) { qDebug() << "SymbolObject::copy: invalid" << key; return 0; } if (input->plugin() != _plugin) { qDebug() << "SymbolObject::copy: invalid" << input->plugin() << _plugin << key; return 0; } ObjectCommand toc(QString("output")); if (! input->message(&toc)) { qDebug() << "SymbolObject::copy: message error" << input->plugin() << toc.command(); return 0; } qDeleteAll(_bars); _bars.clear(); _exchange = toc.getString(QString("exchange")); _ticker = toc.getString(QString("ticker")); QMapIterator<int, Data *> it(toc.map()); while (it.hasNext()) { it.next(); Data *b = it.value(); QStringList keys = b->keys(); Data *nb = new Data; for (int pos = 0; pos < keys.size(); pos++) nb->insert(keys.at(pos), b->value(keys.at(pos))); _bars.insert(it.key(), nb); } //qDebug() << "SymbolObject::copy:" << _bars.size(); return 1; } int SymbolObject::outputKeys (ObjectCommand *oc) { QStringList keys; keys << "D" << "O" << "H" << "L" << "C" << "V"; oc->setValue(QString("output_keys"), keys); return 1; } int SymbolObject::info (ObjectCommand *oc) { QString key("names"); QStringList names = oc->getList(key); for (int pos = 0; pos < names.size(); pos++) { Data i; if (! getInfo(names.at(pos), i)) continue; oc->setValue(names.at(pos), i); } return 1; } int SymbolObject::searchDialog (ObjectCommand *oc) { SymbolSelectDialog *dialog = new SymbolSelectDialog(_name); dialog->setSettings(oc->getString(QString("exchange")), oc->getString(QString("ticker")), oc->getString(QString("type")), oc->getString(QString("name"))); connect(dialog, SIGNAL(signalDone(void *)), this, SLOT(searchDialogDone(void *))); dialog->show(); return 1; } void SymbolObject::searchDialogDone (void *dialog) { SymbolSelectDialog *d = (SymbolSelectDialog *) dialog; QHash<QString, Data> symbols; QString exchange, ticker, type, name; d->settings(symbols, exchange, ticker, type, name); ObjectCommand oc(QString("search")); oc.setValue(QString("exchange"), exchange); oc.setValue(QString("ticker"), ticker); oc.setValue(QString("type"), type); oc.setValue(QString("name"), name); oc.setDatas(symbols); emit signalMessage(oc); } int SymbolObject::getInfo (QString symbol, Data &info) { info.clear(); if (! _db) { qDebug() << "SymbolObject::getInfo: invalid db object"; return 0; } ObjectCommand oc(QString("get")); oc.setValue(QString("table"), QString("symbolIndex")); QStringList tl; tl << symbol; oc.setValue(QString("names"), tl); if (! _db->message(&oc)) { qDebug() << "SymbolObject::getInfo: message error" << oc.command(); return 0; } info = oc.getData(symbol); return 1; } int SymbolObject::setInfo (Data &info) { if (! _db) { qDebug() << "SymbolObject::setInfo: invalid db object"; return 0; } ObjectCommand oc(QString("transaction")); if (! _db->message(&oc)) { qDebug() << "SymbolObject::setInfo: message error" << oc.command(); return 0; } QString symbol = info.value("exchange").toString() + ":" + info.value("ticker").toString(); oc.setCommand(QString("set")); oc.setValue(QString("table"), QString("symbolIndex")); oc.setValue(symbol, info); if (! _db->message(&oc)) { qDebug() << "SymbolObject::setInfo: message error" << oc.command(); return 0; } oc.setCommand(QString("commit")); if (! _db->message(&oc)) { qDebug() << "SymbolObject::setInfo: message error" << oc.command(); return 0; } return 1; } int SymbolObject::getBars (QDateTime &startDate, QDateTime &endDate, QString table, QString length) { if (! _db) { qDebug() << "SymbolObject::getBars: invalid db object"; return 0; } // load all bars within date range ObjectCommand oc(QString("get_range")); oc.setValue(QString("table"), table); oc.setValue(QString("range_start"), startDate.toString("yyyyMMddHHmmss")); oc.setValue(QString("range_end"), endDate.toString("yyyyMMddHHmmss")); if (! _db->message(&oc)) { qDebug() << "SymbolObject::getBars: message error" << oc.command(); return 0; } //qDebug() << "SymbolObject::getBars: records" << oc.outputs.size(); QHash<QString, Data> output = oc.getDatas(); QList<QString> keys = output.keys(); qSort(keys); QHash<QString, Data *> tbars; for (int pos = 0; pos < keys.size(); pos++) { Data d = output.value(keys.at(pos)); QDateTime td = QDateTime::fromString(keys.at(pos), "yyyyMMddHHmmss"); if (! td.isValid()) continue; QDateTime sd = td; QDateTime ed; if (! getInterval(length, 1, sd, ed)) continue; QString key = ed.toString("yyyyMMddHHmmss"); Data *bar = tbars.value(key); if (! bar) { bar = new Data; bar->insert(QString("D"), QVariant(td)); bar->insert(QString("O"), d.value(QString("O"))); bar->insert(QString("H"), d.value(QString("H"))); bar->insert(QString("L"), d.value(QString("L"))); bar->insert(QString("C"), d.value(QString("C"))); bar->insert(QString("V"), d.value(QString("V"))); tbars.insert(key, bar); } else { // update to latest date bar->insert(QString("D"), QVariant(td)); // test high double t = d.value(QString("H")).toDouble(); double t2 = bar->value(QString("H")).toDouble(); if (t > t2) bar->insert(QString("H"), QVariant(t)); // test low t = d.value(QString("L")).toDouble(); t2 = bar->value(QString("L")).toDouble(); if (t < t2) bar->insert(QString("L"), QVariant(t)); // accumulate volume t = bar->value(QString("V")).toDouble(); t += d.value(QString("V")).toDouble(); bar->insert(QString("V"), QVariant(t)); // latest close bar->insert(QString("C"), d.value(QString("C"))); } } keys = tbars.keys(); qSort(keys); for (int pos = 0; pos < keys.size(); pos++) _bars.insert(pos, tbars.value(keys.at(pos))); return 1; } int SymbolObject::getInterval (QString &length, int interval, QDateTime &sd, QDateTime &ed) { switch (_lengths.indexOf(length)) { case 0: // T sd.setTime(QTime(sd.time().hour(), sd.time().minute(), 0, 0)); ed = sd; ed = ed.addSecs(60 * interval); // ed = ed.addSecs(-1); break; case 1: // D sd.setTime(QTime(0, 0, 0, 0)); ed = sd; ed = ed.addDays(interval); // ed = ed.addSecs(-1); break; case 2: // W sd.setTime(QTime(0, 0, 0, 0)); sd = sd.addDays(- (sd.date().dayOfWeek() - 1)); ed = sd; ed = ed.addDays(7 * interval); // ed = ed.addSecs(-1); break; case 3: // M sd.setTime(QTime(0, 0, 0, 0)); sd = sd.addDays(- (sd.date().day() - 1)); ed = sd; for (int loop = 0; loop < interval; loop++) ed = ed.addDays(ed.date().daysInMonth()); // ed = ed.addSecs(-1); break; default: return 0; break; } return 1; } --- NEW FILE: Symbol.h --- /* * Qtstalker stock charter * * Copyright (C) 2001-2007 Stefan S. Stratigakos * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. */ #ifndef PLUGIN_SYMBOL_H #define PLUGIN_SYMBOL_H #include "Plugin.h" class Symbol : public QObject, Plugin { Q_OBJECT Q_INTERFACES(Plugin) public: Symbol (); int command (PluginCommand *); private: QStringList _commands; }; #endif |
From: Steve S. <sst...@us...> - 2013-02-15 04:39:28
|
Update of /cvsroot/qtstalker/qtstalker/plugins/Symbol In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv9632/Symbol Log Message: Directory /cvsroot/qtstalker/qtstalker/plugins/Symbol added to the repository |
Update of /cvsroot/qtstalker/qtstalker/plugins/STOCHS In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv9477/qtstalker/plugins/STOCHS Modified Files: STOCHS.cpp STOCHS.h STOCHS.pro STOCHSDialog.cpp STOCHSDialog.h Added Files: STOCHSObject.cpp STOCHSObject.h Log Message: --- NEW FILE: STOCHSObject.h --- /* * Qtstalker stock charter * * Copyright (C) 2001-2010 Stefan S. Stratigakos * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. */ #ifndef PLUGIN_STOCHS_OBJECT_HPP #define PLUGIN_STOCHS_OBJECT_HPP #include <QStringList> #include <QMap> #include "Object.h" #include "STOCHSDialog.h" class STOCHSObject : public Object { Q_OBJECT public: STOCHSObject (QString profile, QString name); ~STOCHSObject (); void clear (); int update (ObjectCommand *); int dialog (ObjectCommand *); int output (ObjectCommand *); int load (ObjectCommand *); int save (ObjectCommand *); int outputKeys (ObjectCommand *); public slots: int message (ObjectCommand *); void dialogDone (void *); private: QStringList _commandList; QStringList _maList; QMap<int, Data *> _bars; QString _inputObject; QString _highKey; QString _lowKey; QString _closeKey; QString _kmaType; QString _dmaType; QString _outputKKey; QString _outputDKey; int _period; int _kperiod; int _dperiod; }; #endif Index: STOCHSDialog.cpp =================================================================== RCS file: /cvsroot/qtstalker/qtstalker/plugins/STOCHS/STOCHSDialog.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** STOCHSDialog.cpp 25 Jun 2012 22:28:03 -0000 1.1 --- STOCHSDialog.cpp 15 Feb 2013 04:37:10 -0000 1.2 *************** *** 21,337 **** #include "STOCHSDialog.h" ! #include "Doc.h" ! #include "Global.h" ! #include "MAType.h" ! #include "CurveLineType.h" ! #include "BarType.h" ! ! #include <QtDebug> ! #include <QVariant> ! #include <QLayout> ! #include <QFormLayout> ! ! STOCHSDialog::STOCHSDialog (QWidget *p) : QDialog (p) { ! _settings = 0; ! _modified = 0; ! _helpFile = "main.html"; ! connect(this, SIGNAL(finished(int)), this, SLOT(deleteLater())); ! ! // main vbox ! QVBoxLayout *vbox = new QVBoxLayout; ! vbox->setSpacing(2); ! vbox->setMargin(5); ! setLayout(vbox); ! _tabs = new QTabWidget; ! vbox->addWidget(_tabs); ! ! // buttonbox ! _buttonBox = new QDialogButtonBox(QDialogButtonBox::Help); ! connect(_buttonBox, SIGNAL(accepted()), this, SLOT(done())); ! connect(_buttonBox, SIGNAL(rejected()), this, SLOT(cancel())); ! vbox->addWidget(_buttonBox); ! ! // ok button ! _okButton = _buttonBox->addButton(QDialogButtonBox::Ok); ! _okButton->setText(tr("&OK")); ! ! // cancel button ! _cancelButton = _buttonBox->addButton(QDialogButtonBox::Cancel); ! _cancelButton->setText(tr("&Cancel")); ! _cancelButton->setDefault(TRUE); ! _cancelButton->setFocus(); ! ! // help button ! QPushButton *b = _buttonBox->button(QDialogButtonBox::Help); ! b->setText(tr("&Help")); ! connect(b, SIGNAL(clicked()), this, SLOT(help())); ! } ! ! void STOCHSDialog::done () ! { ! saveSettings(); ! save(); ! accept(); ! } ! ! void STOCHSDialog::help () ! { ! Doc *doc = new Doc; ! doc->showDocumentation(_helpFile); } ! void STOCHSDialog::cancel () { saveSettings(); - reject(); - } - - void STOCHSDialog::loadSettings () - { - QSettings settings(g_settings); - settings.beginGroup(g_session); - - QSize sz = settings.value("stochs_dialog_size", QSize(200,200)).toSize(); - resize(sz); - - // restore the position of the app - QPoint p = settings.value("stochs_dialog_pos").toPoint(); - if (! p.isNull()) - move(p); - } - - void STOCHSDialog::saveSettings () - { - QSettings settings(g_settings); - settings.beginGroup(g_session); - settings.setValue("stochs_dialog_size", size()); - settings.setValue("stochs_dialog_pos", pos()); } ! void STOCHSDialog::setGUI (Entity *settings) { ! _settings = settings; - // %K page QWidget *w = new QWidget; QFormLayout *form = new QFormLayout; w->setLayout(form); - - // color - QVariant *set = _settings->get(QString("kColor")); - - _kColor = new ColorButton(this, QColor(set->toString())); - connect(_kColor, SIGNAL(valueChanged(QColor)), this, SLOT(modified())); - form->addRow(tr("Color"), _kColor); - - // fast period - set = _settings->get(QString("fkPeriod")); - - _fkPeriod = new QSpinBox; - _fkPeriod->setRange(1, 999999); - _fkPeriod->setValue(set->toInt()); - connect(_fkPeriod, SIGNAL(valueChanged(const QString &)), this, SLOT(modified())); - form->addRow(tr("Fast Period"), _fkPeriod); - - // k period - set = _settings->get(QString("kPeriod")); - - _kPeriod = new QSpinBox; - _kPeriod->setRange(1, 999999); - _kPeriod->setValue(set->toInt()); - connect(_kPeriod, SIGNAL(valueChanged(const QString &)), this, SLOT(modified())); - form->addRow(tr("Period"), _kPeriod); - - // ma type - set = _settings->get(QString("kType")); - - MAType mat; - _kType = new QComboBox; - _kType->addItems(mat.list()); - _kType->setCurrentIndex(_kType->findText(set->toString(), Qt::MatchExactly)); - connect(_kType, SIGNAL(currentIndexChanged(int)), this, SLOT(modified())); - form->addRow(tr("Type"), _kType); - - // style - set = _settings->get(QString("kStyle")); - - CurveLineType clt; - _kStyle = new QComboBox; - _kStyle->addItems(clt.list()); - _kStyle->setCurrentIndex(_kStyle->findText(set->toString(), Qt::MatchExactly)); - connect(_kStyle, SIGNAL(currentIndexChanged(int)), this, SLOT(modified())); - form->addRow(tr("Style"), _kStyle); - - // width - set = _settings->get(QString("kWidth")); - - _kWidth = new QSpinBox; - _kWidth->setRange(1, 99); - _kWidth->setValue(set->toInt()); - connect(_kWidth, SIGNAL(valueChanged(const QString &)), this, SLOT(modified())); - form->addRow(tr("Width"), _kWidth); - - _tabs->addTab(w, QString("%K")); - - - // %D page - w = new QWidget; - - form = new QFormLayout; - w->setLayout(form); - - // type - set = _settings->get(QString("dType")); - - _dType = new QComboBox; - _dType->addItems(mat.list()); - _dType->setCurrentIndex(_dType->findText(set->toString(), Qt::MatchExactly)); - connect(_dType, SIGNAL(currentIndexChanged(int)), this, SLOT(modified())); - form->addRow(tr("Type"), _dType); - - // style - set = _settings->get(QString("dStyle")); - - _dStyle = new QComboBox; - _dStyle->addItems(clt.list()); - _dStyle->setCurrentIndex(_dStyle->findText(set->toString(), Qt::MatchExactly)); - connect(_dStyle, SIGNAL(currentIndexChanged(int)), this, SLOT(modified())); - form->addRow(tr("Style"), _dStyle); ! // width ! set = _settings->get(QString("dWidth")); - _dWidth = new QSpinBox; - _dWidth->setRange(1, 99); - _dWidth->setValue(set->toInt()); - connect(_dWidth, SIGNAL(valueChanged(const QString &)), this, SLOT(modified())); - form->addRow(tr("Width"), _dWidth); - - // color - set = _settings->get(QString("dColor")); - - _dColor = new ColorButton(this, QColor(set->toString())); - connect(_dColor, SIGNAL(valueChanged(QColor)), this, SLOT(modified())); - form->addRow(tr("Color"), _dColor); - // period ! set = _settings->get(QString("dPeriod")); ! ! _dPeriod = new QSpinBox; ! _dPeriod->setRange(1, 999999); ! _dPeriod->setValue(set->toInt()); ! connect(_dPeriod, SIGNAL(valueChanged(const QString &)), this, SLOT(modified())); ! form->addRow(tr("Period"), _dPeriod); ! ! _tabs->addTab(w, QString("%D")); ! ! ! // buy marker page ! w = new QWidget; ! ! form = new QFormLayout; ! w->setLayout(form); ! ! // color ! set = _settings->get(QString("buyMarkerColor")); ! _ref1Color = new ColorButton(this, QColor(set->toString())); ! connect(_ref1Color, SIGNAL(valueChanged(QColor)), this, SLOT(modified())); ! form->addRow(tr("Color"), _ref1Color); ! ! // value ! set = _settings->get(QString("buyMarkerPrice")); ! ! _ref1 = new QDoubleSpinBox; ! _ref1->setRange(-99999999.0, 99999999.0); ! _ref1->setValue(set->toDouble()); ! connect(_ref1, SIGNAL(valueChanged(const QString &)), this, SLOT(modified())); ! form->addRow(tr("Value"), _ref1); ! ! _tabs->addTab(w, tr("Buy Marker")); ! // REF2 page ! w = new QWidget; ! ! form = new QFormLayout; ! w->setLayout(form); ! ! // color ! set = _settings->get(QString("sellMarkerColor")); ! ! _ref2Color = new ColorButton(this, QColor(set->toString())); ! connect(_ref2Color, SIGNAL(valueChanged(QColor)), this, SLOT(modified())); ! form->addRow(tr("Color"), _ref2Color); ! // value ! set = _settings->get(QString("sellMarkerPrice")); ! _ref2 = new QDoubleSpinBox; ! _ref2->setRange(-99999999.0, 99999999.0); ! _ref2->setValue(set->toDouble()); ! connect(_ref2, SIGNAL(valueChanged(const QString &)), this, SLOT(modified())); ! form->addRow(tr("Value"), _ref2); ! _tabs->addTab(w, tr("Sell Marker")); } ! void STOCHSDialog::save () { ! if (! _modified) ! return; ! ! QVariant *set = _settings->get(QString("kColor")); ! set->setValue(_kColor->color().name()); ! ! set = _settings->get(QString("fkPeriod")); ! set->setValue(_fkPeriod->value()); ! ! set = _settings->get(QString("kPeriod")); ! set->setValue(_kPeriod->value()); ! ! set = _settings->get(QString("kWidth")); ! set->setValue(_kWidth->value()); ! ! set = _settings->get(QString("kStyle")); ! set->setValue(_kStyle->currentText()); ! ! set = _settings->get(QString("kType")); ! set->setValue(_kType->currentText()); ! ! set = _settings->get(QString("dColor")); ! set->setValue(_dColor->color().name()); ! ! set = _settings->get(QString("dPeriod")); ! set->setValue(_dPeriod->value()); ! ! set = _settings->get(QString("dWidth")); ! set->setValue(_dWidth->value()); ! ! set = _settings->get(QString("dStyle")); ! set->setValue(_dStyle->currentText()); ! ! set = _settings->get(QString("dType")); ! set->setValue(_dType->currentText()); ! ! set = _settings->get(QString("buyMarkerColor")); ! set->setValue(_ref1Color->color().name()); ! set = _settings->get(QString("buyMarkerPrice")); ! set->setValue(_ref1->value()); ! set = _settings->get(QString("sellMarkerColor")); ! set->setValue(_ref2Color->color().name()); ! set = _settings->get(QString("sellMarkerPrice")); ! set->setValue(_ref2->value()); } ! void STOCHSDialog::modified () { ! _modified = 1; } --- 21,158 ---- #include "STOCHSDialog.h" ! #include "Util.h" ! STOCHSDialog::STOCHSDialog (QHash<QString, void *> objects, QString name) : Dialog (0, name) { ! QStringList tl; ! QDir dir(QDir::homePath()); ! tl << dir.absolutePath() << QString("OTA") << QString("STOCHS") << QString("settings") << QString("dialog"); ! _settingsPath = tl.join("/"); ! createTab(objects); ! loadSettings(); } ! STOCHSDialog::~STOCHSDialog () { saveSettings(); } ! void ! STOCHSDialog::createTab (QHash<QString, void *> l) { ! QHash<QString, void *> ol; ! QHashIterator<QString, void *> it(l); ! while (it.hasNext()) ! { ! it.next(); ! Object *o = (Object *) it.value(); ! if (o->hasOutput()) ! ol.insert(it.key(), it.value()); ! } QWidget *w = new QWidget; QFormLayout *form = new QFormLayout; + form->setSpacing(2); + form->setMargin(10); w->setLayout(form); ! _input = new InputObjectWidget; ! _input->setObjects(ol); ! connect(_input, SIGNAL(valueChanged()), this, SLOT(modified())); ! form->addRow(tr("Input"), _input); // period ! _period = new QSpinBox; ! _period->setRange(1, 999999); ! connect(_period, SIGNAL(valueChanged(int)), this, SLOT(modified())); ! form->addRow(tr("Fast Period"), _period); ! // k type ! QStringList tl; ! Util util; ! Object *o = util.object(QString("MA"), QString(), QString()); ! if (o) ! { ! QString key("types"); ! ObjectCommand toc(key); ! if (o->message(&toc)) ! tl = toc.getList(key); ! delete o; ! } + _ktype = new QComboBox; + _ktype->addItems(tl); + connect(_ktype, SIGNAL(currentIndexChanged(int)), this, SLOT(modified())); + form->addRow(tr("%K MA Type"), _ktype); ! // k period ! _kperiod = new QSpinBox; ! _kperiod->setRange(1, 999999); ! connect(_kperiod, SIGNAL(valueChanged(int)), this, SLOT(modified())); ! form->addRow(tr("%K Period"), _kperiod); ! // d type ! _dtype = new QComboBox; ! _dtype->addItems(tl); ! connect(_dtype, SIGNAL(currentIndexChanged(int)), this, SLOT(modified())); ! form->addRow(tr("%D MA Type"), _dtype); ! // d period ! _dperiod = new QSpinBox; ! _dperiod->setRange(1, 999999); ! connect(_dperiod, SIGNAL(valueChanged(int)), this, SLOT(modified())); ! form->addRow(tr("%D Period"), _dperiod); ! _tabs->addTab(w, tr("Settings")); } ! void ! STOCHSDialog::done () { ! emit signalDone((void *) this); ! Dialog::done(); ! } ! void ! STOCHSDialog::loadSettings () ! { ! QSettings settings(_settingsPath, QSettings::NativeFormat); ! Dialog::loadSettings(settings); ! } ! void ! STOCHSDialog::saveSettings() ! { ! QSettings settings(_settingsPath, QSettings::NativeFormat); ! Dialog::saveSettings(settings); ! } ! void ! STOCHSDialog::setSettings (QString i, QString hk, QString lk, QString ck, QString kma, QString dma, int p, int kp, int dp) ! { ! _input->setInput(i); ! _input->setKey(tr("High"), hk); ! _input->setKey(tr("Low"), lk); ! _input->setKey(tr("Close"), ck); ! _ktype->setCurrentIndex(_ktype->findText(kma)); ! _dtype->setCurrentIndex(_dtype->findText(dma)); ! _period->setValue(p); ! _kperiod->setValue(kp); ! _dperiod->setValue(dp); } ! void ! STOCHSDialog::settings (QString &i, QString &hk, QString &lk, QString &ck, QString &kma, QString &dma, int &p, int &kp, int &dp) { ! i = _input->input(); ! hk = _input->key(tr("High")); ! lk = _input->key(tr("Low")); ! ck = _input->key(tr("Close")); ! kma = _ktype->currentText(); ! dma = _dtype->currentText(); ! p = _period->value(); ! kp = _kperiod->value(); ! dp = _dperiod->value(); } --- NEW FILE: STOCHSObject.cpp --- /* * Qtstalker stock charter * * Copyright (C) 2001-2010 Stefan S. Stratigakos * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. */ #include "STOCHSObject.h" #include "ta_libc.h" #include "STOCHSDialog.h" #include "Util.h" #include <QtDebug> STOCHSObject::STOCHSObject (QString profile, QString name) { TA_RetCode rc = TA_Initialize(); if (rc != TA_SUCCESS) qDebug() << "STOCHSObject::STOCHSObject: error on TA_Initialize"; _profile = profile; _name = name; _plugin = QString("STOCHS"); _type = QString("indicator"); _kmaType = QString("EMA"); _dmaType = QString("EMA"); _period = 5; _kperiod = 3; _dperiod = 3; _outputKKey = QString("k"); _outputDKey = QString("d"); _hasOutput = TRUE; _inputObject = QString("symbol"); _highKey = QString("H"); _lowKey = QString("L"); _closeKey = QString("C"); _commandList << QString("update"); _commandList << QString("dialog"); _commandList << QString("output"); _commandList << QString("load"); _commandList << QString("save"); _commandList << QString("output_keys"); Util util; Object *o = util.object(QString("MA"), QString(), QString()); if (o) { QString key("types"); ObjectCommand toc(key); if (o->message(&toc)) _maList = toc.getList(key); delete o; } } STOCHSObject::~STOCHSObject () { clear(); } void STOCHSObject::clear () { qDeleteAll(_bars); _bars.clear(); } int STOCHSObject::message (ObjectCommand *oc) { int rc = 0; switch (_commandList.indexOf(oc->command())) { case 0: rc = update(oc); break; case 1: rc = dialog(oc); break; case 2: rc = output(oc); break; case 3: rc = load(oc); break; case 4: rc = save(oc); break; case 5: rc = outputKeys(oc); break; default: break; } return rc; } int STOCHSObject::update (ObjectCommand *oc) { clear(); // input object Object *io = (Object *) oc->getObject(_inputObject); if (! io) { qDebug() << "STOCHSObject::update: invalid input" << _inputObject; return 0; } // get input bars ObjectCommand toc(QString("output")); if (! io->message(&toc)) { qDebug() << "STOCHSObject::update: message error" << io->plugin() << toc.command(); return 0; } QMap<int, Data *> data = toc.map(); int size = data.size(); TA_Real high[size]; TA_Real low[size]; TA_Real close[size]; TA_Real out[size]; TA_Real out2[size]; TA_Integer outBeg; TA_Integer outNb; int dpos = 0; QMapIterator<int, Data *> it(data); while (it.hasNext()) { it.next(); Data *d = it.value(); if (! d->contains(_highKey)) continue; if (! d->contains(_lowKey)) continue; if (! d->contains(_closeKey)) continue; high[dpos] = (TA_Real) d->value(_highKey).toDouble(); low[dpos] = (TA_Real) d->value(_lowKey).toDouble(); close[dpos++] = (TA_Real) d->value(_closeKey).toDouble(); } TA_RetCode rc = TA_STOCH(0, dpos - 1, &high[0], &low[0], &close[0], _period, _kperiod, (TA_MAType) _maList.indexOf(_kmaType), _dperiod, (TA_MAType) _maList.indexOf(_dmaType), &outBeg, &outNb, &out[0], &out2[0]); if (rc != TA_SUCCESS) { qDebug() << "STOCHSObject::update: TA-Lib error" << rc; return 0; } int outLoop = outNb - 1; it.toBack(); while (it.hasPrevious() && outLoop > -1) { it.previous(); Data *b = new Data; b->insert(_outputKKey, out[outLoop]); b->insert(_outputDKey, out2[outLoop--]); _bars.insert(it.key(), b); } return 1; } int STOCHSObject::dialog (ObjectCommand *oc) { STOCHSDialog *dialog = new STOCHSDialog(oc->getObjects(), _name); dialog->setSettings(_inputObject, _highKey, _lowKey, _closeKey, _kmaType, _dmaType, _period, _kperiod, _dperiod); connect(dialog, SIGNAL(signalDone(void *)), this, SLOT(dialogDone(void *))); dialog->setModified(FALSE); dialog->show(); return 1; } void STOCHSObject::dialogDone (void *dialog) { STOCHSDialog *d = (STOCHSDialog *) dialog; d->settings(_inputObject, _highKey, _lowKey, _closeKey, _kmaType, _dmaType, _period, _kperiod, _dperiod); ObjectCommand oc(QString("modified")); emit signalMessage(oc); } int STOCHSObject::outputKeys (ObjectCommand *oc) { QStringList keys; keys << _outputKKey << _outputDKey; oc->setValue(QString("output_keys"), keys); return 1; } int STOCHSObject::output (ObjectCommand *oc) { outputKeys(oc); oc->setMap(_bars); return 1; } int STOCHSObject::load (ObjectCommand *oc) { QSettings *settings = (QSettings *) oc->getObject(QString("QSettings")); if (! settings) { qDebug() << "STOCHSObject::load: invalid QSettings"; return 0; } _inputObject = settings->value(QString("input_object")).toString(); _highKey = settings->value(QString("high_key")).toString(); _lowKey = settings->value(QString("low_key")).toString(); _closeKey = settings->value(QString("close_key")).toString(); _kmaType = settings->value(QString("ktype")).toString(); _dmaType = settings->value(QString("dtype")).toString(); _period = settings->value(QString("period")).toInt(); _kperiod = settings->value(QString("kperiod")).toInt(); _dperiod = settings->value(QString("dperiod")).toInt(); return 1; } int STOCHSObject::save (ObjectCommand *oc) { QSettings *settings = (QSettings *) oc->getObject(QString("QSettings")); if (! settings) { qDebug() << "STOCHSObject::save: invalid QSettings"; return 0; } settings->setValue(QString("plugin"), _plugin); settings->setValue(QString("input_object"), _inputObject); settings->setValue(QString("high_key"), _highKey); settings->setValue(QString("low_key"), _lowKey); settings->setValue(QString("close_key"), _closeKey); settings->setValue(QString("ktype"), _kmaType); settings->setValue(QString("dtype"), _dmaType); settings->setValue(QString("period"), _period); settings->setValue(QString("kperiod"), _kperiod); settings->setValue(QString("dperiod"), _dperiod); return 1; } Index: STOCHS.h =================================================================== RCS file: /cvsroot/qtstalker/qtstalker/plugins/STOCHS/STOCHS.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** STOCHS.h 25 Jun 2012 22:28:03 -0000 1.1 --- STOCHS.h 15 Feb 2013 04:37:10 -0000 1.2 *************** *** 24,29 **** #define PLUGIN_STOCHS_H - #include <QObject> - #include "Plugin.h" --- 24,27 ---- *************** *** 34,44 **** public: ! int draw (QPainter *, const QwtScaleMap &, const QwtScaleMap &, const QRect &, void *); ! int command (PluginData *); ! int settings (PluginData *); ! int dialog (PluginData *); ! int run (PluginData *); ! int getSTOCHS (int fk, int sk, int kma, QString kkey, int sd, int dma, QString dkey); ! Marker * newMarker (QColor color, double price); }; --- 32,40 ---- public: ! STOCHS (); ! int command (PluginCommand *); ! ! protected: ! QStringList _commandList; }; Index: STOCHS.cpp =================================================================== RCS file: /cvsroot/qtstalker/qtstalker/plugins/STOCHS/STOCHS.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** STOCHS.cpp 25 Jun 2012 22:28:03 -0000 1.1 --- STOCHS.cpp 15 Feb 2013 04:37:10 -0000 1.2 *************** *** 20,56 **** */ - #include <QtGui> - - #include "ta_libc.h" #include "STOCHS.h" ! #include "MAType.h" ! #include "BarType.h" ! #include "CurveLineType.h" ! #include "Global.h" ! #include "STOCHSDialog.h" int ! STOCHS::command (PluginData *pd) { int rc = 0; ! QStringList cl; ! cl << "type" << "dialog" << "runIndicator" << "settings"; ! ! switch (cl.indexOf(pd->command)) { case 0: // type ! pd->type = QString("indicator"); rc = 1; break; ! case 1: // dialog ! rc = dialog(pd); ! break; ! case 2: // runIndicator ! rc = run(pd); ! break; ! case 3: // settings ! rc = settings(pd); break; default: --- 20,47 ---- */ #include "STOCHS.h" ! #include "STOCHSObject.h" + STOCHS::STOCHS () + { + _commandList << QString("type"); + _commandList << QString("object"); + } + int ! STOCHS::command (PluginCommand *pc) { int rc = 0; ! switch (_commandList.indexOf(pc->command)) { case 0: // type ! pc->type = QString("indicator"); rc = 1; break; ! case 1: // object ! pc->object = new STOCHSObject(pc->profile, pc->name); ! rc = 1; break; default: *************** *** 61,329 **** } - int - STOCHS::dialog (PluginData *pd) - { - if (! pd->dialogParent) - { - qDebug() << "STOCHS::dialog: invalid parent"; - return 0; - } - - if (! pd->settings) - { - qDebug() << "STOCHS::dialog: invalid settings"; - return 0; - } - - STOCHSDialog *dialog = new STOCHSDialog(pd->dialogParent); - dialog->setGUI(pd->settings); - pd->dialog = dialog; - - return 1; - } - - int - STOCHS::run (PluginData *pd) - { - if (! g_symbol) - return 0; - - QVariant *fk = pd->settings->get(QString("fkPeriod")); - if (! fk) - return 0; - - QVariant *sk = pd->settings->get(QString("kPeriod")); - if (! sk) - return 0; - - MAType mat; - QVariant *var = pd->settings->get(QString("kType")); - if (! var) - return 0; - int kma = mat.stringToIndex(var->toString()); - - QVariant *klabel = pd->settings->get(QString("kLabel")); - if (! klabel) - return 0; - - var = pd->settings->get(QString("kColor")); - if (! var) - return 0; - QColor kcolor(var->toString()); - - QVariant *kstyle = pd->settings->get(QString("kStyle")); - if (! kstyle) - return 0; - - QVariant *kwidth = pd->settings->get(QString("kWidth")); - if (! kwidth) - return 0; - - QVariant *sd = pd->settings->get(QString("dPeriod")); - if (! sd) - return 0; - - QVariant *dlabel = pd->settings->get(QString("dLabel")); - if (! dlabel) - return 0; - - var = pd->settings->get(QString("dColor")); - if (! var) - return 0; - QColor dcolor(var->toString()); - - var = pd->settings->get(QString("dType")); - if (! var) - return 0; - int dma = mat.stringToIndex(var->toString()); - - QVariant *dstyle = pd->settings->get(QString("dStyle")); - if (! dstyle) - return 0; - - QVariant *dwidth = pd->settings->get(QString("dWidth")); - if (! dwidth) - return 0; - - if (! getSTOCHS(fk->toInt(), - sk->toInt(), - kma, - klabel->toString(), - sd->toInt(), - dma, - dlabel->toString())) - return 0; - - // buy marker - QVariant *mcolor = pd->settings->get(QString("buyMarkerColor")); - QColor color(mcolor->toString()); - QVariant *mprice = pd->settings->get(QString("buyMarkerPrice")); - Marker *m = newMarker(color, mprice->toDouble()); - pd->markers << m; - - // sell marker - mcolor = pd->settings->get(QString("sellMarkerColor")); - color = QColor(mcolor->toString()); - mprice = pd->settings->get(QString("sellMarkerPrice")); - m = newMarker(color, mprice->toDouble()); - pd->markers << m; - - CurveLineType clt; - Curve *c = new Curve(QString("CurveLine")); - c->setColor(kcolor); - c->setLabel(klabel->toString()); - c->setStyle(clt.stringToIndex(kstyle->toString())); - c->fill(klabel->toString(), QString(), QString(), QString(), kcolor); - c->setPen(kwidth->toInt()); - pd->curves << c; - - c = new Curve(QString("CurveLine")); - c->setColor(dcolor); - c->setLabel(dlabel->toString()); - c->setStyle(clt.stringToIndex(dstyle->toString())); - c->fill(dlabel->toString(), QString(), QString(), QString(), dcolor); - c->setPen(dwidth->toInt()); - pd->curves << c; - - return 1; - } - - int - STOCHS::getSTOCHS (int fk, int sk, int kma, QString kkey, int sd, int dma, QString dkey) - { - if (! g_symbol) - return 0; - - TA_RetCode rc = TA_Initialize(); - if (rc != TA_SUCCESS) - qDebug() << "STOCHS::STOCHS: error on TA_Initialize"; - - QList<int> keys = g_symbol->keys(); - - int size = keys.size(); - TA_Real high[size]; - TA_Real low[size]; - TA_Real close[size]; - TA_Real out[size]; - TA_Real out2[size]; - TA_Integer outBeg; - TA_Integer outNb; - - BarType bt; - QString highKey = bt.indexToString(BarType::_HIGH); - QString lowKey = bt.indexToString(BarType::_LOW); - QString closeKey = bt.indexToString(BarType::_CLOSE); - - int dpos = 0; - for (int kpos = 0; kpos < keys.size(); kpos++) - { - CBar *bar = g_symbol->bar(keys.at(kpos)); - - double h; - if (! bar->get(highKey, h)) - continue; - - double l; - if (! bar->get(lowKey, l)) - continue; - - double c; - if (! bar->get(closeKey, c)) - continue; - - high[dpos] = (TA_Real) h; - low[dpos] = (TA_Real) l; - close[dpos++] = (TA_Real) c; - } - - rc = TA_STOCH(0, dpos - 1, &high[0], &low[0], &close[0], fk, sk, (TA_MAType) kma, sd, (TA_MAType) dma, &outBeg, &outNb, &out[0], &out2[0]); - - if (rc != TA_SUCCESS) - { - qDebug() << "STOCHS::getSTOCHS: TA-Lib error" << rc; - return 0; - } - - int keyLoop = keys.size() - 1; - int outLoop = outNb - 1; - while (keyLoop > -1 && outLoop > -1) - { - CBar *bar = g_symbol->bar(keys.at(keyLoop)); - bar->set(kkey, out[outLoop]); - bar->set(dkey, out2[outLoop]); - keyLoop--; - outLoop--; - } - - return 1; - } - - Marker * - STOCHS::newMarker (QColor color, double price) - { - QString id = QUuid::createUuid().toString(); - id.remove("{"); - id.remove("}"); - id.remove("-"); - - Marker *m = new Marker(QString("MarkerHLine")); - m->setID(id); - m->setReadOnly(TRUE); - - Entity *e = m->settings(); - - QVariant *tset = e->get(QString("color")); - tset->setValue(color.name()); - - tset = e->get(QString("price")); - tset->setValue(price); - - return m; - } - - int - STOCHS::settings (PluginData *pd) - { - BarType bt; - CurveLineType clt; - MAType mat; - Entity *command = new Entity; - - command->set(QString("plugin"), new QVariant(QString("STOCHF"))); - command->set(QString("type"), new QVariant(QString("indicator"))); - - command->set(QString("kType"), new QVariant(mat.indexToString(MAType::_EMA))); - command->set(QString("kStyle"), new QVariant(clt.indexToString(CurveLineType::_SOLID))); - command->set(QString("kWidth"), new QVariant(1)); - command->set(QString("kColor"), new QVariant(QString("red"))); - command->set(QString("fkPeriod"), new QVariant(5)); - command->set(QString("kPeriod"), new QVariant(3)); - command->set(QString("kLabel"), new QVariant(QString("%K"))); - - command->set(QString("dType"), new QVariant(mat.indexToString(MAType::_EMA))); - command->set(QString("dStyle"), new QVariant(clt.indexToString(CurveLineType::_SOLID))); - command->set(QString("dWidth"), new QVariant(1)); - command->set(QString("dColor"), new QVariant(QString("yellow"))); - command->set(QString("dPeriod"), new QVariant(3)); - command->set(QString("dLabel"), new QVariant(QString("%D"))); - - command->set(QString("buyMarkerColor"), new QVariant(QString("green"))); - command->set(QString("buyMarkerPrice"), new QVariant(20.0)); - - command->set(QString("sellMarkerColor"), new QVariant(QString("red"))); - command->set(QString("sellMarkerPrice"), new QVariant(80.0)); - - pd->settings = command; - - return 1; - } - - int - STOCHS::draw (QPainter *, const QwtScaleMap &, const QwtScaleMap &, const QRect &, void *) - { - return 0; - } - - // do not remove ! Q_EXPORT_PLUGIN2(stochs, STOCHS); --- 52,55 ---- } // do not remove ! Q_EXPORT_PLUGIN2(STOCHS, STOCHS); Index: STOCHSDialog.h =================================================================== RCS file: /cvsroot/qtstalker/qtstalker/plugins/STOCHS/STOCHSDialog.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** STOCHSDialog.h 25 Jun 2012 22:28:03 -0000 1.1 --- STOCHSDialog.h 15 Feb 2013 04:37:10 -0000 1.2 *************** *** 23,85 **** #define PLUGIN_STOCHS_DIALOG_HPP ! #include <QDialog> ! #include <QPushButton> ! #include <QDialogButtonBox> ! #include <QStringList> ! #include <QTabWidget> ! #include <QComboBox> ! #include <QLineEdit> ! #include <QSpinBox> ! #include <QCheckBox> ! #include "Entity.h" ! #include "ColorButton.h" ! class STOCHSDialog : public QDialog { Q_OBJECT ! public: ! STOCHSDialog (QWidget *); ! void setGUI (Entity *); ! public slots: void done (); - void cancel (); - void help (); void loadSettings (); void saveSettings (); ! void modified (); ! void save (); ! protected: ! Entity *_settings; ! QTabWidget *_tabs; ! QDialogButtonBox *_buttonBox; ! QPushButton *_okButton; ! QPushButton *_cancelButton; ! QString _helpFile; ! int _modified; ! ! ColorButton *_kColor; ! QSpinBox *_kPeriod; ! QSpinBox *_fkPeriod; ! QSpinBox *_kWidth; ! QComboBox *_kStyle; ! QComboBox *_kType; ! ! QSpinBox *_dWidth; ! ColorButton *_dColor; ! QSpinBox *_dPeriod; ! QComboBox *_dStyle; ! QComboBox *_dType; ! ! QDoubleSpinBox *_ref1; ! ColorButton *_ref1Color; ! QCheckBox *_ref1Show; ! ! QDoubleSpinBox *_ref2; ! ColorButton *_ref2Color; ! QCheckBox *_ref2Show; }; --- 23,54 ---- #define PLUGIN_STOCHS_DIALOG_HPP ! #include <QtGui> ! #include "Dialog.h" ! #include "InputObjectWidget.h" ! class STOCHSDialog : public Dialog { Q_OBJECT ! public: ! STOCHSDialog (QHash<QString, void *> objects, QString name); ! ~STOCHSDialog (); ! void createTab (QHash<QString, void *>); ! void setSettings(QString i, QString hk, QString lk, QString ck, QString kma, QString dma, int p, int kp, int dp); ! void settings(QString &i, QString &hk, QString &lk, QString &ck, QString &kma, QString &dma, int &p, int &kp, int &dp); ! public slots: void done (); void loadSettings (); void saveSettings (); ! protected: ! QComboBox *_ktype; ! QComboBox *_dtype; ! InputObjectWidget *_input; ! QSpinBox *_period; ! QSpinBox *_kperiod; ! QSpinBox *_dperiod; }; Index: STOCHS.pro =================================================================== RCS file: /cvsroot/qtstalker/qtstalker/plugins/STOCHS/STOCHS.pro,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** STOCHS.pro 25 Jun 2012 22:28:03 -0000 1.1 --- STOCHS.pro 15 Feb 2013 04:37:10 -0000 1.2 *************** *** 1,19 **** TEMPLATE = lib CONFIG += plugin - INCLUDEPATH += ../../lib - LIBS += -L../../lib -lOTA MOC_DIR += build OBJECTS_DIR += build HEADERS += STOCHS.h SOURCES += STOCHS.cpp HEADERS += STOCHSDialog.h SOURCES += STOCHSDialog.cpp ! target.path = /usr/local/lib/OTA/plugins INSTALLS += target QT += core QT += gui - QT += sql - QT += network --- 1,33 ---- TEMPLATE = lib CONFIG += plugin MOC_DIR += build OBJECTS_DIR += build + INCLUDEPATH += ../../src + HEADERS += STOCHS.h SOURCES += STOCHS.cpp + HEADERS += STOCHSObject.h + SOURCES += STOCHSObject.cpp HEADERS += STOCHSDialog.h SOURCES += STOCHSDialog.cpp + HEADERS += ../../src/Object.h + SOURCES += ../../src/Object.cpp + HEADERS += ../../src/Util.h + SOURCES += ../../src/Util.cpp + HEADERS += ../../src/Plugin.h + HEADERS += ../../src/PluginCommand.h + HEADERS += ../../src/ObjectCommand.h + SOURCES += ../../src/ObjectCommand.cpp + SOURCES += ../../src/Dialog.cpp + HEADERS += ../../src/Dialog.h + SOURCES += ../../src/InputObjectWidget.cpp + HEADERS += ../../src/InputObjectWidget.h ! ! HOME=$$system(echo $HOME) ! target.path = $${HOME}/OTA/lib INSTALLS += target QT += core QT += gui |
Update of /cvsroot/qtstalker/qtstalker/plugins/STDDEV In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv9477/qtstalker/plugins/STDDEV Added Files: .cvsignore STDDEV.cpp STDDEV.h STDDEV.pro STDDEVDialog.cpp STDDEVDialog.h STDDEVObject.cpp STDDEVObject.h Log Message: --- NEW FILE: .cvsignore --- Makefile moc_*.cpp --- NEW FILE: STDDEVDialog.cpp --- /* * Qtstalker stock charter * * Copyright (C) 2001-2010 Stefan S. Stratigakos * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. */ #include "STDDEVDialog.h" #include "Util.h" STDDEVDialog::STDDEVDialog (QHash<QString, void *> objects, QString name) : Dialog (0, name) { QStringList tl; QDir dir(QDir::homePath()); tl << dir.absolutePath() << QString("OTA") << QString("STDDEV") << QString("settings") << QString("dialog"); _settingsPath = tl.join("/"); createTab(objects); loadSettings(); } STDDEVDialog::~STDDEVDialog () { saveSettings(); } void STDDEVDialog::createTab (QHash<QString, void *> l) { QHash<QString, void *> ol; QHashIterator<QString, void *> it(l); while (it.hasNext()) { it.next(); Object *o = (Object *) it.value(); if (o->hasOutput()) ol.insert(it.key(), it.value()); } QWidget *w = new QWidget; QFormLayout *form = new QFormLayout; form->setSpacing(2); form->setMargin(10); w->setLayout(form); _input = new InputObjectWidget; _input->setObjects(ol); connect(_input, SIGNAL(valueChanged()), this, SLOT(modified())); form->addRow(tr("Input"), _input); // period _period = new QSpinBox; _period->setRange(1, 999999); connect(_period, SIGNAL(valueChanged(int)), this, SLOT(modified())); form->addRow(tr("Period"), _period); // dev _dev = new QDoubleSpinBox; _dev->setRange(-999999, 999999); connect(_dev, SIGNAL(valueChanged(double)), this, SLOT(modified())); form->addRow(tr("Deviation"), _dev); _tabs->addTab(w, tr("Settings")); } void STDDEVDialog::done () { emit signalDone((void *) this); Dialog::done(); } void STDDEVDialog::loadSettings () { QSettings settings(_settingsPath, QSettings::NativeFormat); Dialog::loadSettings(settings); } void STDDEVDialog::saveSettings() { QSettings settings(_settingsPath, QSettings::NativeFormat); Dialog::saveSettings(settings); } void STDDEVDialog::setSettings (QString i, QString ik, int p, double d) { _input->setInput(i); _input->setKey(tr("Input"), ik); _period->setValue(p); _dev->setValue(d); } void STDDEVDialog::settings (QString &i, QString &ik, int &p, double &d) { i = _input->input(); ik = _input->key(tr("Input")); p = _period->value(); d = _dev->value(); } --- NEW FILE: STDDEV.pro --- TEMPLATE = lib CONFIG += plugin MOC_DIR += build OBJECTS_DIR += build INCLUDEPATH += ../../src HEADERS += STDDEV.h SOURCES += STDDEV.cpp HEADERS += STDDEVObject.h SOURCES += STDDEVObject.cpp HEADERS += STDDEVDialog.h SOURCES += STDDEVDialog.cpp HEADERS += ../../src/Object.h SOURCES += ../../src/Object.cpp HEADERS += ../../src/Util.h SOURCES += ../../src/Util.cpp HEADERS += ../../src/Plugin.h HEADERS += ../../src/PluginCommand.h HEADERS += ../../src/ObjectCommand.h SOURCES += ../../src/ObjectCommand.cpp SOURCES += ../../src/Dialog.cpp HEADERS += ../../src/Dialog.h SOURCES += ../../src/InputObjectWidget.cpp HEADERS += ../../src/InputObjectWidget.h HOME=$$system(echo $HOME) target.path = $${HOME}/OTA/lib INSTALLS += target QT += core QT += gui --- NEW FILE: STDDEV.cpp --- /* * Qtstalker stock charter * * Copyright (C) 2001-2007 Stefan S. Stratigakos * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. */ #include "STDDEV.h" #include "STDDEVObject.h" STDDEV::STDDEV () { _commandList << QString("type"); _commandList << QString("object"); } int STDDEV::command (PluginCommand *pc) { int rc = 0; switch (_commandList.indexOf(pc->command)) { case 0: // type pc->type = QString("indicator"); rc = 1; break; case 1: // object pc->object = new STDDEVObject(pc->profile, pc->name); rc = 1; break; default: break; } return rc; } // do not remove Q_EXPORT_PLUGIN2(STDDEV, STDDEV); --- NEW FILE: STDDEVDialog.h --- /* * Qtstalker stock charter * * Copyright (C) 2001-2010 Stefan S. Stratigakos * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. */ #ifndef PLUGIN_STDDEV_DIALOG_HPP #define PLUGIN_STDDEV_DIALOG_HPP #include <QtGui> #include "Dialog.h" #include "InputObjectWidget.h" class STDDEVDialog : public Dialog { Q_OBJECT public: STDDEVDialog (QHash<QString, void *> objects, QString name); ~STDDEVDialog (); void createTab (QHash<QString, void *>); void setSettings(QString i, QString ik, int p, double d); void settings(QString &i, QString &ik, int &p, double &d); public slots: void done (); void loadSettings (); void saveSettings (); protected: InputObjectWidget *_input; QSpinBox *_period; QDoubleSpinBox *_dev; }; #endif --- NEW FILE: STDDEVObject.h --- /* * Qtstalker stock charter * * Copyright (C) 2001-2010 Stefan S. Stratigakos * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. */ #ifndef PLUGIN_STDDEV_OBJECT_HPP #define PLUGIN_STDDEV_OBJECT_HPP #include <QStringList> #include <QMap> #include "Object.h" #include "STDDEVDialog.h" class STDDEVObject : public Object { Q_OBJECT public: STDDEVObject (QString profile, QString name); ~STDDEVObject (); void clear (); int update (ObjectCommand *); int dialog (ObjectCommand *); int output (ObjectCommand *); int load (ObjectCommand *); int save (ObjectCommand *); int outputKeys (ObjectCommand *); public slots: int message (ObjectCommand *); void dialogDone (void *); private: QStringList _commandList; QMap<int, Data *> _bars; QString _inputObject; QString _inputKey; QString _outputKey; int _period; double _dev; }; #endif --- NEW FILE: STDDEVObject.cpp --- /* * Qtstalker stock charter * * Copyright (C) 2001-2010 Stefan S. Stratigakos * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. */ #include "STDDEVObject.h" #include "ta_libc.h" #include "STDDEVDialog.h" #include "Util.h" #include <QtDebug> STDDEVObject::STDDEVObject (QString profile, QString name) { TA_RetCode rc = TA_Initialize(); if (rc != TA_SUCCESS) qDebug() << "STDDEVObject::STDDEVObject: error on TA_Initialize"; _profile = profile; _name = name; _plugin = QString("STDDEV"); _type = QString("indicator"); _outputKey = QString("v"); _hasOutput = TRUE; _inputObject = QString("symbol"); _inputKey = QString("C"); _period = 14; _dev = 2.0; _commandList << QString("update"); _commandList << QString("dialog"); _commandList << QString("output"); _commandList << QString("load"); _commandList << QString("save"); _commandList << QString("output_keys"); } STDDEVObject::~STDDEVObject () { clear(); } void STDDEVObject::clear () { qDeleteAll(_bars); _bars.clear(); } int STDDEVObject::message (ObjectCommand *oc) { int rc = 0; switch (_commandList.indexOf(oc->command())) { case 0: rc = update(oc); break; case 1: rc = dialog(oc); break; case 2: rc = output(oc); break; case 3: rc = load(oc); break; case 4: rc = save(oc); break; case 5: rc = outputKeys(oc); break; default: break; } return rc; } int STDDEVObject::update (ObjectCommand *oc) { clear(); // input object Object *io = (Object *) oc->getObject(_inputObject); if (! io) { qDebug() << "STDDEVObject::update: invalid input" << _inputObject; return 0; } // get input bars ObjectCommand toc(QString("output")); if (! io->message(&toc)) { qDebug() << "STDDEVObject::update: message error" << io->plugin() << toc.command(); return 0; } QMap<int, Data *> data = toc.map(); int size = data.size(); TA_Real input[size]; TA_Real out[size]; TA_Integer outBeg; TA_Integer outNb; int dpos = 0; QMapIterator<int, Data *> it(data); while (it.hasNext()) { it.next(); Data *d = it.value(); if (d->contains(_inputKey)) input[dpos++] = (TA_Real) d->value(_inputKey).toDouble(); } TA_RetCode rc = TA_STDDEV(0, dpos - 1, &input[0], _period, _dev, &outBeg, &outNb, &out[0]); if (rc != TA_SUCCESS) { qDebug() << "STDDEVObject::update: TA-Lib error" << rc; return 0; } int outLoop = outNb - 1; it.toBack(); while (it.hasPrevious() && outLoop > -1) { it.previous(); Data *b = new Data; b->insert(_outputKey, out[outLoop--]); _bars.insert(it.key(), b); } return 1; } int STDDEVObject::dialog (ObjectCommand *oc) { STDDEVDialog *dialog = new STDDEVDialog(oc->getObjects(), _name); dialog->setSettings(_inputObject, _inputKey, _period, _dev); connect(dialog, SIGNAL(signalDone(void *)), this, SLOT(dialogDone(void *))); dialog->setModified(FALSE); dialog->show(); return 1; } void STDDEVObject::dialogDone (void *dialog) { STDDEVDialog *d = (STDDEVDialog *) dialog; d->settings(_inputObject, _inputKey, _period, _dev); ObjectCommand oc(QString("modified")); emit signalMessage(oc); } int STDDEVObject::outputKeys (ObjectCommand *oc) { QStringList keys; keys << _outputKey; oc->setValue(QString("output_keys"), keys); return 1; } int STDDEVObject::output (ObjectCommand *oc) { outputKeys(oc); oc->setMap(_bars); return 1; } int STDDEVObject::load (ObjectCommand *oc) { QSettings *settings = (QSettings *) oc->getObject(QString("QSettings")); if (! settings) { qDebug() << "STDDEVObject::load: invalid QSettings"; return 0; } _inputObject = settings->value(QString("input_object")).toString(); _inputKey = settings->value(QString("input_key")).toString(); _period = settings->value(QString("period")).toInt(); _dev = settings->value(QString("dev")).toDouble(); return 1; } int STDDEVObject::save (ObjectCommand *oc) { QSettings *settings = (QSettings *) oc->getObject(QString("QSettings")); if (! settings) { qDebug() << "STDDEVObject::save: invalid QSettings"; return 0; } settings->setValue(QString("plugin"), _plugin); settings->setValue(QString("input_object"), _inputObject); settings->setValue(QString("input_key"), _inputKey); settings->setValue(QString("period"), _period); settings->setValue(QString("dev"), _dev); return 1; } --- NEW FILE: STDDEV.h --- /* * Qtstalker stock charter * * Copyright (C) 2001-2007 Stefan S. Stratigakos * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. */ #ifndef PLUGIN_STDDEV_H #define PLUGIN_STDDEV_H #include "Plugin.h" class STDDEV : public QObject, public Plugin { Q_OBJECT Q_INTERFACES(Plugin) public: STDDEV (); int command (PluginCommand *); protected: QStringList _commandList; }; #endif |
Update of /cvsroot/qtstalker/qtstalker/plugins/ROC In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv9477/qtstalker/plugins/ROC Modified Files: ROC.cpp ROC.h ROC.pro ROCDialog.cpp ROCDialog.h ROCType.h Added Files: ROCObject.cpp ROCObject.h Log Message: Index: ROCDialog.h =================================================================== RCS file: /cvsroot/qtstalker/qtstalker/plugins/ROC/ROCDialog.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ROCDialog.h 25 Jun 2012 22:28:02 -0000 1.1 --- ROCDialog.h 15 Feb 2013 04:37:09 -0000 1.2 *************** *** 23,78 **** #define PLUGIN_ROC_DIALOG_HPP ! #include <QDialog> ! #include <QPushButton> ! #include <QDialogButtonBox> ! #include <QStringList> ! #include <QTabWidget> ! #include <QComboBox> ! #include <QLineEdit> ! #include <QSpinBox> ! #include <QCheckBox> ! #include "Entity.h" ! #include "ColorButton.h" ! class ROCDialog : public QDialog { Q_OBJECT ! public: ! ROCDialog (QWidget *); ! void setGUI (Entity *); ! public slots: void done (); - void cancel (); - void help (); void loadSettings (); void saveSettings (); ! void modified (); ! void save (); ! protected: - Entity *_settings; - QTabWidget *_tabs; - QDialogButtonBox *_buttonBox; - QPushButton *_okButton; - QPushButton *_cancelButton; - QString _helpFile; - int _modified; - - ColorButton *_upColor; - ColorButton *_downColor; - QSpinBox *_period; - QComboBox *_input; QComboBox *_method; ! QCheckBox *_rocShow; ! ! QSpinBox *_maWidth; ! ColorButton *_maColor; ! QSpinBox *_maPeriod; ! QComboBox *_maStyle; ! QComboBox *_maType; ! QCheckBox *_maShow; }; --- 23,51 ---- #define PLUGIN_ROC_DIALOG_HPP ! #include <QtGui> ! #include "Dialog.h" ! #include "InputObjectWidget.h" ! class ROCDialog : public Dialog { Q_OBJECT ! public: ! ROCDialog (QHash<QString, void *> objects, QString name); ! ~ROCDialog (); ! void createTab (QHash<QString, void *>); ! void setSettings(QString i, QString ik, QString m, int p); ! void settings(QString &i, QString &ik, QString &m, int &p); ! public slots: void done (); void loadSettings (); void saveSettings (); ! protected: QComboBox *_method; ! InputObjectWidget *_input; ! QSpinBox *_period; }; Index: ROC.pro =================================================================== RCS file: /cvsroot/qtstalker/qtstalker/plugins/ROC/ROC.pro,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ROC.pro 25 Jun 2012 22:28:02 -0000 1.1 --- ROC.pro 15 Feb 2013 04:37:09 -0000 1.2 *************** *** 1,21 **** TEMPLATE = lib CONFIG += plugin - INCLUDEPATH += ../../lib - LIBS += -L../../lib -lOTA MOC_DIR += build OBJECTS_DIR += build HEADERS += ROC.h SOURCES += ROC.cpp HEADERS += ROCDialog.h SOURCES += ROCDialog.cpp HEADERS += ROCType.h SOURCES += ROCType.cpp ! target.path = /usr/local/lib/OTA/plugins INSTALLS += target QT += core QT += gui - QT += sql - QT += network --- 1,35 ---- TEMPLATE = lib CONFIG += plugin MOC_DIR += build OBJECTS_DIR += build + INCLUDEPATH += ../../src + HEADERS += ROC.h SOURCES += ROC.cpp + HEADERS += ROCObject.h + SOURCES += ROCObject.cpp HEADERS += ROCDialog.h SOURCES += ROCDialog.cpp HEADERS += ROCType.h SOURCES += ROCType.cpp + HEADERS += ../../src/Object.h + SOURCES += ../../src/Object.cpp + HEADERS += ../../src/Util.h + SOURCES += ../../src/Util.cpp + HEADERS += ../../src/Plugin.h + HEADERS += ../../src/PluginCommand.h + HEADERS += ../../src/ObjectCommand.h + SOURCES += ../../src/ObjectCommand.cpp + SOURCES += ../../src/Dialog.cpp + HEADERS += ../../src/Dialog.h + SOURCES += ../../src/InputObjectWidget.cpp + HEADERS += ../../src/InputObjectWidget.h ! ! HOME=$$system(echo $HOME) ! target.path = $${HOME}/OTA/lib INSTALLS += target QT += core QT += gui Index: ROC.cpp =================================================================== RCS file: /cvsroot/qtstalker/qtstalker/plugins/ROC/ROC.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ROC.cpp 25 Jun 2012 22:28:02 -0000 1.1 --- ROC.cpp 15 Feb 2013 04:37:08 -0000 1.2 *************** *** 20,57 **** */ - #include <QtGui> - #include "ta_libc.h" #include "ROC.h" ! #include "MAType.h" ! #include "BarType.h" ! #include "CurveLineType.h" ! #include "CurveHistogramType.h" ! #include "Global.h" ! #include "ROCDialog.h" ! #include "ROCType.h" int ! ROC::command (PluginData *pd) { int rc = 0; ! QStringList cl; ! cl << "type" << "dialog" << "runIndicator" << "settings"; ! ! switch (cl.indexOf(pd->command)) { case 0: // type ! pd->type = QString("indicator"); rc = 1; break; ! case 1: // dialog ! rc = dialog(pd); ! break; ! case 2: // runIndicator ! rc = run(pd); ! break; ! case 3: // settings ! rc = settings(pd); break; default: --- 20,47 ---- */ #include "ROC.h" ! #include "ROCObject.h" ! + ROC::ROC () + { + _commandList << QString("type"); + _commandList << QString("object"); + } int ! ROC::command (PluginCommand *pc) { int rc = 0; ! switch (_commandList.indexOf(pc->command)) { case 0: // type ! pc->type = QString("indicator"); rc = 1; break; ! case 1: // object ! pc->object = new ROCObject(pc->profile, pc->name); ! rc = 1; break; default: *************** *** 62,372 **** } - int - ROC::dialog (PluginData *pd) - { - if (! pd->dialogParent) - { - qDebug() << "ROC::dialog: invalid parent"; - return 0; - } - - if (! pd->settings) - { - qDebug() << "ROC::dialog: invalid settings"; - return 0; - } - - ROCDialog *dialog = new ROCDialog(pd->dialogParent); - dialog->setGUI(pd->settings); - pd->dialog = dialog; - - return 1; - } - - int - ROC::run (PluginData *pd) - { - if (! g_symbol) - return 0; - - QVariant *input = pd->settings->get(QString("input")); - if (! input) - return 0; - - QVariant *var = pd->settings->get(QString("method")); - if (! var) - return 0; - ROCType rt; - int method = rt.stringToIndex(var->toString()); - if (method == -1) - 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 (! getROC(input->toString(), method, period->toInt(), label->toString())) - return 0; - - // roc - QVariant *show = pd->settings->get(QString("rocShow")); - if (! show) - return 0; - - if (show->toBool()) - { - QVariant *var = pd->settings->get(QString("upColor")); - if (! var) - return 0; - QColor uc(var->toString()); - - var = pd->settings->get(QString("downColor")); - if (! var) - return 0; - QColor dc(var->toString()); - - Curve *hl = new Curve(QString("CurveHistogram")); - hl->setColor(uc); - hl->setLabel(label->toString()); - hl->setStyle(CurveHistogramType::_BAR); - hl->fill(label->toString(), QString(), QString(), QString(), uc); - pd->curves << hl; - - // color down bars - QList<int> keys = g_symbol->keys(); - - for (int pos = 0; pos < keys.size(); pos++) - { - Bar *bar = hl->bar(keys.at(pos)); - if (! bar) - continue; - - if (bar->value() < bar->base()) - bar->setColor(dc); - } - } - - // ma - show = pd->settings->get(QString("maShow")); - if (! show) - return 0; - - if (show->toBool()) - { - Curve *ma = getMA(pd->settings); - if (ma) - pd->curves << ma; - } - - return 1; - } - - Curve * - ROC::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 *momLabel = settings->get(QString("label")); - if (! momLabel) - return 0; - - if (! getMA(momLabel->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 - ROC::getROC (QString ikey, int method, int period, QString okey) - { - if (! g_symbol) - return 0; - - TA_RetCode rc = TA_Initialize(); - if (rc != TA_SUCCESS) - qDebug() << "ROC::ROC: error on TA_Initialize"; - - QList<int> keys = g_symbol->keys(); - - int size = keys.size(); - TA_Real input[size]; - TA_Real out[size]; - TA_Integer outBeg; - TA_Integer outNb; - - int dpos = 0; - for (int kpos = 0; kpos < keys.size(); kpos++) - { - CBar *bar = g_symbol->bar(keys.at(kpos)); - - double v; - if (! bar->get(ikey, v)) - continue; - - input[dpos++] = (TA_Real) v; - } - - switch ((ROCType::Key) method) - { - case ROCType::_ROC: - rc = TA_ROC (0, dpos - 1, &input[0], period, &outBeg, &outNb, &out[0]); - break; - case ROCType::_ROCP: - rc = TA_ROCP (0, dpos - 1, &input[0], period, &outBeg, &outNb, &out[0]); - break; - case ROCType::_ROCR: - rc = TA_ROCR (0, dpos - 1, &input[0], period, &outBeg, &outNb, &out[0]); - break; - case ROCType::_ROCR100: - rc = TA_ROCR100 (0, dpos - 1, &input[0], period, &outBeg, &outNb, &out[0]); - break; - default: - break; - } - - if (rc != TA_SUCCESS) - { - qDebug() << "ROC::getROC: TA-Lib error" << rc; - return 0; - } - - int keyLoop = keys.size() - 1; - int outLoop = outNb - 1; - while (keyLoop > -1 && outLoop > -1) - { - CBar *bar = g_symbol->bar(keys.at(keyLoop)); - bar->set(okey, out[outLoop]); - keyLoop--; - outLoop--; - } - - return 1; - } - - int - ROC::getMA (QString inKey, QString outKey, int type, int period) - { - if (! g_symbol) - return 0; - - TA_RetCode rc = TA_Initialize(); - if (rc != TA_SUCCESS) - qDebug() << "ROC::getMA: error on TA_Initialize"; - - QList<int> keys = g_symbol->keys(); - - int size = keys.size(); - TA_Real input[size]; - TA_Real out[size]; - TA_Integer outBeg; - TA_Integer outNb; - - int dpos = 0; - for (int kpos = 0; kpos < keys.size(); kpos++) - { - CBar *bar = g_symbol->bar(keys.at(kpos)); - - double v; - if (! bar->get(inKey, v)) - continue; - - input[dpos++] = (TA_Real) v; - } - - rc = TA_MA(0, dpos - 1, &input[0], period, (TA_MAType) type, &outBeg, &outNb, &out[0]); - if (rc != TA_SUCCESS) - { - qDebug() << "ROC::getMA: TA-Lib error" << rc; - return 0; - } - - int keyLoop = keys.size() - 1; - int outLoop = outNb - 1; - while (keyLoop > -1 && outLoop > -1) - { - CBar *bar = g_symbol->bar(keys.at(keyLoop)); - bar->set(outKey, out[outLoop]); - keyLoop--; - outLoop--; - } - - return 1; - } - - int - ROC::settings (PluginData *pd) - { - Entity *command = new Entity; - BarType bt; - MAType mat; - CurveLineType clt; - ROCType rt; - - command->set(QString("plugin"), new QVariant(QString("ROC"))); - command->set(QString("type"), new QVariant(QString("indicator"))); - - command->set(QString("input"), new QVariant(bt.indexToString(BarType::_CLOSE))); - command->set(QString("upColor"), new QVariant(QString("green"))); - command->set(QString("downColor"), new QVariant(QString("red"))); - command->set(QString("period"), new QVariant(14)); - command->set(QString("label"), new QVariant(QString("ROC"))); - command->set(QString("method"), new QVariant(rt.indexToString(ROCType::_ROC))); - command->set(QString("rocShow"), new QVariant(TRUE)); - - command->set(QString("maType"), new QVariant(mat.indexToString(MAType::_EMA))); - command->set(QString("maStyle"), new QVariant(clt.indexToString(CurveLineType::_SOLID))); - command->set(QString("maWidth"), new QVariant(1)); - command->set(QString("maColor"), new QVariant(QString("yellow"))); - command->set(QString("maPeriod"), new QVariant(10)); - command->set(QString("maLabel"), new QVariant(QString("MA"))); - command->set(QString("maShow"), new QVariant(TRUE)); - - pd->settings = command; - - return 1; - } - - int - ROC::draw (QPainter *, const QwtScaleMap &, const QwtScaleMap &, const QRect &, void *) - { - return 0; - } - - // do not remove ! Q_EXPORT_PLUGIN2(roc, ROC); --- 52,55 ---- } // do not remove ! Q_EXPORT_PLUGIN2(ROC, ROC); Index: ROC.h =================================================================== RCS file: /cvsroot/qtstalker/qtstalker/plugins/ROC/ROC.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ROC.h 25 Jun 2012 22:28:02 -0000 1.1 --- ROC.h 15 Feb 2013 04:37:09 -0000 1.2 *************** *** 24,29 **** #define PLUGIN_ROC_H - #include <QObject> - #include "Plugin.h" --- 24,27 ---- *************** *** 34,45 **** public: ! int draw (QPainter *, const QwtScaleMap &, const QwtScaleMap &, const QRect &, void *); ! int command (PluginData *); ! Curve * getMA (Entity *settings); ! int settings (PluginData *); ! int dialog (PluginData *); ! int run (PluginData *); ! int getROC (QString ikey, int method, int period, QString okey); ! int getMA (QString inKey, QString outKey, int type, int period); }; --- 32,40 ---- public: ! ROC (); ! int command (PluginCommand *); ! ! protected: ! QStringList _commandList; }; --- NEW FILE: ROCObject.h --- /* * Qtstalker stock charter * * Copyright (C) 2001-2010 Stefan S. Stratigakos * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. */ #ifndef PLUGIN_ROC_OBJECT_HPP #define PLUGIN_ROC_OBJECT_HPP #include <QStringList> #include <QMap> #include "Object.h" #include "ROCDialog.h" class ROCObject : public Object { Q_OBJECT public: ROCObject (QString profile, QString name); ~ROCObject (); void clear (); int update (ObjectCommand *); int dialog (ObjectCommand *); int output (ObjectCommand *); int load (ObjectCommand *); int save (ObjectCommand *); int outputKeys (ObjectCommand *); public slots: int message (ObjectCommand *); void dialogDone (void *); private: QStringList _commandList; QMap<int, Data *> _bars; QString _inputObject; QString _inputKey; QString _outputKey; QString _method; int _period; }; #endif Index: ROCDialog.cpp =================================================================== RCS file: /cvsroot/qtstalker/qtstalker/plugins/ROC/ROCDialog.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ROCDialog.cpp 25 Jun 2012 22:28:02 -0000 1.1 --- ROCDialog.cpp 15 Feb 2013 04:37:09 -0000 1.2 *************** *** 21,286 **** #include "ROCDialog.h" ! #include "Doc.h" ! #include "Global.h" ! #include "MAType.h" ! #include "CurveLineType.h" ! #include "CurveHistogramType.h" ! #include "BarType.h" #include "ROCType.h" ! #include <QtDebug> ! #include <QVariant> ! #include <QLayout> ! #include <QFormLayout> ! ! ! ROCDialog::ROCDialog (QWidget *p) : QDialog (p) { ! _settings = 0; ! _modified = 0; ! _helpFile = "main.html"; ! connect(this, SIGNAL(finished(int)), this, SLOT(deleteLater())); ! ! // main vbox ! QVBoxLayout *vbox = new QVBoxLayout; ! vbox->setSpacing(2); ! vbox->setMargin(5); ! setLayout(vbox); ! _tabs = new QTabWidget; ! vbox->addWidget(_tabs); ! ! // buttonbox ! _buttonBox = new QDialogButtonBox(QDialogButtonBox::Help); ! connect(_buttonBox, SIGNAL(accepted()), this, SLOT(done())); ! connect(_buttonBox, SIGNAL(rejected()), this, SLOT(cancel())); ! vbox->addWidget(_buttonBox); ! ! // ok button ! _okButton = _buttonBox->addButton(QDialogButtonBox::Ok); ! _okButton->setText(tr("&OK")); ! ! // cancel button ! _cancelButton = _buttonBox->addButton(QDialogButtonBox::Cancel); ! _cancelButton->setText(tr("&Cancel")); ! _cancelButton->setDefault(TRUE); ! _cancelButton->setFocus(); ! ! // help button ! QPushButton *b = _buttonBox->button(QDialogButtonBox::Help); ! b->setText(tr("&Help")); ! connect(b, SIGNAL(clicked()), this, SLOT(help())); ! } ! ! void ROCDialog::done () ! { ! saveSettings(); ! save(); ! accept(); ! } ! ! void ROCDialog::help () ! { ! Doc *doc = new Doc; ! doc->showDocumentation(_helpFile); } ! void ROCDialog::cancel () { saveSettings(); - reject(); - } - - void ROCDialog::loadSettings () - { - QSettings settings(g_settings); - settings.beginGroup(g_session); - - QSize sz = settings.value("roc_dialog_size", QSize(200,200)).toSize(); - resize(sz); - - // restore the position of the app - QPoint p = settings.value("roc_dialog_pos").toPoint(); - if (! p.isNull()) - move(p); - } - - void ROCDialog::saveSettings () - { - QSettings settings(g_settings); - settings.beginGroup(g_session); - settings.setValue("roc_dialog_size", size()); - settings.setValue("roc_dialog_pos", pos()); } ! void ROCDialog::setGUI (Entity *settings) { ! _settings = settings; - // ROC page QWidget *w = new QWidget; QFormLayout *form = new QFormLayout; w->setLayout(form); ! ! // up color ! QVariant *set = _settings->get(QString("upColor")); ! ! _upColor = new ColorButton(this, QColor(set->toString())); ! connect(_upColor, SIGNAL(valueChanged(QColor)), this, SLOT(modified())); ! form->addRow(tr("Up Color"), _upColor); ! ! // down color ! set = _settings->get(QString("downColor")); ! ! _downColor = new ColorButton(this, QColor(set->toString())); ! connect(_downColor, SIGNAL(valueChanged(QColor)), this, SLOT(modified())); ! form->addRow(tr("Down Color"), _downColor); // method - set = _settings->get(QString("method")); - ROCType rt; _method = new QComboBox; _method->addItems(rt.list()); - _method->setCurrentIndex(_method->findText(set->toString(), Qt::MatchExactly)); connect(_method, SIGNAL(currentIndexChanged(int)), this, SLOT(modified())); form->addRow(tr("Method"), _method); - // input - set = _settings->get(QString("input")); - - BarType bt; - _input = new QComboBox; - _input->addItems(bt.list()); - _input->setCurrentIndex(_input->findText(set->toString(), Qt::MatchExactly)); - connect(_input, SIGNAL(currentIndexChanged(int)), this, SLOT(modified())); - form->addRow(tr("Input"), _input); - // period - set = _settings->get(QString("period")); - _period = new QSpinBox; _period->setRange(1, 999999); ! _period->setValue(set->toInt()); ! connect(_period, SIGNAL(valueChanged(const QString &)), this, SLOT(modified())); form->addRow(tr("Period"), _period); ! // show ! set = _settings->get(QString("rocShow")); ! ! _rocShow = new QCheckBox; ! _rocShow->setChecked(set->toBool()); ! connect(_rocShow, SIGNAL(toggled(bool)), this, SLOT(modified())); ! form->addRow(tr("Show"), _rocShow); ! ! _tabs->addTab(w, QString("ROC")); ! ! // MA page ! w = new QWidget; ! ! form = new QFormLayout; ! w->setLayout(form); ! ! // type ! set = _settings->get(QString("maType")); ! ! MAType mat; ! _maType = new QComboBox; ! _maType->addItems(mat.list()); ! _maType->setCurrentIndex(_maType->findText(set->toString(), Qt::MatchExactly)); ! connect(_maType, SIGNAL(currentIndexChanged(int)), this, SLOT(modified())); ! form->addRow(tr("Type"), _maType); ! ! // style ! set = _settings->get(QString("maStyle")); ! ! CurveLineType clt; ! _maStyle = new QComboBox; ! _maStyle->addItems(clt.list()); ! _maStyle->setCurrentIndex(_maStyle->findText(set->toString(), Qt::MatchExactly)); ! connect(_maStyle, SIGNAL(currentIndexChanged(int)), this, SLOT(modified())); ! form->addRow(tr("Style"), _maStyle); ! ! // width ! set = _settings->get(QString("maWidth")); ! ! _maWidth = new QSpinBox; ! _maWidth->setRange(1, 99); ! _maWidth->setValue(set->toInt()); ! connect(_maWidth, SIGNAL(valueChanged(const QString &)), this, SLOT(modified())); ! form->addRow(tr("Width"), _maWidth); ! ! // color ! set = _settings->get(QString("maColor")); ! ! _maColor = new ColorButton(this, QColor(set->toString())); ! connect(_maColor, SIGNAL(valueChanged(QColor)), this, SLOT(modified())); ! form->addRow(tr("Color"), _maColor); ! ! // period ! set = _settings->get(QString("maPeriod")); ! ! _maPeriod = new QSpinBox; ! _maPeriod->setRange(1, 999999); ! _maPeriod->setValue(set->toInt()); ! connect(_maPeriod, SIGNAL(valueChanged(const QString &)), this, SLOT(modified())); ! form->addRow(tr("Period"), _maPeriod); ! ! // show ! set = _settings->get(QString("maShow")); ! ! _maShow = new QCheckBox; ! _maShow->setChecked(set->toBool()); ! connect(_maShow, SIGNAL(toggled(bool)), this, SLOT(modified())); ! form->addRow(tr("Show"), _maShow); ! ! _tabs->addTab(w, QString("MA")); } ! void ROCDialog::save () { ! if (! _modified) ! return; ! ! QVariant *set = _settings->get(QString("upColor")); ! set->setValue(_upColor->color().name()); ! ! set = _settings->get(QString("downColor")); ! set->setValue(_downColor->color().name()); ! ! set = _settings->get(QString("period")); ! set->setValue(_period->value()); ! ! set = _settings->get(QString("input")); ! set->setValue(_input->currentText()); ! ! set = _settings->get(QString("method")); ! set->setValue(_method->currentText()); ! ! set = _settings->get(QString("rocShow")); ! set->setValue(_rocShow->isChecked()); ! ! set = _settings->get(QString("maType")); ! set->setValue(_maType->currentText()); ! ! set = _settings->get(QString("maStyle")); ! set->setValue(_maStyle->currentText()); ! ! set = _settings->get(QString("maWidth")); ! set->setValue(_maWidth->value()); ! set = _settings->get(QString("maColor")); ! set->setValue(_maColor->color().name()); ! set = _settings->get(QString("maPeriod")); ! set->setValue(_maPeriod->value()); ! set = _settings->get(QString("maShow")); ! set->setValue(_maShow->isChecked()); } ! void ROCDialog::modified () { ! _modified = 1; } --- 21,120 ---- #include "ROCDialog.h" ! #include "Util.h" #include "ROCType.h" ! ROCDialog::ROCDialog (QHash<QString, void *> objects, QString name) : Dialog (0, name) { ! QStringList tl; ! QDir dir(QDir::homePath()); ! tl << dir.absolutePath() << QString("OTA") << QString("ROC") << QString("settings") << QString("dialog"); ! _settingsPath = tl.join("/"); ! createTab(objects); ! loadSettings(); } ! ROCDialog::~ROCDialog () { saveSettings(); } ! void ! ROCDialog::createTab (QHash<QString, void *> l) { ! QHash<QString, void *> ol; ! QHashIterator<QString, void *> it(l); ! while (it.hasNext()) ! { ! it.next(); ! Object *o = (Object *) it.value(); ! if (o->hasOutput()) ! ol.insert(it.key(), it.value()); ! } QWidget *w = new QWidget; QFormLayout *form = new QFormLayout; + form->setSpacing(2); + form->setMargin(10); w->setLayout(form); ! ! _input = new InputObjectWidget; ! _input->setObjects(ol); ! connect(_input, SIGNAL(valueChanged()), this, SLOT(modified())); ! form->addRow(tr("Input"), _input); // method ROCType rt; _method = new QComboBox; _method->addItems(rt.list()); connect(_method, SIGNAL(currentIndexChanged(int)), this, SLOT(modified())); form->addRow(tr("Method"), _method); // period _period = new QSpinBox; _period->setRange(1, 999999); ! connect(_period, SIGNAL(valueChanged(int)), this, SLOT(modified())); form->addRow(tr("Period"), _period); ! _tabs->addTab(w, tr("Settings")); } ! void ! ROCDialog::done () { ! emit signalDone((void *) this); ! Dialog::done(); ! } ! void ! ROCDialog::loadSettings () ! { ! QSettings settings(_settingsPath, QSettings::NativeFormat); ! Dialog::loadSettings(settings); ! } ! void ! ROCDialog::saveSettings() ! { ! QSettings settings(_settingsPath, QSettings::NativeFormat); ! Dialog::saveSettings(settings); ! } ! void ! ROCDialog::setSettings (QString i, QString ik, QString m, int p) ! { ! _input->setInput(i); ! _input->setKey(tr("Input"), ik); ! _method->setCurrentIndex(_method->findText(m)); ! _period->setValue(p); } ! void ! ROCDialog::settings (QString &i, QString &ik, QString &m, int &p) { ! i = _input->input(); ! ik = _input->key(tr("Input")); ! m = _method->currentText(); ! p = _period->value(); } Index: ROCType.h =================================================================== RCS file: /cvsroot/qtstalker/qtstalker/plugins/ROC/ROCType.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ROCType.h 25 Jun 2012 22:28:03 -0000 1.1 --- ROCType.h 15 Feb 2013 04:37:09 -0000 1.2 *************** *** 23,28 **** // ************************************************************************************************* ! #ifndef PLUGIN_ROC_TYPE_HPP ! #define PLUGIN_ROC_TYPE_HPP #include <QStringList> --- 23,28 ---- // ************************************************************************************************* ! #ifndef PLUGIN_ROC_ROC_TYPE_HPP ! #define PLUGIN_ROC_ROC_TYPE_HPP #include <QStringList> --- NEW FILE: ROCObject.cpp --- /* * Qtstalker stock charter * * Copyright (C) 2001-2010 Stefan S. Stratigakos * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. */ #include "ROCObject.h" #include "ta_libc.h" #include "ROCDialog.h" #include "Util.h" #include "ROCType.h" #include <QtDebug> ROCObject::ROCObject (QString profile, QString name) { TA_RetCode rc = TA_Initialize(); if (rc != TA_SUCCESS) qDebug() << "ROCObject::ROCObject: error on TA_Initialize"; _profile = profile; _name = name; _plugin = QString("ROC"); _type = QString("indicator"); _method = QString("ROC"); _period = 14; _outputKey = QString("v"); _hasOutput = TRUE; _inputObject = QString("symbol"); _inputKey = QString("C"); _commandList << QString("update"); _commandList << QString("dialog"); _commandList << QString("output"); _commandList << QString("load"); _commandList << QString("save"); _commandList << QString("output_keys"); } ROCObject::~ROCObject () { clear(); } void ROCObject::clear () { qDeleteAll(_bars); _bars.clear(); } int ROCObject::message (ObjectCommand *oc) { int rc = 0; switch (_commandList.indexOf(oc->command())) { case 0: rc = update(oc); break; case 1: rc = dialog(oc); break; case 2: rc = output(oc); break; case 3: rc = load(oc); break; case 4: rc = save(oc); break; case 5: rc = outputKeys(oc); break; default: break; } return rc; } int ROCObject::update (ObjectCommand *oc) { clear(); // input object Object *io = (Object *) oc->getObject(_inputObject); if (! io) { qDebug() << "ROCObject::update: invalid input" << _inputObject; return 0; } // get input bars ObjectCommand toc(QString("output")); if (! io->message(&toc)) { qDebug() << "ROCObject::update: message error" << io->plugin() << toc.command(); return 0; } QMap<int, Data *> data = toc.map(); int size = data.size(); TA_Real input[size]; TA_Real out[size]; TA_Integer outBeg; TA_Integer outNb; int dpos = 0; QMapIterator<int, Data *> it(data); while (it.hasNext()) { it.next(); Data *d = it.value(); if (d->contains(_inputKey)) input[dpos++] = (TA_Real) d->value(_inputKey).toDouble(); } TA_RetCode rc = TA_SUCCESS; ROCType rt; switch ((ROCType::Key) rt.stringToIndex(_method)) { case ROCType::_ROC: rc = TA_ROC (0, dpos - 1, &input[0], _period, &outBeg, &outNb, &out[0]); break; case ROCType::_ROCP: rc = TA_ROCP (0, dpos - 1, &input[0], _period, &outBeg, &outNb, &out[0]); break; case ROCType::_ROCR: rc = TA_ROCR (0, dpos - 1, &input[0], _period, &outBeg, &outNb, &out[0]); break; case ROCType::_ROCR100: rc = TA_ROCR100 (0, dpos - 1, &input[0], _period, &outBeg, &outNb, &out[0]); break; default: break; } if (rc != TA_SUCCESS) { qDebug() << "ROCObject::getROC: TA-Lib error" << rc; return 0; } int outLoop = outNb - 1; it.toBack(); while (it.hasPrevious() && outLoop > -1) { it.previous(); Data *b = new Data; b->insert(_outputKey, out[outLoop--]); _bars.insert(it.key(), b); } return 1; } int ROCObject::dialog (ObjectCommand *oc) { ROCDialog *dialog = new ROCDialog(oc->getObjects(), _name); dialog->setSettings(_inputObject, _inputKey, _method, _period); connect(dialog, SIGNAL(signalDone(void *)), this, SLOT(dialogDone(void *))); dialog->setModified(FALSE); dialog->show(); return 1; } void ROCObject::dialogDone (void *dialog) { ROCDialog *d = (ROCDialog *) dialog; d->settings(_inputObject, _inputKey, _method, _period); ObjectCommand oc(QString("modified")); emit signalMessage(oc); } int ROCObject::outputKeys (ObjectCommand *oc) { QStringList keys; keys << _outputKey; oc->setValue(QString("output_keys"), keys); return 1; } int ROCObject::output (ObjectCommand *oc) { outputKeys(oc); oc->setMap(_bars); return 1; } int ROCObject::load (ObjectCommand *oc) { QSettings *settings = (QSettings *) oc->getObject(QString("QSettings")); if (! settings) { qDebug() << "ROCObject::load: invalid QSettings"; return 0; } _inputObject = settings->value(QString("input_object")).toString(); _inputKey = settings->value(QString("input_key")).toString(); _method = settings->value(QString("method")).toString(); _period = settings->value(QString("period")).toInt(); return 1; } int ROCObject::save (ObjectCommand *oc) { QSettings *settings = (QSettings *) oc->getObject(QString("QSettings")); if (! settings) { qDebug() << "ROCObject::save: invalid QSettings"; return 0; } settings->setValue(QString("plugin"), _plugin); settings->setValue(QString("input_object"), _inputObject); settings->setValue(QString("input_key"), _inputKey); settings->setValue(QString("method"), _method); settings->setValue(QString("period"), _period); return 1; } |
Update of /cvsroot/qtstalker/qtstalker/plugins/PDI In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv9477/qtstalker/plugins/PDI Added Files: .cvsignore PDI.cpp PDI.h PDI.pro PDIDialog.cpp PDIDialog.h PDIObject.cpp PDIObject.h Log Message: --- NEW FILE: PDIObject.cpp --- /* * Qtstalker stock charter * * Copyright (C) 2001-2010 Stefan S. Stratigakos * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. */ #include "PDIObject.h" #include "ta_libc.h" #include "PDIDialog.h" #include "Util.h" #include <QtDebug> PDIObject::PDIObject (QString profile, QString name) { TA_RetCode rc = TA_Initialize(); if (rc != TA_SUCCESS) qDebug() << "PDIObject::PDIObject: error on TA_Initialize"; _profile = profile; _name = name; _plugin = QString("PDI"); _type = QString("indicator"); _period = 14; _outputKey = QString("v"); _hasOutput = TRUE; _inputObject = QString("symbol"); _highKey = QString("H"); _lowKey = QString("L"); _closeKey = QString("C"); _commandList << QString("update"); _commandList << QString("dialog"); _commandList << QString("output"); _commandList << QString("load"); _commandList << QString("save"); _commandList << QString("output_keys"); } PDIObject::~PDIObject () { clear(); } void PDIObject::clear () { qDeleteAll(_bars); _bars.clear(); } int PDIObject::message (ObjectCommand *oc) { int rc = 0; switch (_commandList.indexOf(oc->command())) { case 0: rc = update(oc); break; case 1: rc = dialog(oc); break; case 2: rc = output(oc); break; case 3: rc = load(oc); break; case 4: rc = save(oc); break; case 5: rc = outputKeys(oc); break; default: break; } return rc; } int PDIObject::update (ObjectCommand *oc) { clear(); // input object Object *io = (Object *) oc->getObject(_inputObject); if (! io) { qDebug() << "PDIObject::update: invalid input" << _inputObject; return 0; } // get input bars ObjectCommand toc(QString("output")); if (! io->message(&toc)) { qDebug() << "PDIObject::update: message error" << io->plugin() << toc.command(); return 0; } QMap<int, Data *> data = toc.map(); int size = data.size(); TA_Real high[size]; TA_Real low[size]; TA_Real close[size]; TA_Real out[size]; TA_Integer outBeg; TA_Integer outNb; int dpos = 0; QMapIterator<int, Data *> it(data); while (it.hasNext()) { it.next(); Data *d = it.value(); if (! d->contains(_highKey)) continue; if (! d->contains(_lowKey)) continue; if (! d->contains(_closeKey)) continue; high[dpos] = (TA_Real) d->value(_highKey).toDouble(); low[dpos] = (TA_Real) d->value(_lowKey).toDouble(); close[dpos++] = (TA_Real) d->value(_closeKey).toDouble(); } TA_RetCode rc = TA_PLUS_DI(0, dpos - 1, &high[0], &low[0], &close[0], _period, &outBeg, &outNb, &out[0]); if (rc != TA_SUCCESS) { qDebug() << "PDIObject::update: TA-Lib error" << rc; return 0; } int outLoop = outNb - 1; it.toBack(); while (it.hasPrevious() && outLoop > -1) { it.previous(); Data *b = new Data; b->insert(_outputKey, out[outLoop--]); _bars.insert(it.key(), b); } return 1; } int PDIObject::dialog (ObjectCommand *oc) { PDIDialog *dialog = new PDIDialog(oc->getObjects(), _name); dialog->setSettings(_inputObject, _highKey, _lowKey, _closeKey, _period); connect(dialog, SIGNAL(signalDone(void *)), this, SLOT(dialogDone(void *))); dialog->setModified(FALSE); dialog->show(); return 1; } void PDIObject::dialogDone (void *dialog) { PDIDialog *d = (PDIDialog *) dialog; d->settings(_inputObject, _highKey, _lowKey, _closeKey, _period); ObjectCommand oc(QString("modified")); emit signalMessage(oc); } int PDIObject::outputKeys (ObjectCommand *oc) { QStringList keys; keys << _outputKey; oc->setValue(QString("output_keys"), keys); return 1; } int PDIObject::output (ObjectCommand *oc) { outputKeys(oc); oc->setMap(_bars); return 1; } int PDIObject::load (ObjectCommand *oc) { QSettings *settings = (QSettings *) oc->getObject(QString("QSettings")); if (! settings) { qDebug() << "PDIObject::load: invalid QSettings"; return 0; } _inputObject = settings->value(QString("input_object")).toString(); _highKey = settings->value(QString("high_key")).toString(); _lowKey = settings->value(QString("low_key")).toString(); _closeKey = settings->value(QString("close_key")).toString(); _period = settings->value(QString("period")).toInt(); return 1; } int PDIObject::save (ObjectCommand *oc) { QSettings *settings = (QSettings *) oc->getObject(QString("QSettings")); if (! settings) { qDebug() << "PDIObject::save: invalid QSettings"; return 0; } settings->setValue(QString("plugin"), _plugin); settings->setValue(QString("input_object"), _inputObject); settings->setValue(QString("high_key"), _highKey); settings->setValue(QString("low_key"), _lowKey); settings->setValue(QString("close_key"), _closeKey); settings->setValue(QString("period"), _period); return 1; } --- NEW FILE: PDIDialog.cpp --- /* * Qtstalker stock charter * * Copyright (C) 2001-2010 Stefan S. Stratigakos * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. */ #include "PDIDialog.h" #include "Util.h" PDIDialog::PDIDialog (QHash<QString, void *> objects, QString name) : Dialog (0, name) { QStringList tl; QDir dir(QDir::homePath()); tl << dir.absolutePath() << QString("OTA") << QString("PDI") << QString("settings") << QString("dialog"); _settingsPath = tl.join("/"); createTab(objects); loadSettings(); } PDIDialog::~PDIDialog () { saveSettings(); } void PDIDialog::createTab (QHash<QString, void *> l) { QHash<QString, void *> ol; QHashIterator<QString, void *> it(l); while (it.hasNext()) { it.next(); Object *o = (Object *) it.value(); if (o->hasOutput()) ol.insert(it.key(), it.value()); } QWidget *w = new QWidget; QFormLayout *form = new QFormLayout; form->setSpacing(2); form->setMargin(10); w->setLayout(form); _input = new InputObjectWidget; _input->setObjects(ol); connect(_input, SIGNAL(valueChanged()), this, SLOT(modified())); form->addRow(tr("Input"), _input); // period _period = new QSpinBox; _period->setRange(1, 999999); connect(_period, SIGNAL(valueChanged(int)), this, SLOT(modified())); form->addRow(tr("Period"), _period); _tabs->addTab(w, tr("Settings")); } void PDIDialog::done () { emit signalDone((void *) this); Dialog::done(); } void PDIDialog::loadSettings () { QSettings settings(_settingsPath, QSettings::NativeFormat); Dialog::loadSettings(settings); } void PDIDialog::saveSettings() { QSettings settings(_settingsPath, QSettings::NativeFormat); Dialog::saveSettings(settings); } void PDIDialog::setSettings (QString i, QString hk, QString lk, QString ck, int p) { _input->setInput(i); _input->setKey(tr("High"), hk); _input->setKey(tr("Low"), lk); _input->setKey(tr("Close"), ck); _period->setValue(p); } void PDIDialog::settings (QString &i, QString &hk, QString &lk, QString &ck, int &p) { i = _input->input(); hk = _input->key(tr("High")); lk = _input->key(tr("Low")); ck = _input->key(tr("Close")); p = _period->value(); } --- NEW FILE: PDIObject.h --- /* * Qtstalker stock charter * * Copyright (C) 2001-2010 Stefan S. Stratigakos * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. */ #ifndef PLUGIN_PDI_OBJECT_HPP #define PLUGIN_PDI_OBJECT_HPP #include <QStringList> #include <QMap> #include "Object.h" #include "PDIDialog.h" class PDIObject : public Object { Q_OBJECT public: PDIObject (QString profile, QString name); ~PDIObject (); void clear (); int update (ObjectCommand *); int dialog (ObjectCommand *); int output (ObjectCommand *); int load (ObjectCommand *); int save (ObjectCommand *); int outputKeys (ObjectCommand *); public slots: int message (ObjectCommand *); void dialogDone (void *); private: QStringList _commandList; QMap<int, Data *> _bars; QString _inputObject; QString _highKey; QString _lowKey; QString _closeKey; QString _outputKey; int _period; }; #endif --- NEW FILE: PDIDialog.h --- /* * Qtstalker stock charter * * Copyright (C) 2001-2010 Stefan S. Stratigakos * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. */ #ifndef PLUGIN_PDI_DIALOG_HPP #define PLUGIN_PDI_DIALOG_HPP #include <QtGui> #include "Dialog.h" #include "InputObjectWidget.h" class PDIDialog : public Dialog { Q_OBJECT public: PDIDialog (QHash<QString, void *> objects, QString name); ~PDIDialog (); void createTab (QHash<QString, void *>); void setSettings(QString i, QString hk, QString lk, QString ck, int p); void settings(QString &i, QString &hk, QString &lk, QString &ck, int &p); public slots: void done (); void loadSettings (); void saveSettings (); protected: InputObjectWidget *_input; QSpinBox *_period; }; #endif --- NEW FILE: PDI.cpp --- /* * Qtstalker stock charter * * Copyright (C) 2001-2007 Stefan S. Stratigakos * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. */ #include "PDI.h" #include "PDIObject.h" PDI::PDI () { _commandList << QString("type"); _commandList << QString("object"); } int PDI::command (PluginCommand *pc) { int rc = 0; switch (_commandList.indexOf(pc->command)) { case 0: // type pc->type = QString("indicator"); rc = 1; break; case 1: // object pc->object = new PDIObject(pc->profile, pc->name); rc = 1; break; default: break; } return rc; } // do not remove Q_EXPORT_PLUGIN2(PDI, PDI); --- NEW FILE: PDI.pro --- TEMPLATE = lib CONFIG += plugin MOC_DIR += build OBJECTS_DIR += build INCLUDEPATH += ../../src HEADERS += PDI.h SOURCES += PDI.cpp HEADERS += PDIObject.h SOURCES += PDIObject.cpp HEADERS += PDIDialog.h SOURCES += PDIDialog.cpp HEADERS += ../../src/Object.h SOURCES += ../../src/Object.cpp HEADERS += ../../src/Util.h SOURCES += ../../src/Util.cpp HEADERS += ../../src/Plugin.h HEADERS += ../../src/PluginCommand.h HEADERS += ../../src/ObjectCommand.h SOURCES += ../../src/ObjectCommand.cpp SOURCES += ../../src/Dialog.cpp HEADERS += ../../src/Dialog.h SOURCES += ../../src/InputObjectWidget.cpp HEADERS += ../../src/InputObjectWidget.h HOME=$$system(echo $HOME) target.path = $${HOME}/OTA/lib INSTALLS += target QT += core QT += gui --- NEW FILE: .cvsignore --- Makefile moc_*.cpp --- NEW FILE: PDI.h --- /* * Qtstalker stock charter * * Copyright (C) 2001-2007 Stefan S. Stratigakos * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. */ #ifndef PLUGIN_PDI_H #define PLUGIN_PDI_H #include "Plugin.h" class PDI : public QObject, public Plugin { Q_OBJECT Q_INTERFACES(Plugin) public: PDI (); int command (PluginCommand *); protected: QStringList _commandList; }; #endif |
From: Steve S. <sst...@us...> - 2013-02-15 04:34:25
|
Update of /cvsroot/qtstalker/qtstalker/plugins/PHASOR In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv9290/PHASOR Log Message: Directory /cvsroot/qtstalker/qtstalker/plugins/PHASOR added to the repository |
From: Steve S. <sst...@us...> - 2013-02-15 04:16:49
|
Update of /cvsroot/qtstalker/qtstalker/plugins/MACD In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv8373/qtstalker/plugins/MACD Modified Files: MACD.cpp MACD.h MACD.pro MACDDialog.cpp MACDDialog.h Added Files: MACDObject.cpp MACDObject.h Log Message: Index: MACDDialog.h =================================================================== RCS file: /cvsroot/qtstalker/qtstalker/plugins/MACD/MACDDialog.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** MACDDialog.h 25 Jun 2012 22:28:02 -0000 1.1 --- MACDDialog.h 15 Feb 2013 04:16:17 -0000 1.2 *************** *** 23,84 **** #define PLUGIN_MACD_DIALOG_HPP ! #include <QDialog> ! #include <QPushButton> ! #include <QDialogButtonBox> ! #include <QStringList> ! #include <QTabWidget> ! #include <QComboBox> ! #include <QLineEdit> ! #include <QSpinBox> ! #include <QCheckBox> ! #include "Entity.h" ! #include "ColorButton.h" ! class MACDDialog : public QDialog { Q_OBJECT ! public: ! MACDDialog (QWidget *); ! void setGUI (Entity *); ! public slots: void done (); - void cancel (); - void help (); void loadSettings (); void saveSettings (); ! void modified (); ! void save (); ! protected: ! Entity *_settings; ! QTabWidget *_tabs; ! QDialogButtonBox *_buttonBox; ! QPushButton *_okButton; ! QPushButton *_cancelButton; ! QString _helpFile; ! int _modified; ! ! QSpinBox *_macdWidth; ! ColorButton *_macdColor; ! QSpinBox *_fast; ! QSpinBox *_slow; ! QComboBox *_macdStyle; ! QComboBox *_fastMA; ! QComboBox *_slowMA; ! QComboBox *_input; ! QCheckBox *_macdShow; ! ! QSpinBox *_signalWidth; ! ColorButton *_signalColor; QSpinBox *_signalPeriod; ! QComboBox *_signalStyle; ! QComboBox *_signalMA; ! QCheckBox *_signalShow; ! ! ColorButton *_histColor; ! QCheckBox *_histShow; }; --- 23,55 ---- #define PLUGIN_MACD_DIALOG_HPP ! #include <QtGui> ! #include "Dialog.h" ! #include "InputObjectWidget.h" ! class MACDDialog : public Dialog { Q_OBJECT ! public: ! MACDDialog (QHash<QString, void *> objects, QString name); ! ~MACDDialog (); ! void createTab (QHash<QString, void *>); ! void setSettings(QString io, QString ik, int fp, QString fma, int sp, QString sma, int sigp, QString sigma); ! void settings(QString &io, QString &ik, int &fp, QString &fma, int &sp, QString &sma, int &sigp, QString &sigma); ! public slots: void done (); void loadSettings (); void saveSettings (); ! protected: ! InputObjectWidget *_input; ! QSpinBox *_fastPeriod; ! QSpinBox *_slowPeriod; QSpinBox *_signalPeriod; ! QComboBox *_fastMAType; ! QComboBox *_slowMAType; ! QComboBox *_signalMAType; }; Index: MACD.pro =================================================================== RCS file: /cvsroot/qtstalker/qtstalker/plugins/MACD/MACD.pro,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** MACD.pro 25 Jun 2012 22:28:02 -0000 1.1 --- MACD.pro 15 Feb 2013 04:16:17 -0000 1.2 *************** *** 1,19 **** TEMPLATE = lib CONFIG += plugin - INCLUDEPATH += ../../lib - LIBS += -L../../lib -lOTA MOC_DIR += build OBJECTS_DIR += build HEADERS += MACD.h SOURCES += MACD.cpp HEADERS += MACDDialog.h SOURCES += MACDDialog.cpp ! target.path = /usr/local/lib/OTA/plugins INSTALLS += target QT += core QT += gui - QT += sql - QT += network --- 1,33 ---- TEMPLATE = lib CONFIG += plugin MOC_DIR += build OBJECTS_DIR += build + INCLUDEPATH += ../../src + HEADERS += MACD.h SOURCES += MACD.cpp + HEADERS += MACDObject.h + SOURCES += MACDObject.cpp HEADERS += MACDDialog.h SOURCES += MACDDialog.cpp + HEADERS += ../../src/Object.h + SOURCES += ../../src/Object.cpp + HEADERS += ../../src/Util.h + SOURCES += ../../src/Util.cpp + HEADERS += ../../src/Plugin.h + HEADERS += ../../src/PluginCommand.h + HEADERS += ../../src/ObjectCommand.h + SOURCES += ../../src/ObjectCommand.cpp + SOURCES += ../../src/Dialog.cpp + HEADERS += ../../src/Dialog.h + SOURCES += ../../src/InputObjectWidget.cpp + HEADERS += ../../src/InputObjectWidget.h ! ! HOME=$$system(echo $HOME) ! target.path = $${HOME}/OTA/lib INSTALLS += target QT += core QT += gui --- NEW FILE: MACDObject.h --- /* * Qtstalker stock charter * * Copyright (C) 2001-2010 Stefan S. Stratigakos * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. */ #ifndef PLUGIN_MACD_OBJECT_HPP #define PLUGIN_MACD_OBJECT_HPP #include <QStringList> #include <QMap> #include "Object.h" #include "MACDDialog.h" class MACDObject : public Object { Q_OBJECT public: MACDObject (QString profile, QString name); ~MACDObject (); void clear (); int update (ObjectCommand *); int dialog (ObjectCommand *); int output (ObjectCommand *); int load (ObjectCommand *); int save (ObjectCommand *); int outputKeys (ObjectCommand *); public slots: int message (ObjectCommand *); void dialogDone (void *); private: QStringList _commandList; QStringList _maList; QMap<int, Data *> _bars; QString _inputObject; QString _inputKey; QString _slowMAType; QString _fastMAType; QString _signalMAType; QString _macdKey; QString _signalKey; QString _histKey; int _fastPeriod; int _slowPeriod; int _signalPeriod; }; #endif --- NEW FILE: MACDObject.cpp --- /* * Qtstalker stock charter * * Copyright (C) 2001-2010 Stefan S. Stratigakos * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. */ #include "MACDObject.h" #include "ta_libc.h" #include "MACDDialog.h" #include "Util.h" #include <QtDebug> MACDObject::MACDObject (QString profile, QString name) { TA_RetCode rc = TA_Initialize(); if (rc != TA_SUCCESS) qDebug() << "MACDObject::MACDObject: error on TA_Initialize"; _profile = profile; _name = name; _plugin = QString("MACD"); _type = QString("indicator"); _fastMAType = QString("EMA"); _slowMAType = QString("EMA"); _signalMAType = QString("EMA"); _fastPeriod = 12; _slowPeriod = 26; _signalPeriod = 9; _macdKey = QString("m"); _signalKey = QString("s"); _histKey = QString("h"); _hasOutput = TRUE; _inputObject = QString("symbol"); _inputKey = QString("C"); _commandList << QString("update"); _commandList << QString("dialog"); _commandList << QString("output"); _commandList << QString("load"); _commandList << QString("save"); _commandList << QString("output_keys"); Util util; Object *o = util.object(QString("MA"), QString(), QString()); if (o) { QString key("types"); ObjectCommand toc(key); if (o->message(&toc)) _maList = toc.getList(key); delete o; } } MACDObject::~MACDObject () { clear(); } void MACDObject::clear () { qDeleteAll(_bars); _bars.clear(); } int MACDObject::message (ObjectCommand *oc) { int rc = 0; switch (_commandList.indexOf(oc->command())) { case 0: rc = update(oc); break; case 1: rc = dialog(oc); break; case 2: rc = output(oc); break; case 3: rc = load(oc); break; case 4: rc = save(oc); break; case 5: rc = outputKeys(oc); break; default: break; } return rc; } int MACDObject::update (ObjectCommand *oc) { clear(); // input object Object *io = (Object *) oc->getObject(_inputObject); if (! io) { qDebug() << "MACDObject::update: invalid input" << _inputObject; return 0; } // get input bars ObjectCommand toc(QString("output")); if (! io->message(&toc)) { qDebug() << "MACDObject::update: message error" << io->plugin() << toc.command(); return 0; } QMap<int, Data *> data = toc.map(); int size = data.size(); TA_Real input[size]; TA_Real out[size]; TA_Real out2[size]; TA_Real out3[size]; TA_Integer outBeg; TA_Integer outNb; int dpos = 0; QMapIterator<int, Data *> it(data); while (it.hasNext()) { it.next(); Data *d = it.value(); if (d->contains(_inputKey)) input[dpos++] = (TA_Real) d->value(_inputKey).toDouble(); } TA_RetCode rc = TA_MACDEXT(0, dpos - 1, &input[0], _fastPeriod, (TA_MAType) _maList.indexOf(_fastMAType), _slowPeriod, (TA_MAType) _maList.indexOf(_slowMAType), _signalPeriod, (TA_MAType) _maList.indexOf(_signalMAType), &outBeg, &outNb, &out[0], &out2[0], &out3[0]); if (rc != TA_SUCCESS) { qDebug() << "MACDObject::update: TA-Lib error" << rc; return 0; } int outLoop = outNb - 1; it.toBack(); while (it.hasPrevious() && outLoop > -1) { it.previous(); Data *b = new Data; b->insert(_macdKey, out[outLoop]); b->insert(_signalKey, out2[outLoop]); b->insert(_histKey, out3[outLoop--]); _bars.insert(it.key(), b); } return 1; } int MACDObject::dialog (ObjectCommand *oc) { MACDDialog *dialog = new MACDDialog(oc->getObjects(), _name); dialog->setSettings(_inputObject, _inputKey, _fastPeriod, _fastMAType, _slowPeriod, _slowMAType, _signalPeriod, _signalMAType); connect(dialog, SIGNAL(signalDone(void *)), this, SLOT(dialogDone(void *))); dialog->setModified(FALSE); dialog->show(); return 1; } void MACDObject::dialogDone (void *dialog) { MACDDialog *d = (MACDDialog *) dialog; d->settings(_inputObject, _inputKey, _fastPeriod, _fastMAType, _slowPeriod, _slowMAType, _signalPeriod, _signalMAType); ObjectCommand oc(QString("modified")); emit signalMessage(oc); } int MACDObject::outputKeys (ObjectCommand *oc) { QStringList keys; keys << _macdKey << _signalKey << _histKey; oc->setValue(QString("output_keys"), keys); return 1; } int MACDObject::output (ObjectCommand *oc) { outputKeys(oc); oc->setMap(_bars); return 1; } int MACDObject::load (ObjectCommand *oc) { QSettings *settings = (QSettings *) oc->getObject(QString("QSettings")); if (! settings) { qDebug() << "MACDObject::load: invalid QSettings"; return 0; } _inputObject = settings->value(QString("input_object")).toString(); _inputKey = settings->value(QString("input_key")).toString(); _fastMAType = settings->value(QString("fast_ma_type")).toString(); _fastPeriod = settings->value(QString("fast_period")).toInt(); _slowMAType = settings->value(QString("slow_ma_type")).toString(); _slowPeriod = settings->value(QString("slow_period")).toInt(); _signalMAType = settings->value(QString("signal_ma_type")).toString(); _signalPeriod = settings->value(QString("signal_period")).toInt(); return 1; } int MACDObject::save (ObjectCommand *oc) { QSettings *settings = (QSettings *) oc->getObject(QString("QSettings")); if (! settings) { qDebug() << "MACDObject::save: invalid QSettings"; return 0; } settings->setValue(QString("plugin"), _plugin); settings->setValue(QString("input_object"), _inputObject); settings->setValue(QString("input_key"), _inputKey); settings->setValue(QString("fast_ma_type"), _fastMAType); settings->setValue(QString("fast_period"), _fastPeriod); settings->setValue(QString("slow_ma_type"), _slowMAType); settings->setValue(QString("slow_period"), _slowPeriod); settings->setValue(QString("signal_ma_type"), _signalMAType); settings->setValue(QString("signal_period"), _signalPeriod); return 1; } Index: MACD.h =================================================================== RCS file: /cvsroot/qtstalker/qtstalker/plugins/MACD/MACD.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** MACD.h 25 Jun 2012 22:28:02 -0000 1.1 --- MACD.h 15 Feb 2013 04:16:17 -0000 1.2 *************** *** 24,29 **** #define PLUGIN_MACD_H - #include <QObject> - #include "Plugin.h" --- 24,27 ---- *************** *** 34,44 **** public: ! int draw (QPainter *, const QwtScaleMap &, const QwtScaleMap &, const QRect &, void *); ! int command (PluginData *); ! int settings (PluginData *); ! int dialog (PluginData *); ! int run (PluginData *); ! int getMACD (QString inKey, int fp, int sp, int fma, int sma, int sigp, ! int sigma, QString mkey, QString skey, QString hkey); }; --- 32,40 ---- public: ! MACD (); ! int command (PluginCommand *); ! ! protected: ! QStringList _commandList; }; Index: MACDDialog.cpp =================================================================== RCS file: /cvsroot/qtstalker/qtstalker/plugins/MACD/MACDDialog.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** MACDDialog.cpp 25 Jun 2012 22:28:02 -0000 1.1 --- MACDDialog.cpp 15 Feb 2013 04:16:17 -0000 1.2 *************** *** 21,344 **** #include "MACDDialog.h" ! #include "Doc.h" ! #include "Global.h" ! #include "MAType.h" ! #include "CurveLineType.h" ! #include "BarType.h" ! ! #include <QtDebug> ! #include <QSettings> ! #include <QLayout> ! #include <QFormLayout> ! ! MACDDialog::MACDDialog (QWidget *p) : QDialog (p) { ! _settings = 0; ! _modified = 0; ! _helpFile = "main.html"; ! connect(this, SIGNAL(finished(int)), this, SLOT(deleteLater())); ! ! // main vbox ! QVBoxLayout *vbox = new QVBoxLayout; ! vbox->setSpacing(2); ! vbox->setMargin(5); ! setLayout(vbox); ! _tabs = new QTabWidget; ! vbox->addWidget(_tabs); ! ! // buttonbox ! _buttonBox = new QDialogButtonBox(QDialogButtonBox::Help); ! connect(_buttonBox, SIGNAL(accepted()), this, SLOT(done())); ! connect(_buttonBox, SIGNAL(rejected()), this, SLOT(cancel())); ! vbox->addWidget(_buttonBox); ! ! // ok button ! _okButton = _buttonBox->addButton(QDialogButtonBox::Ok); ! _okButton->setText(tr("&OK")); ! ! // cancel button ! _cancelButton = _buttonBox->addButton(QDialogButtonBox::Cancel); ! _cancelButton->setText(tr("&Cancel")); ! _cancelButton->setDefault(TRUE); ! _cancelButton->setFocus(); ! ! // help button ! QPushButton *b = _buttonBox->button(QDialogButtonBox::Help); ! b->setText(tr("&Help")); ! connect(b, SIGNAL(clicked()), this, SLOT(help())); ! } ! ! void MACDDialog::done () ! { ! saveSettings(); ! save(); ! accept(); ! } ! ! void MACDDialog::help () ! { ! Doc *doc = new Doc; ! doc->showDocumentation(_helpFile); } ! void MACDDialog::cancel () { saveSettings(); - reject(); - } - - void MACDDialog::loadSettings () - { - QSettings settings(g_settings); - settings.beginGroup(g_session); - - QSize sz = settings.value("macd_dialog_size", QSize(200,200)).toSize(); - resize(sz); - - // restore the position of the app - QPoint p = settings.value("macd_dialog_pos").toPoint(); - if (! p.isNull()) - move(p); - } - - void MACDDialog::saveSettings () - { - QSettings settings(g_settings); - settings.beginGroup(g_session); - settings.setValue("macd_dialog_size", size()); - settings.setValue("macd_dialog_pos", pos()); } ! void MACDDialog::setGUI (Entity *settings) { ! _settings = settings; - // MACD page QWidget *w = new QWidget; QFormLayout *form = new QFormLayout; w->setLayout(form); // input ! QVariant *set = _settings->get(QString("input")); ! ! BarType bt; ! _input = new QComboBox; ! _input->addItems(bt.list()); ! _input->setCurrentIndex(_input->findText(set->toString(), Qt::MatchExactly)); ! connect(_input, SIGNAL(currentIndexChanged(int)), this, SLOT(modified())); form->addRow(tr("Input"), _input); ! // color ! set = _settings->get(QString("macdColor")); ! ! _macdColor = new ColorButton(this, QColor(set->toString())); ! connect(_macdColor, SIGNAL(valueChanged(QColor)), this, SLOT(modified())); ! form->addRow(tr("Color"), _macdColor); ! ! // fast period ! set = _settings->get(QString("fast")); ! ! _fast = new QSpinBox; ! _fast->setRange(1, 999999); ! _fast->setValue(set->toInt()); ! connect(_fast, SIGNAL(valueChanged(const QString &)), this, SLOT(modified())); ! form->addRow(tr("Fast Period"), _fast); ! ! // slow period ! set = _settings->get(QString("slow")); ! ! _slow = new QSpinBox; ! _slow->setRange(1, 999999); ! _slow->setValue(set->toInt()); ! connect(_slow, SIGNAL(valueChanged(const QString &)), this, SLOT(modified())); ! form->addRow(tr("Slow Period"), _slow); ! ! // ma fast type ! set = _settings->get(QString("fastMA")); ! ! MAType mat; ! _fastMA = new QComboBox; ! _fastMA->addItems(mat.list()); ! _fastMA->setCurrentIndex(_fastMA->findText(set->toString(), Qt::MatchExactly)); ! connect(_fastMA, SIGNAL(currentIndexChanged(int)), this, SLOT(modified())); ! form->addRow(tr("Fast MA"), _fastMA); ! ! // ma slow type ! set = _settings->get(QString("slowMA")); ! ! _slowMA = new QComboBox; ! _slowMA->addItems(mat.list()); ! _slowMA->setCurrentIndex(_slowMA->findText(set->toString(), Qt::MatchExactly)); ! connect(_slowMA, SIGNAL(currentIndexChanged(int)), this, SLOT(modified())); ! form->addRow(tr("Slow MA"), _slowMA); ! ! // line style ! set = _settings->get(QString("macdStyle")); ! ! CurveLineType clt; ! _macdStyle = new QComboBox; ! _macdStyle->addItems(clt.list()); ! _macdStyle->setCurrentIndex(_macdStyle->findText(set->toString(), Qt::MatchExactly)); ! connect(_macdStyle, SIGNAL(currentIndexChanged(int)), this, SLOT(modified())); ! form->addRow(tr("Style"), _macdStyle); ! ! // width ! set = _settings->get(QString("macdWidth")); ! ! _macdWidth = new QSpinBox; ! _macdWidth->setRange(1, 99); ! _macdWidth->setValue(set->toInt()); ! connect(_macdWidth, SIGNAL(valueChanged(const QString &)), this, SLOT(modified())); ! form->addRow(tr("Width"), _macdWidth); ! ! // show ! set = _settings->get(QString("macdShow")); ! ! _macdShow = new QCheckBox; ! _macdShow->setChecked(set->toBool()); ! connect(_macdShow, SIGNAL(toggled(bool)), this, SLOT(modified())); ! form->addRow(tr("Show"), _macdShow); ! ! _tabs->addTab(w, QString("MACD")); ! ! // SIGNAL page ! w = new QWidget; ! form = new QFormLayout; ! w->setLayout(form); ! ! // style ! set = _settings->get(QString("signalStyle")); ! ! _signalStyle = new QComboBox; ! _signalStyle->addItems(clt.list()); ! _signalStyle->setCurrentIndex(_signalStyle->findText(set->toString(), Qt::MatchExactly)); ! connect(_signalStyle, SIGNAL(currentIndexChanged(int)), this, SLOT(modified())); ! form->addRow(tr("Style"), _signalStyle); ! ! // width ! set = _settings->get(QString("signalWidth")); ! _signalWidth = new QSpinBox; ! _signalWidth->setRange(1, 99); ! _signalWidth->setValue(set->toInt()); ! connect(_signalWidth, SIGNAL(valueChanged(const QString &)), this, SLOT(modified())); ! form->addRow(tr("Width"), _signalWidth); ! ! // color ! set = _settings->get(QString("signalColor")); ! _signalColor = new ColorButton(this, QColor(set->toString())); ! connect(_signalColor, SIGNAL(valueChanged(QColor)), this, SLOT(modified())); ! form->addRow(tr("Color"), _signalColor); ! ! // ma type ! set = _settings->get(QString("signalMA")); ! _signalMA = new QComboBox; ! _signalMA->addItems(mat.list()); ! _signalMA->setCurrentIndex(_fastMA->findText(set->toString(), Qt::MatchExactly)); ! connect(_signalMA, SIGNAL(currentIndexChanged(int)), this, SLOT(modified())); ! form->addRow(tr("MA"), _signalMA); ! // period ! set = _settings->get(QString("signalPeriod")); _signalPeriod = new QSpinBox; _signalPeriod->setRange(1, 999999); ! _signalPeriod->setValue(set->toInt()); ! connect(_signalPeriod, SIGNAL(valueChanged(const QString &)), this, SLOT(modified())); ! form->addRow(tr("Period"), _signalPeriod); ! ! // show ! set = _settings->get(QString("signalShow")); ! ! _signalShow = new QCheckBox; ! _signalShow->setChecked(set->toBool()); ! connect(_signalShow, SIGNAL(toggled(bool)), this, SLOT(modified())); ! form->addRow(tr("Show"), _signalShow); ! ! _tabs->addTab(w, tr("Signal")); ! ! // HIST page ! w = new QWidget; ! ! form = new QFormLayout; ! w->setLayout(form); ! ! // color ! set = _settings->get(QString("histColor")); ! ! _histColor = new ColorButton(this, QColor(set->toString())); ! connect(_histColor, SIGNAL(valueChanged(QColor)), this, SLOT(modified())); ! form->addRow(tr("Color"), _histColor); ! ! // show ! set = _settings->get(QString("histShow")); ! ! _histShow = new QCheckBox; ! _histShow->setChecked(set->toBool()); ! connect(_histShow, SIGNAL(toggled(bool)), this, SLOT(modified())); ! form->addRow(tr("Show"), _histShow); ! _tabs->addTab(w, tr("Histogram")); } ! void MACDDialog::save () { ! if (! _modified) ! return; ! ! QVariant *set = _settings->get(QString("macdColor")); ! set->setValue(_macdColor->color().name()); ! ! set = _settings->get(QString("fast")); ! set->setValue(_fast->value()); ! ! set = _settings->get(QString("slow")); ! set->setValue(_slow->value()); ! ! set = _settings->get(QString("fastMA")); ! set->setValue(_fastMA->currentText()); ! ! set = _settings->get(QString("slowMA")); ! set->setValue(_slowMA->currentText()); ! ! set = _settings->get(QString("macdStyle")); ! set->setValue(_macdStyle->currentText()); ! ! set = _settings->get(QString("macdWidth")); ! set->setValue(_macdWidth->value()); ! ! set = _settings->get(QString("macdShow")); ! set->setValue(_macdShow->isChecked()); ! ! set = _settings->get(QString("signalColor")); ! set->setValue(_signalColor->color().name()); ! ! set = _settings->get(QString("signalPeriod")); ! set->setValue(_signalPeriod->value()); ! ! set = _settings->get(QString("signalWidth")); ! set->setValue(_signalWidth->value()); ! ! set = _settings->get(QString("signalStyle")); ! set->setValue(_signalStyle->currentText()); ! set = _settings->get(QString("signalShow")); ! set->setValue(_signalShow->isChecked()); ! set = _settings->get(QString("histColor")); ! set->setValue(_histColor->color().name()); ! set = _settings->get(QString("histShow")); ! set->setValue(_histShow->isChecked()); } ! void MACDDialog::modified () { ! _modified = 1; } --- 21,164 ---- #include "MACDDialog.h" ! #include "Util.h" ! MACDDialog::MACDDialog (QHash<QString, void *> objects, QString name) : Dialog (0, name) { ! QStringList tl; ! QDir dir(QDir::homePath()); ! tl << dir.absolutePath() << QString("OTA") << QString("MACD") << QString("settings") << QString("dialog"); ! _settingsPath = tl.join("/"); ! createTab(objects); ! loadSettings(); } ! MACDDialog::~MACDDialog () { saveSettings(); } ! void ! MACDDialog::createTab (QHash<QString, void *> l) { ! QHash<QString, void *> ol; ! QHashIterator<QString, void *> it(l); ! while (it.hasNext()) ! { ! it.next(); ! Object *o = (Object *) it.value(); ! if (o->hasOutput()) ! ol.insert(it.key(), it.value()); ! } QWidget *w = new QWidget; QFormLayout *form = new QFormLayout; + form->setSpacing(2); + form->setMargin(10); w->setLayout(form); // input ! _input = new InputObjectWidget; ! _input->setObjects(ol); ! connect(_input, SIGNAL(valueChanged()), this, SLOT(modified())); form->addRow(tr("Input"), _input); ! // fast ma type ! QStringList tl; ! Util util; ! Object *o = util.object(QString("MA"), QString(), QString()); ! if (o) ! { ! QString key("types"); ! ObjectCommand toc(key); ! if (o->message(&toc)) ! tl = toc.getList(key); ! delete o; ! } ! _fastMAType = new QComboBox; ! _fastMAType->addItems(tl); ! connect(_fastMAType, SIGNAL(currentIndexChanged(int)), this, SLOT(modified())); ! form->addRow(tr("Fast MA"), _fastMAType); ! // fast period ! _fastPeriod = new QSpinBox; ! _fastPeriod->setRange(1, 999999); ! connect(_fastPeriod, SIGNAL(valueChanged(int)), this, SLOT(modified())); ! form->addRow(tr("Fast Period"), _fastPeriod); ! // slow ma type ! _slowMAType = new QComboBox; ! _slowMAType->addItems(tl); ! connect(_slowMAType, SIGNAL(currentIndexChanged(int)), this, SLOT(modified())); ! form->addRow(tr("Slow MA"), _slowMAType); ! // slow period ! _slowPeriod = new QSpinBox; ! _slowPeriod->setRange(1, 999999); ! connect(_slowPeriod, SIGNAL(valueChanged(int)), this, SLOT(modified())); ! form->addRow(tr("Slow Period"), _slowPeriod); ! // signal ma type ! _signalMAType = new QComboBox; ! _signalMAType->addItems(tl); ! connect(_signalMAType, SIGNAL(currentIndexChanged(int)), this, SLOT(modified())); ! form->addRow(tr("Signal MA"), _signalMAType); + // signal period _signalPeriod = new QSpinBox; _signalPeriod->setRange(1, 999999); ! connect(_signalPeriod, SIGNAL(valueChanged(int)), this, SLOT(modified())); ! form->addRow(tr("Signal Period"), _signalPeriod); ! _tabs->addTab(w, tr("Settings")); } ! void ! MACDDialog::done () { ! emit signalDone((void *) this); ! Dialog::done(); ! } ! void ! MACDDialog::loadSettings () ! { ! QSettings settings(_settingsPath, QSettings::NativeFormat); ! Dialog::loadSettings(settings); ! } ! void ! MACDDialog::saveSettings() ! { ! QSettings settings(_settingsPath, QSettings::NativeFormat); ! Dialog::saveSettings(settings); ! } ! void ! MACDDialog::setSettings (QString io, QString ik, int fp, QString fma, int sp, QString sma, int sigp, QString sigma) ! { ! _input->setInput(io); ! _input->setKey(tr("Input"), ik); ! _fastPeriod->setValue(fp); ! _fastMAType->setCurrentIndex(_fastMAType->findText(fma)); ! _slowPeriod->setValue(sp); ! _slowMAType->setCurrentIndex(_slowMAType->findText(sma)); ! _signalPeriod->setValue(sigp); ! _signalMAType->setCurrentIndex(_signalMAType->findText(sigma)); } ! void ! MACDDialog::settings (QString &io, QString &ik, int &fp, QString &fma, int &sp, QString &sma, int &sigp, QString &sigma) { ! io = _input->input(); ! ik = _input->key(tr("Input")); ! fma = _fastMAType->currentText(); ! fp = _fastPeriod->value(); ! sma = _slowMAType->currentText(); ! sp = _slowPeriod->value(); ! sigma = _signalMAType->currentText(); ! sigp = _signalPeriod->value(); } + Index: MACD.cpp =================================================================== RCS file: /cvsroot/qtstalker/qtstalker/plugins/MACD/MACD.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** MACD.cpp 25 Jun 2012 22:28:02 -0000 1.1 --- MACD.cpp 15 Feb 2013 04:16:17 -0000 1.2 *************** *** 20,56 **** */ - #include <QtGui> - #include "ta_libc.h" #include "MACD.h" ! #include "MAType.h" ! #include "BarType.h" ! #include "CurveLineType.h" ! #include "CurveHistogramType.h" ! #include "Global.h" ! #include "MACDDialog.h" int ! MACD::command (PluginData *pd) { int rc = 0; ! QStringList cl; ! cl << "type" << "dialog" << "runIndicator" << "settings"; ! ! switch (cl.indexOf(pd->command)) { case 0: // type ! pd->type = QString("indicator"); rc = 1; break; ! case 1: // dialog ! rc = dialog(pd); ! break; ! case 2: // runIndicator ! rc = run(pd); ! break; ! case 3: // settings ! rc = settings(pd); break; default: --- 20,47 ---- */ #include "MACD.h" ! #include "MACDObject.h" ! + MACD::MACD () + { + _commandList << QString("type"); + _commandList << QString("object"); + } int ! MACD::command (PluginCommand *pc) { int rc = 0; ! switch (_commandList.indexOf(pc->command)) { case 0: // type ! pc->type = QString("indicator"); rc = 1; break; ! case 1: // object ! pc->object = new MACDObject(pc->profile, pc->name); ! rc = 1; break; default: *************** *** 61,345 **** } - int - MACD::dialog (PluginData *pd) - { - if (! pd->dialogParent) - { - qDebug() << "MACD::dialog: invalid parent"; - return 0; - } - - if (! pd->settings) - { - qDebug() << "MACD::dialog: invalid settings"; - return 0; - } - - MACDDialog *dialog = new MACDDialog(pd->dialogParent); - dialog->setGUI(pd->settings); - pd->dialog = dialog; - - return 1; - } - - int - MACD::run (PluginData *pd) - { - if (! g_symbol) - return 0; - - QVariant *input = pd->settings->get(QString("input")); - if (! input) - return 0; - - QVariant *fp = pd->settings->get(QString("fast")); - if (! fp) - return 0; - - QVariant *sp = pd->settings->get(QString("slow")); - if (! sp) - return 0; - - QVariant *fma = pd->settings->get(QString("fastMA")); - if (! fma) - return 0; - - QVariant *sma = pd->settings->get(QString("slowMA")); - if (! sma) - return 0; - - QVariant *mlabel = pd->settings->get(QString("macdLabel")); - if (! mlabel) - return 0; - - QVariant *siglabel = pd->settings->get(QString("signalLabel")); - if (! siglabel) - return 0; - - QVariant *histlabel = pd->settings->get(QString("histLabel")); - if (! histlabel) - return 0; - - QVariant *sigma = pd->settings->get(QString("signalMA")); - if (! sigma) - return 0; - - QVariant *sigperiod = pd->settings->get(QString("signalPeriod")); - if (! sigperiod) - return 0; - - if (! getMACD(input->toString(), - fp->toInt(), - sp->toInt(), - fma->toInt(), - sma->toInt(), - sigperiod->toInt(), - sigma->toInt(), - mlabel->toString(), - siglabel->toString(), - histlabel->toString())) - return 0; - - // hist - QVariant *show = pd->settings->get(QString("histShow")); - if (! show) - return 0; - - if (show->toBool()) - { - QVariant *var = pd->settings->get(QString("histColor")); - if (! var) - return 0; - QColor color(var->toString()); - - Curve *c = new Curve(QString("CurveHistogram")); - c->setColor(color); - c->setLabel(histlabel->toString()); - c->setStyle(CurveHistogramType::_BAR); - c->fill(histlabel->toString(), QString(), QString(), QString(), color); - pd->curves << c; - } - - // macd - show = pd->settings->get(QString("macdShow")); - if (! show) - return 0; - - if (show->toBool()) - { - QVariant *var = pd->settings->get(QString("macdColor")); - if (! var) - return 0; - QColor color(var->toString()); - - QVariant *width = pd->settings->get(QString("macdWidth")); - if (! width) - return 0; - - QVariant *style = pd->settings->get(QString("macdStyle")); - if (! style) - return 0; - - CurveLineType clt; - Curve *c = new Curve(QString("CurveLine")); - c->setColor(color); - c->setLabel(mlabel->toString()); - c->setPen(width->toInt()); - c->setStyle(clt.stringToIndex(style->toString())); - c->fill(mlabel->toString(), QString(), QString(), QString(), QColor()); - pd->curves << c; - } - - // signal - show = pd->settings->get(QString("signalShow")); - if (! show) - return 0; - - if (show->toBool()) - { - QVariant *width = pd->settings->get(QString("signalWidth")); - if (! width) - return 0; - - QVariant *var = pd->settings->get(QString("signalColor")); - if (! var) - return 0; - QColor color(var->toString()); - - QVariant *style = pd->settings->get(QString("signalStyle")); - if (! style) - return 0; - - CurveLineType clt; - Curve *c = new Curve(QString("CurveLine")); - c->setColor(color); - c->setPen(width->toInt()); - c->setLabel(siglabel->toString()); - c->setStyle(clt.stringToIndex(style->toString())); - c->fill(siglabel->toString(), QString(), QString(), QString(), QColor()); - pd->curves << c; - } - - return 1; - } - - int - MACD::getMACD (QString inKey, int fp, int sp, int fma, int sma, int sigp, - int sigma, QString mkey, QString skey, QString hkey) - { - if (! g_symbol) - return 0; - - TA_RetCode rc = TA_Initialize(); - if (rc != TA_SUCCESS) - qDebug() << "MACD::MACD: error on TA_Initialize"; - - QList<int> keys = g_symbol->keys(); - - int size = keys.size(); - TA_Real input[size]; - TA_Real out[size]; - TA_Real out2[size]; - TA_Real out3[size]; - TA_Integer outBeg; - TA_Integer outNb; - - int dpos = 0; - for (int kpos = 0; kpos < keys.size(); kpos++) - { - CBar *bar = g_symbol->bar(keys.at(kpos)); - - double v; - if (! bar->get(inKey, v)) - continue; - - input[dpos++] = (TA_Real) v; - } - - rc = TA_MACDEXT(0, - dpos - 1, - &input[0], - fp, - (TA_MAType) fma, - sp, - (TA_MAType) sma, - sigp, - (TA_MAType) sigma, - &outBeg, - &outNb, - &out[0], - &out2[0], - &out3[0]); - - if (rc != TA_SUCCESS) - { - qDebug() << "MACD::getMACD: TA-Lib error" << rc; - return 0; - } - - int keyLoop = keys.size() - 1; - int outLoop = outNb - 1; - while (keyLoop > -1 && outLoop > -1) - { - CBar *bar = g_symbol->bar(keys.at(keyLoop)); - - bar->set(mkey, out[outLoop]); - bar->set(skey, out2[outLoop]); - bar->set(hkey, out3[outLoop]); - - keyLoop--; - outLoop--; - } - - return 1; - } - - int - MACD::settings (PluginData *pd) - { - Entity *command = new Entity; - BarType bt; - MAType mat; - CurveHistogramType cht; - CurveLineType clt; - - command->set(QString("plugin"), new QVariant(QString("MACD"))); - command->set(QString("type"), new QVariant(QString("indicator"))); - - command->set(QString("input"), new QVariant(bt.indexToString(BarType::_CLOSE))); - command->set(QString("fast"), new QVariant(12)); - command->set(QString("slow"), new QVariant(24)); - command->set(QString("fastMA"), new QVariant(mat.indexToString(MAType::_EMA))); - command->set(QString("slowMA"), new QVariant(mat.indexToString(MAType::_EMA))); - command->set(QString("macdColor"), new QVariant(QString("red"))); - command->set(QString("macdLabel"), new QVariant(QString("MACD"))); - command->set(QString("macdStyle"), new QVariant(clt.indexToString(CurveLineType::_SOLID))); - command->set(QString("macdWidth"), new QVariant(1)); - command->set(QString("macdShow"), new QVariant(TRUE)); - - command->set(QString("signalMA"), new QVariant(mat.indexToString(MAType::_EMA))); - command->set(QString("signalPeriod"), new QVariant(9)); - command->set(QString("signalColor"), new QVariant(QString("yellow"))); - command->set(QString("signalLabel"), new QVariant(tr("Signal"))); - command->set(QString("signalStyle"), new QVariant(clt.indexToString(CurveLineType::_SOLID))); - command->set(QString("signalWidth"), new QVariant(1)); - command->set(QString("signalShow"), new QVariant(TRUE)); - - command->set(QString("histColor"), new QVariant(QString("blue"))); - command->set(QString("histLabel"), new QVariant(QString("HIST"))); - command->set(QString("histShow"), new QVariant(TRUE)); - - pd->settings = command; - - return 1; - } - - int - MACD::draw (QPainter *, const QwtScaleMap &, const QwtScaleMap &, const QRect &, void *) - { - return 0; - } - - // do not remove ! Q_EXPORT_PLUGIN2(macd, MACD); --- 52,55 ---- } // do not remove ! Q_EXPORT_PLUGIN2(MACD, MACD); |