44#include " HistoricalDataEasy.hpp"
55
66int main () {
7- std::string path = " ..//..//train_2//quotes_bars_data//frxAUDCAD " ;
7+ std::string path = " ..//..//train_2//quotes_bars_data//frxEURGBP " ;
88 HistoricalDataEasy::HistoricalData hist (path);
99 hist.read_all_data ();
1010
1111 int PERIOD_MA = 10 ;
1212 int PERIOD_MW = 10 ;
13- int PERIOD_RSI = 10 ;
13+ int PERIOD_RSI = 5 ;
1414 int PERIOD_BB = 20 ;
1515 double STD_DEV_BB = 2 ;
1616 IndicatorsEasy::WMA <double > wma (PERIOD_MA );
@@ -19,24 +19,59 @@ int main() {
1919 IndicatorsEasy::MW <double > mw (PERIOD_MW );
2020 IndicatorsEasy::RSI <double , IndicatorsEasy::EMA <double >> rsi (PERIOD_RSI );
2121 IndicatorsEasy::BollingerBands<double > bb (PERIOD_BB , STD_DEV_BB );
22+ IndicatorsEasy::DetectorWaveform<double > dw (100 );
23+ /*
24+ 30, 240, 0.6
25+ */
2226 const int CANDLE_SIZE = 60 ;
2327
2428 int status = 0 ;
2529 while (status != hist.END_OF_DATA ) {
2630 double price = 0 ;
2731 unsigned long long timestamp = 0 ;
2832 hist.get_price (price, timestamp, status, CANDLE_SIZE );
29- std::cout << " price: " << price << std::endl;
33+ // std::cout << "price: " << price << std::endl;
3034 if (status == hist.SKIPPING_DATA ) {
3135 wma.clear ();
3236 sma.clear ();
3337 ema.clear ();
3438 mw.clear ();
3539 rsi.clear ();
3640 bb.clear ();
41+ dw.clear ();
3742 }
3843 if (status == hist.NORMAL_DATA ) {
3944 double wma_out, sma_out, ema_out, rsi_out, bb_tl, bb_ml, bb_bl;
45+ double dw_out;
46+ if (rsi.update (price, rsi_out) == hist.OK ) {
47+ // std::cout << "rsi: " << rsi_out << std::endl;
48+ }
49+ if (dw.update (price, dw_out, 20 ) == hist.OK ) {
50+ // std::cout << "dw: " << dw_out << std::endl;
51+ if (abs (rsi_out) > 80 )
52+ if (abs (dw_out) > 0.8 ) {
53+ int state = 0 ;
54+ if (dw_out > 0 ) {
55+ hist.check_binary_option (state, hist.SELL , 180 , timestamp);
56+ } else
57+ if (dw_out < 0 ) {
58+ hist.check_binary_option (state, hist.BUY , 180 , timestamp);
59+ }
60+ static int num_sum = 0 ;
61+ static double sum = 0 ;
62+ if (state == 1 ) {
63+ sum += 1.0 ;
64+ }
65+ num_sum++;
66+ std::cout << " eff " << (sum / (double )num_sum) << std::endl;
67+ std::cout << num_sum << std::endl;
68+ std::cout << xtime::get_str_unix_date_time (timestamp) << std::endl;
69+ // int zz;
70+ // std::cin >> zz;
71+ // std::cout << zz << std::endl;
72+ }
73+ }
74+ # if (0)
4075 if (wma.update (price, wma_out) == hist.OK ) {
4176 std::cout << " wma: " << wma_out << std::endl;
4277 }
@@ -83,8 +118,9 @@ int main() {
83118 std::cout << " mw min: " << temp << std::endl;
84119 std::cout << std::endl;
85120 }
121+ # endif
86122 }
87- std::cout << std::endl;
123+ // std::cout << std::endl;
88124 }
89125 return 0 ;
90126}
0 commit comments