public void Strength_Sell100Neutral100_ReturnsSell0() { var combinedSignal = new DefensiveCombinedSignal(new SellSignal(100), new NeutralSignal(100)); var expectedSignal = new SellSignal(0); Assert.That(combinedSignal, Is.EqualTo(expectedSignal)); }
public void Strength_Buy0Sell100_ReturnsSell25() { var combinedSignal = new OffensiveCombinedSignal(new BuySignal(0), new SellSignal(100)); var expectedSignal = new SellSignal(25); Assert.That(combinedSignal, Is.EqualTo(expectedSignal)); }
void blt_GotNewBar(string symbol, int interval) { int idx = _active.getindex(symbol); Tick tOther = _kt[symbol]; // calculate the TD_combination using high/low/close prices for so many bars back BarList _myBars = _blt[symbol, interval]; // make sure the lastBar is full //Bar _lastBar = _myBars[_myBars.Count - 2]; //Bar _secondBar = _myBars[_myBars.Count - 3]; //Bar _thirdBar = _myBars[_myBars.Count - 4]; //Bar _forthBar = _myBars[_myBars.Count - 5]; //Bar _sixthBar = _myBars[_myBars.Count - 7]; //Bar _seventhBar = _myBars[_myBars.Count - 8]; //Bar _fifthBar = _myBars[_myBars.Count - 6]; //Bar _ninthBar = _myBars[_myBars.Count - 10]; //Bar _eighthBar = _myBars[_myBars.Count - 9]; for (int i = 1; i <= 15; i++) { _barVec[i] = _myBars[_myBars.Count - 1 - i]; } if (UseTD_combinationFromATSGlobalIndicator) { _TD_combinationFromATSGlobalIndicator.UpdateValue(_barVec); BuySignal = _TD_combinationFromATSGlobalIndicator.GetBuySignal(); SellSignal = _TD_combinationFromATSGlobalIndicator.GetSellSignal(); } //else //{ // SMA = Calc.Avg(Calc.EndSlice(_blt[symbol].Open(), _barsback)); //} // wait until we have the TD_combination+ and the TD_combination- //if (BuySignal == 0 && SellSignal == 0) // return; //ensure we aren't waiting for previous order to fill if (!_wait[symbol]) { // if we're flat and not waiting // if TD_combination+ is above TD_combination-, buy if ((Money_state == 0 && BuySignal == 1)) { Money_state = 1; D("TD_BuySignal appears, buy"); //sendorder(new BuyMarket(symbol, EntrySize)); _side = true; _adj = (_side ? -1 : +1) * _quasiMarketOrderAdjSize; Int64 _orderidLocal = _idtLocal.AssignId; LimitOrder lOrder = new LimitOrder(symbol, _side, EntrySize, tOther.trade - _adj, _orderidLocal); sendorder(lOrder); // wait for fill _wait[symbol] = true; } // otherwise if TD_combination+ is above TD_combination-, sell if (Money_state == 1 && SellSignal == 1) { Money_state = 0; D("TD_SellSignal appears, sell"); //sendorder(new SellMarket(symbol, EntrySize)); _side = false; _adj = (_side ? -1 : +1) * _quasiMarketOrderAdjSize; Int64 _orderidLocal = _idtLocal.AssignId; LimitOrder lOrder = new LimitOrder(symbol, _side, EntrySize, tOther.trade - _adj, _orderidLocal); sendorder(lOrder); // wait for fill _wait[symbol] = true; } } // this way we can debug our indicators during development // indicators are sent in the same order as they are named above sendindicators(new string[] { _time.ToString(), BuySignal.ToString("F5", System.Globalization.CultureInfo.InvariantCulture), SellSignal.ToString("F5", System.Globalization.CultureInfo.InvariantCulture), _barVec[1].High.ToString("F5", System.Globalization.CultureInfo.InvariantCulture), _barVec[1].Low.ToString("F5", System.Globalization.CultureInfo.InvariantCulture), _barVec[1].Close.ToString("F5", System.Globalization.CultureInfo.InvariantCulture), //_previousBar.High.ToString("F5", System.Globalization.CultureInfo.InvariantCulture), //_previousBar.Low.ToString("F5", System.Globalization.CultureInfo.InvariantCulture), //_previousBar.Close.ToString("F5", System.Globalization.CultureInfo.InvariantCulture) }); }
public void SellSignal_WhenCreated_StrengthIs50() { var signal = new SellSignal(); Assert.That(signal.Strength.Value, Is.EqualTo(50)); }