private Stock_Report GetStockReportData(Stock stock) { try { List <Candel> candels = stock.Stock_Quote.Select(sq => new Candel() { Date = sq.date_round, Close = sq.closing, Maximun = sq.maximun, Minimun = sq.minimun, Open = sq.opening, Visible = true, Volume = (double)sq.volume }).ToList(); if (candels.Any()) { MA ma20 = new MA(candels, 20, ""); MA ma50 = new MA(candels, 50, ""); MA ma200 = new MA(candels, 200, ""); EMA ema12 = new EMA(candels, 12, "", false); EMA ema20 = new EMA(candels, 20, "", false); EMA ema26 = new EMA(candels, 26, "", false); RSI rsi14 = new RSI(candels, 14, 0, 0, "", ""); Momentum momentum12 = new Momentum(candels, 12, "", ""); StochasticOscillatorFast soFast = new StochasticOscillatorFast(candels, 14, 0, 0, "", "", ""); MACD macd1226 = new MACD(candels, 12, 26, 9, "", ""); BoolingerBands boolinger20 = new BoolingerBands(candels, 20, ""); WilliansR williansr14 = new WilliansR(candels, 14, 0, 0, "", "", ""); Stock_Report result = new Stock_Report(); result.Stock_ID = stock.Id; result.Price = stock.Stock_Quote.Last().closing; result.Date_Round = stock.Stock_Quote.Last().date_round; result.MA20 = ma20.Series[0].Data.Last().Value; result.MA50 = ma50.Series[0].Data.Last().Value; result.MA200 = ma200.Series[0].Data.Last().Value; result.RSI14 = rsi14.Series[0].Data.Last().Value; result.Momentum12 = momentum12.Series[0].Data.Last().Value; result.SOFast_k14 = (soFast.Series[0].Data.Any()) ? soFast.Series[0].Data.Last().Value : 0; result.SOFast_d3 = (soFast.Series[1].Data.Any()) ? soFast.Series[1].Data.Last().Value : 0; result.EMA12 = ema12.Series[0].Data.Last().Value; result.EMA26 = ema26.Series[0].Data.Last().Value; result.MACD2612 = macd1226.Series[0].Data.Last().Value; result.MA9 = macd1226.Series[1].Data.Last().Value; result.EMA20 = ema20.Series[0].Data.Last().Value; result.BoolUP = boolinger20.Series[1].Data.Last().Value; result.BoolLOW = boolinger20.Series[2].Data.Last().Value; result.WilliansR = (williansr14.Series[0].Data.Any()) ? williansr14.Series[0].Data.Last().Value : 0; return(result); } return(null); } catch (Exception ex) { throw ex; } }
public void CanSerializeToXml_RSI() { var source = new RSI { Symbol = "A", Date = DateTime.Today, PercentGT50 = 1.0, Avg = 2.0, LastRSI = 3.0, TotalDays = 4, MaxContGT50Days = 5, AvgContGT50Days = 6, MaxContLT50Days = 7, AvgContLT50Days = 8, LastContDays = 9, }; var i = source.ToIndicator(); var target = EntityHelper.DeserializeFromXml <RSI>(i.Data); Assert.IsTrue(source.Symbol == target.Symbol); Assert.IsTrue(source.Date == target.Date); Assert.IsTrue(source.PercentGT50 == target.PercentGT50); Assert.IsTrue(source.Avg == target.Avg); Assert.IsTrue(source.LastRSI == target.LastRSI); Assert.IsTrue(source.TotalDays == target.TotalDays); Assert.IsTrue(source.MaxContGT50Days == target.MaxContGT50Days); Assert.IsTrue(source.AvgContGT50Days == target.AvgContGT50Days); Assert.IsTrue(source.MaxContLT50Days == target.MaxContLT50Days); Assert.IsTrue(source.AvgContLT50Days == target.AvgContLT50Days); Assert.IsTrue(source.LastContDays == target.LastContDays); }
private TrendDirection Get4HDirection() { // check the 4h chart EMA fastEMA = EMA(BarsArray[1], EMAFastPeriod); EMA slowEMA = EMA(BarsArray[1], EMASlowPeriod); Stochastics stoch = Stochastics(BarsArray[1], StochPeriodD, StochPeriodK, StochSmooth); RSI rsi = RSI(BarsArray[1], RSIPeriod, RSISmooth); // long if (fastEMA[0] > slowEMA[0] && Rising(fastEMA) && rsi[0] > RSIUpper && Rising(stoch) && stoch[0] < StochUpper) { // BackColor = Color.LightGreen; return(TrendDirection.Long); } // short if (fastEMA[0] < slowEMA[0] && Falling(fastEMA) && rsi[0] < RSIUpper && Falling(stoch) && stoch[0] > StochLower) { // BackColor = Color.Pink; return(TrendDirection.Short); } return(TrendDirection.Neutral); }
private TrendDirection Get15MinuteDirection() { EMA fastEMA = EMA(EMAFastPeriod); EMA slowEMA = EMA(EMASlowPeriod); Stochastics stoch = Stochastics(StochPeriodD, StochPeriodK, StochSmooth); RSI rsi = RSI(RSIPeriod, RSISmooth); MACD macd = MACD(MACDFast, MACDSlow, MACDSmooth); // long if (CrossAbove(slowEMA, fastEMA[0], CrossoverLookbackPeriod) && rsi[0] > RSIUpper && Rising(stoch) && stoch[0] < StochUpper && (CrossAbove(0, macd.Diff, CrossoverLookbackPeriod) || (macd.Diff[0] < 0 && Rising(macd.Diff)))) // macd.diff should be just starting to rise { return(TrendDirection.Long); } // short if (CrossBelow(slowEMA, fastEMA[0], CrossoverLookbackPeriod) && rsi[0] < RSIUpper && Falling(stoch) && stoch[0] > StochLower && (CrossBelow(0, macd.Diff, CrossoverLookbackPeriod) || (macd.Diff[0] > 0 && Falling(macd.Diff)))) // macd.diff should be just starting to fall { return(TrendDirection.Short); } return(TrendDirection.Neutral); }
public void TestRSI() { var prices = new List <decimal> { 44.34m, 44.09m, 44.15m, 43.61m, 44.33m, 44.83m, 45.10m, 45.42m, 45.84m, 46.08m, 45.89m, 46.03m, 45.61m, 46.28m, 46.28m, 46.00m, 46.03m, 46.41m, 46.22m, 45.64m, 46.21m, 46.25m, 45.71m, 46.45m, 45.78m, 45.35m, 44.03m, 44.18m, 44.22m, 44.57m, 43.42m, 42.66m, 43.13m, }; var referenceResults = new List <decimal> { 00.00m, 00.00m, 00.00m, 00.00m, 00.00m, 00.00m, 00.00m, 00.00m, 00.00m, 00.00m, 00.00m, 00.00m, 00.00m, 00.00m, 70.53m, 66.32m, 66.55m, 69.41m, 66.36m, 57.97m, 62.93m, 63.26m, 56.06m, 62.38m, 54.71m, 50.42m, 39.99m, 41.46m, 41.87m, 45.46m, 37.30m, 33.08m, 37.77m, }; var results = new List <decimal>(); IFinancialIndicator rsi = new RSI(14); prices.ForEach(price => { rsi.Update(price); results.Add(rsi.Value); }); // la verificación no es posible //for (int i = 0; i < results.Count; i++) { // Assert.AreEqual(referenceResults[i], results[i]); //} }
protected override void OnStateChange() { if (State == State.SetDefaults) { Description = NinjaTrader.Custom.Resource.NinjaScriptStrategyDescriptionSampleMultiInstrument; Name = NinjaTrader.Custom.Resource.NinjaScriptStrategyNameSampleMultiInstrument; // This strategy has been designed to take advantage of performance gains in Strategy Analyzer optimizations // See the Help Guide for additional information IsInstantiatedOnEachOptimizationIteration = false; } else if (State == State.Configure) { // Add an MSFT 1 minute Bars object to the strategy AddDataSeries("MSFT", Data.BarsPeriodType.Minute, 1); // Sets a 20 tick trailing stop for an open position SetTrailStop(CalculationMode.Ticks, 20); } else if (State == State.DataLoaded) { rsi = RSI(14, 1); adx = ADX(14); // Add RSI and ADX indicators to the chart for display // This only displays the indicators for the primary Bars object (main instrument) on the chart AddChartIndicator(rsi); AddChartIndicator(adx); } }
/// <summary> /// In this function we do all the work and send back the OrderAction. /// </summary> /// <param name="data"></param> /// <returns></returns> public OrderAction?calculate(IDataSeries data, IDataSeries open, IDataSeries high, IOrder longorder, IOrder shortorder, int bollinger_period, double bollinger_standarddeviation, int momentum_period, int rsi_period, int rsi_smooth, int rsi_level_low, int rsi_level_high, int momentum_level_low, int momentum_level_high) { //Calculate BB Bollinger bb = Bollinger(data, bollinger_standarddeviation, bollinger_period); Momentum mom = Momentum(data, momentum_period); RSI rsi = RSI(data, rsi_period, rsi_smooth); bb_lower = bb.Lower[0]; bb_middle = bb.Middle[0]; bb_upper = bb.Upper[0]; //if (high[0] > open[1]) //{ if (mom[0] >= momentum_level_high && rsi[0] <= rsi_level_low && data[0] <= bb.Lower[0] && data[1] <= bb.Lower[1] && data[2] <= bb.Lower[2]) { return(OrderAction.Buy); } else if (mom[0] <= momentum_level_low && rsi[0] >= rsi_level_high && data[0] >= bb.Upper[0] && data[1] >= bb.Upper[1] && data[2] >= bb.Upper[2]) { return(OrderAction.SellShort); } else if (data[0] >= bb.Upper[0] && longorder != null) { //currently we left the building on the upper band, is it better if we switch to a stop? return(OrderAction.Sell); } else if (data[0] <= bb.Lower[0] && shortorder != null) { return(OrderAction.BuyToCover); } //} return(null); }
protected override void OnStateChange() { base.OnStateChange(); if (State == State.SetDefaults) { Description = "Hedge by itself"; Name = "StgSelfHedger"; // This strategy has been designed to take advantage of performance gains in Strategy Analyzer optimizations // See the Help Guide for additional information Calculate = Calculate.OnBarClose; //IsFillLimitOnTouch = false; TraceOrders = false; BarsRequiredToTrade = 22; IsUnmanaged = false; //IsInstantiatedOnEachOptimizationIteration = false; } else if (State == State.Configure) { // Add an MSFT 1 minute Bars object to the strategy //AddDataSeries("NQ 06-20", Data.BarsPeriodType.Minute, 13); AddDataSeries("MNQ 06-20", Data.BarsPeriodType.Minute, 13); // Sets a 20 tick trailing stop for an open position SetTrailStop(CalculationMode.Ticks, 20); } else if (State == State.DataLoaded) { rsi = RSI(14, 1); adx = ADX(14); // Add RSI and ADX indicators to the chart for display // This only displays the indicators for the primary Bars object (main instrument) on the chart AddChartIndicator(rsi); AddChartIndicator(adx); } }
//populate public override void Populate() { TimeSeries source = Parameters[0].AsTimeSeries; Int32 period = Parameters[1].AsInt; Double multiplier = Parameters[2].AsDouble; bool useSD = Parameters[3].AsBoolean; DateTimes = source.DateTimes; TimeSeries overbought = null; RSI rsi = new RSI(source, period); if (useSD) { StdDev sd = new StdDev(rsi, period); overbought = 50 - multiplier * sd; } else { SMA sma = new SMA(rsi, period); overbought = new SMA((rsi - sma).Abs(), period); overbought = 50 - multiplier * overbought; } //modify the code below to implement your own indicator calculation for (int n = 0; n < source.Count; n++) { Values[n] = overbought[n]; } }
public override void GetAll(IIndicatorValues Ind) { int period = (int)this.IndicatorParameters.List[0]; decimal thresholdPercentage = (decimal)this.IndicatorParameters.List[1]; if (!Ind.RSI(period, thresholdPercentage).IsPopulated) { int oldCurrentBar = Ind.Bar.CurrentBar; for (int i = 1; i <= Ind.Bar.MaxBar; i++) { Ind.Bar.CurrentBar = i; object prototype = null; if (i == 1) { prototype = new RSI(thresholdPercentage); } else { prototype = (RSI)Ind.RSI(period, thresholdPercentage)[1].Clone(); } Get(ref prototype, Ind); Ind.RSI(period, thresholdPercentage)[0] = (RSI)prototype; Ind.RSI(period, thresholdPercentage).IsPopulated = true; // set here so instance is guaranteed to exits } Ind.Bar.CurrentBar = oldCurrentBar; } }
public override void PopulateExtendedIndicators(Entity.Indicator[] indArray) { double[] close = new double[indArray.Length]; double?[] rsiOutput = new double?[indArray.Length]; double?[] rsiOutput_Acc = new double?[indArray.Length]; for (int i = 0; i < indArray.Length; i++) { if (indArray[i].Close.HasValue) { close[i] = indArray[i].Close.Value; } else { close[i] = 0; } } RSI.Calculate(close, 2, rsiOutput); GenericHelper.GetAccumulate(rsiOutput, 2, 2, rsiOutput_Acc); for (int i = 0; i < indArray.Length; i++) { indArray[i].ExtendedIndicators = new Dictionary <string, double?>(); indArray[i].ExtendedIndicators.Add("RSI2", rsiOutput[i]); indArray[i].ExtendedIndicators.Add("RSI2ACC", rsiOutput_Acc[i]); } }
protected override void Create() { m_RSI = new RSI(this); m_myrsi = new VariableSeries <Double>(this); m_RsiLE = OrderCreator.MarketNextBar(new SOrderParameters(Contracts.Default, "RsiLE", EOrderAction.Buy)); }
public override void Load(IResourceCache cache, ResourcePath path) { var manifestPath = path / "meta.json"; string manifestContents; using (var manifestFile = cache.ContentFileRead(manifestPath)) using (var reader = new StreamReader(manifestFile)) { manifestContents = reader.ReadToEnd(); } if (RSISchema != null) { var errors = RSISchema.Validate(manifestContents); if (errors.Count != 0) { Logger.Error($"Unable to load RSI from '{path}', {errors.Count} errors:"); foreach (var error in errors) { Logger.Error("{0}", error.ToString()); } throw new RSILoadException($"{errors.Count} errors while loading RSI. See console."); } } // Ok schema validated just fine. var manifestJson = JObject.Parse(manifestContents); var size = manifestJson["size"].ToObject <Vector2u>(); var rsi = new RSI(size); var images = new List <Image <Rgba32> >(); var directionFramesList = new List <(Texture, float)[]>();
public override bool OnExecution() { BinanceConnectorNode binanceConnector = this.InParameters["connection"].GetValue() as BinanceConnectorNode; var result = binanceConnector.Client.FuturesUsdt.Market.GetKlines(this.InParameters["symbol"].GetValue().ToString(), global::Binance.Net.Enums.KlineInterval.OneHour); RSI rsi = new RSI(30); List <Ohlc> ohlcList = new List <Ohlc>(); foreach (var candle in result.Data) { ohlcList.Add(new Ohlc() { Date = candle.CloseTime, Open = (double)candle.Open, High = (double)candle.High, Low = (double)candle.Low, Close = (double)candle.Close, Volume = (double)candle.QuoteVolume, AdjClose = 1 }); } rsi.Load(ohlcList); var serie = rsi.Calculate(); this.OutParameters["RSI"].SetValue(serie.RSI.LastOrDefault()); return(true); }
public ConnorsRSI(DataSeries ds, int periodRSI, int periodStreak, int periodPR, string description) : base(ds, description) { base.FirstValidValue = Math.Max(Math.Max(periodRSI, periodStreak), periodPR); if (FirstValidValue <= 1) { return; } ConsecDaysDown cdd = ConsecDaysDown.Series(ds, 0); ConsecDaysUp cdu = ConsecDaysUp.Series(ds, 0); DataSeries streak = new DataSeries(ds, "streak"); for (int bar = 0; bar < ds.Count; bar++) { streak[bar] = cdd[bar] > 0 ? -cdd[bar] : cdu[bar] > 0 ? cdu[bar] : 0; } RSI rsi3 = RSI.Series(ds, periodRSI); RSI rsiStreak = RSI.Series(streak, periodStreak); ROC ret = ROC.Series(ds, 1); DataSeries pr = PercentRank.Series(ret, periodPR) * 100.0; DataSeries connorsRSI = (rsi3 + rsiStreak + pr) / 3; for (int bar = base.FirstValidValue; bar < ds.Count; bar++) { base[bar] = connorsRSI[bar]; } }
public Indicator AnalyzeData(DataState state) { double[] closePrices = _analyseRepo.LoadClosePriceBySymbol(state.Symbol, true).ToArray(); double[] RsiValues = RSICalculator.CalculateRsi(RSICalculator.Period, closePrices); if (RsiValues.Length == 0) { return(null); } var cont = new ContinuousCalculator(RsiValues, r => r > 50.0); RSI value = new RSI(); value.Symbol = state.Symbol; value.Date = state.Last.Value; value.Avg = RsiValues.Average(); value.LastRSI = AlgorithmHelper.GetLast(RsiValues); value.PercentGT50 = RsiValues.Where(r => r > 50).Count() * 100 / RsiValues.Count(); value.TotalDays = RsiValues.Count(); value.MaxContGT50Days = cont.TrueMax; value.MaxContLT50Days = cont.FalseMax; value.AvgContGT50Days = cont.TrueAvg; value.AvgContLT50Days = cont.FalseAvg; value.LastContDays = cont.LastCont; return(value.ToIndicator()); }
protected override void OnStateChange() { base.OnStateChange(); if (State == State.SetDefaults) { Description = "Free Sample Strategy using MA Cross"; Name = "StgFreeSample"; // This strategy has been designed to take advantage of performance gains in Strategy Analyzer optimizations // See the Help Guide for additional information Calculate = Calculate.OnBarClose; //IsFillLimitOnTouch = false; TraceOrders = false; BarsRequiredToTrade = 22; IsUnmanaged = false; OrderFillResolution = OrderFillResolution.Standard; EntriesPerDirection = 1; DefaultQuantity = 5; StopTargetHandling = StopTargetHandling.PerEntryExecution; MM_ProfitFactorMax = 1; MM_ProfitFactorMin = 0; TG_TradeEndH = 10; TG_TradeEndM = 45; //IsInstantiatedOnEachOptimizationIteration = false; } else if (State == State.Configure) { // Add an MSFT 1 minute Bars object to the strategy //AddDataSeries("NQ 06-20", Data.BarsPeriodType.Minute, 13); AddDataSeries("NQ 06-20", Data.BarsPeriodType.Minute, 13); AddDataSeries("RTY 06-20", Data.BarsPeriodType.Minute, 13); SetOrderQuantity = SetOrderQuantity.Strategy; // calculate orders based off default size // Sets a 20 tick trailing stop for an open position //SetTrailStop(CalculationMode.Ticks, 200); } else if (State == State.DataLoaded) { rsi = RSI(14, 1); rsi1 = RSI(BarsArray[1], 14, 1); rsi2 = RSI(BarsArray[2], 14, 1); adx = ADX(14); adx1 = ADX(BarsArray[1], 14); adx2 = ADX(BarsArray[2], 14); giPctSpd = GIPctSpd(8); // Add RSI and ADX indicators to the chart for display // This only displays the indicators for the primary Bars object (main instrument) on the chart AddChartIndicator(rsi); AddChartIndicator(adx); AddChartIndicator(giPctSpd); giPctSpd.RaiseIndicatorEvent += OnTradeByPctSpd; giPctSpd.TM_ClosingH = TG_TradeEndH; giPctSpd.TM_ClosingM = TG_TradeEndM; SetPrintOut(1); Print(String.Format("{0}: IsUnmanaged={1}", this.GetType().Name, IsUnmanaged)); Print(String.Format("{0}: DataLoaded...BarsArray.Length={1}", this.GetType().Name, BarsArray.Length)); } }
protected override void Create() { // In this method we create orders and functions, required for further signal functioning buy_order = OrderCreator.MarketThisBar(new SOrderParameters(Contracts.Default, "Long", EOrderAction.Buy)); sell_order = OrderCreator.MarketThisBar(new SOrderParameters(Contracts.Default, "Short", EOrderAction.SellShort)); m_RSI = new RSI(this); }
protected override void OnStrategyStart() { Portfolio.Account.Deposit(AllocationPerInstrument, CurrencyId.USD, "Initial allocation"); rsi = new RSI(Bars, RSILength); AddGroups(); }
static void Main(string[] args) { Console.ForegroundColor = ConsoleColor.Gray; //Console.ResetColor() is not working :( Console.CancelKeyPress += Console_CancelKeyPress; var ticker = string.Empty; string indicator = string.Empty; HandleArgs(args, ref ticker, ref indicator); Console.WriteLine($"Fetching trade data for {ticker.ToUpper()}..."); //on the next version, it's gonna be an interface RSI RSITrades = null; CCI CCITrades = null; BollingerBands BBandTrades = null; var bfxReader = new Core.Exchanges.Bitfinex.TickerReader(); TickerHandler tickerHndl = null; //getting the 14 last minutes history var hist = new Core.Exchanges.Bitfinex.TickerCandlesReader(); if (indicator.ToUpper() == "RSI") { RSICalc(out RSITrades, bfxReader, out tickerHndl, hist); } else if (indicator.ToUpper() == "CCI") { CCICalc(out CCITrades, bfxReader, out tickerHndl, hist); } else if (indicator.ToUpper() == "BBANDS") { BBandCalc(out BBandTrades, bfxReader, out tickerHndl, hist); } else { Console.WriteLine("Invalid Parameter"); return; } tickerHndl.OnError += tickerHndl_OnError; bfxReader.Enabled = true; Task.Run(async() => { await bfxReader.Start(ticker.ToUpper()); }); while (enabled) { ; } Console.ForegroundColor = ConsoleColor.Gray; Console.WriteLine($"Program ended."); }
protected override void MyInitialize() { _macd = MACD_ZeroLag_Colors(1, MACDFast, MACDSlow, MACDSmooth, 0); Add(_macd); _rsi = RSI(RSIPeriod, RSISmooth); Add(_rsi); TraceOrders = true; }
//populate public override void Populate() { TimeSeries source = Parameters[0].AsTimeSeries; TimeSeries ds = new TimeSeries(source.DateTimes, false); ds.Values.AddRange(source.Values); Int32 rsiPeriod = Parameters[1].AsInt; Int32 wmaPeriod = Parameters[2].AsInt; DateTimes = ds.DateTimes; int period = Math.Max(rsiPeriod, wmaPeriod); if (period <= 0 || ds.Count == 0) { return; } var FirstValidValue = Math.Max(rsiPeriod * 3, wmaPeriod); if (FirstValidValue > ds.Count) { FirstValidValue = ds.Count; } // Clip the raw Put/Call Ratio data for (int bar = 0; bar < ds.Count; bar++) { if (ds[bar] > 0.9) { ds[bar] = 0.9; } else if (ds[bar] < 0.45) { ds[bar] = 0.45; } } // TEMA smoothing ds = new TEMA_TASC(ds, 5); // Rainbow smoothing var rbw = new TimeSeries(DateTimes); var ma = new WMA(ds, 2); for (int w = 1; w <= 9; w++) { ma = new WMA(ma, 2); rbw += ma; } rbw /= 10d; rbw = new RSI(rbw, rsiPeriod); for (int bar = wmaPeriod - 1; bar < ds.Count; bar++) { Values[bar] = new WMA(rbw, wmaPeriod)[bar]; } }
public TickerHandler(IExchangeTickerReader tickerReader, RSI trades) { _tickerReader = tickerReader; _tickerReader.PoolingInterval = Consts.PoolingInterval; _tickerReader.TickerReady += _tickerReader_TickerReady; _tickerReader.OnError += _tickerReader_OnError; _rsi = trades; _rsi.IndicatorReady += _rsi_IndicatorReady; }
public void Less_Data_Then_Periods_Results_CollectionData_And_Empty_Current_Values(decimal[] input, int numberOfPeriods) { RSI rsi = new RSI(numberOfPeriods); rsi.Calculate(input.AsTradesWitRates()); Assert.True(rsi.CollectingData); Assert.Empty(rsi.Values); }
protected override void Create() { //buyOrder = OrderCreator.Limit(new SOrderParameters(Contracts.UserSpecified, EOrderAction.Buy)); buyOrderMarket = OrderCreator.MarketNextBar(new SOrderParameters(Contracts.UserSpecified, EOrderAction.Buy)); // we need "Default" in order for MM Signal to work sellOrderRsi = OrderCreator.MarketNextBar(new SOrderParameters(Contracts.Default, "RSI Exit", EOrderAction.Sell, OrderExit.FromAll)); sellOrderCutLoss = OrderCreator.MarketNextBar(new SOrderParameters(Contracts.Default, "Cut Loss Exit", EOrderAction.Sell, OrderExit.FromAll)); rsi = new RSI(this); kRatioBarsMathShort = new K_RatioBarsMath(this); kRatioBarsMathLong = new K_RatioBarsMath(this); }
public TickerHandler(IExchangeTickerReader tickerReader, RSI trades) { _trades = trades; _tickerReader = tickerReader; _tickerReader.PoolingInterval = 4280; //provides 14 readings in a minute _tickerReader.TickerReady += _tickerReader_TickerReady; _tickerReader.OnError += _tickerReader_OnError; _trades.IndicatorReady += _trades_IndicatorReady; }
public RSIHighLow(BarItemType barType) { this.barType = barType; this.identityCode = string.Format("{0}({1})", IDENTITY_CODE, barType.Code); rsi = new RSI(barType, 14); Register(rsi); }
public RSITargets(QREBridgeBase bridge, Symbol symbol) : base(bridge, symbol) { atr = new AverageTrueRangeEW(bars, parameter <int>("ATRLen")); rsiSpud = new RSI(bars.close, parameter <int>("HalfLife")); entryLevel = parameter <double>("EntryLevel"); exitLevel = parameter <double>("ExitLevel"); stoppedFlag = false; lastDirection = 0; lastStop = 0; }
protected override void OnCalculate() { ADX adx = ADX(14); EMA ema = EMA(20); RSI rsi = RSI(14, 3); double singnaldata = 0; if (adx[0] > 30 && adx[0] > adx[1] && InSeries[0] <= ema[0]) { Color color = Color.Green; if (rsi[0] <= 30) { color = Color.LightGreen; singnaldata = 1; } else { singnaldata = 0.5; } AddChartArrowUp("ArrowLong_Entry" + +Bars[0].Time.Ticks, this.IsAutoAdjustableScale, 0, Bars[0].Low, color); } //ADX adx = ADX(14); //EMA ema = EMA(20); //double singnaldata = 0; //if (adx[0] > 30 && adx[0] > adx[1] && InSeries[0] <= ema[0]) //{ // singnaldata = 1; // AddChartArrowUp("ArrowLong_Entry" + +Bars[0].Time.Ticks, this.IsAutoAdjustableScale, 0, Bars[0].Low, Color.Green); //} SignalLine.Set(singnaldata); PlotLine_ADX.Set(adx[0]); PlotLine_XMA.Set(ema[0]); PlotColors[0][0] = this.Plot0Color; OutputDescriptors[0].PenStyle = this.Dash0Style; OutputDescriptors[0].Pen.Width = this.Plot0Width; PlotColors[1][0] = this.Plot1Color; OutputDescriptors[1].PenStyle = this.Dash1Style; OutputDescriptors[1].Pen.Width = this.Plot1Width; PlotColors[2][0] = this.Plot1Color; OutputDescriptors[2].PenStyle = this.Dash1Style; OutputDescriptors[2].Pen.Width = this.Plot1Width; }
public void RSI() { RSI rsi = new RSI(14); rsi.Load(Directory.GetCurrentDirectory() + "\\vas.csv"); RSISerie serie = rsi.Calculate(); Assert.IsNotNull(serie); //Assert.IsTrue(serie.rsiDataPoint.RS.Count > 0); //Assert.IsTrue(serie.rsiDataPoint.RSI.Count > 0); }
protected override void Create(){ m_RSI = new RSI(this); m_myrsi = new VariableSeries<Double>(this); m_RsiSE = OrderCreator.MarketNextBar(new SOrderParameters(Contracts.Default, "RsiSE", EOrderAction.SellShort)); }
public static void RSI() { string fn = CONFIG.SERVER_PATH + "Data/Item/Info/ItemInfo03.rsi"; var rsi = new RSI(new ByteReader(File.ReadAllBytes(fn), ENC.KR)); var item = new RSI.Item() { ShopDescription = "", InventoryDescription = "" }; SetCommonItemFields(item); rsi.Items.Add(item); File.WriteAllBytes(fn, rsi.Save(new ByteWriter(ENC.KR)).ToByteArray()); }