public override bool ComputeRBA(IMarketModelIndicator market_model, double[] target)
        {
            Tuple <double[], bool> tuple = indicator.Compute(market_model);

            if (!tuple.Item2)
            {
                return(false);
            }
            target[0] = model.GetLabel(tuple.Item1);
            return(true);
        }
Esempio n. 2
0
        private static void AddIndicators(MarketModelSimulation market, IIndicator feature_indicator, IIndicator label_indicators, IList <double[]> feature_data, IList <bool[]> missing_data, IList <double[]> label_data)
        {
            Tuple <double[], bool> tuple_features = feature_indicator.Compute(market);
            Tuple <double[], bool> tuple_labels   = label_indicators.Compute(market);

            //Only add valid entries?
            if (tuple_features.Item2 && tuple_labels.Item2)
            {
                feature_data.Add(tuple_features.Item1);
                missing_data.Add(ToolsCollection.CreateArray(feature_indicator.SubIndicatorCount, false));
                label_data.Add(tuple_labels.Item1);
            }
        }
Esempio n. 3
0
        public override bool ComputeRBA(IMarketModelIndicator market_model, double[] target)
        {
            bool all_valid = true;

            for (int indicator_index = 0; indicator_index < indicators.Count; indicator_index++)
            {
                IIndicator             inidicator = indicators[indicator_index];
                Tuple <double[], bool> tuple      = inidicator.Compute(market_model);
                ToolsCollection.CopyRBA(tuple.Item1, 0, target, indicator_offsets[indicator_index], inidicator.SubIndicatorCount);

                if (!tuple.Item2)
                {
                    all_valid = false;
                }
            }
            return(all_valid);
        }
Esempio n. 4
0
        public void GetTradeOrderCommand(IMarketModelSimulation market_model)
        {
            Tuple <double[], bool> indicator_0_Tuple      = indicator_0.Compute(market_model);
            Tuple <double[], bool> indicator_0_Tuple_Prev = indicator_0_Tuple;

            if (indicator_0_Tuple.Item2 && market_model.OpenOrders.Count == 0)
            {
                //   if (market_model.CurrentAsk < indicator_0_Tuple.Item1[2] && market_model.Second1[-1].CloseAsk < indicator_0_Tuple_Prev.Item1[2])

                if (threshold_long < indicator_0_Tuple.Item1[7])
                {
                    market_model.ProcessOrderCommand(new TradingOrderCommand(TradingOrderType.Long, TradingConstants.LOT, market_model.CurrentAsk, 0
                                                                             , market_model.CurrentAsk - stop_loss * TradingConstants.POINT, market_model.CurrentAsk + take_profit * TradingConstants.POINT));
                }
                if (threshold_short > indicator_0_Tuple.Item1[7])
                {
                    market_model.ProcessOrderCommand(new TradingOrderCommand(TradingOrderType.Short, TradingConstants.LOT, market_model.CurrentBid, 0
                                                                             , market_model.CurrentBid + stop_loss * TradingConstants.POINT, market_model.CurrentBid - take_profit * TradingConstants.POINT));
                }
            }

            TrailingStopLoss(market_model, TradingConstants.POINT * 150);
        }
 public void GetTradeOrderCommand(IMarketModelSimulation market)
 {
     Tuple <double[], bool> tuple = indicator.Compute(market);
 }