override protected void StrategyExecute() { MACD macd = Indicators.MACD.Series(data.Close, parameters[0], parameters[1], parameters[2], ""); ADX adx = new ADX(data.Bars, parameters[3], ""); double delta = 0, lastDelta = 0; for (int idx = 1; idx < macd.Values.Length; idx++) { delta = (macd.HistSeries[idx] - macd.HistSeries[idx - 1]); //If there is a trend if (adx[idx] > 25) { if (delta > 0 && lastDelta < 0) { BuyAtClose(idx); } } if (delta < 0 && lastDelta > 0) { SellAtClose(idx); } lastDelta = delta; } }
public override void Initialization() { try { //Создаем индикаторы для торговой стратегии _upperChannelOne = new Highest((int)Parameter(1)); _lowerChannelOne = new Lowest((int)Parameter(1)); _upperChannelTwo = new Highest((int)Parameter(1) / 2); //50% от P1 _lowerChannelTwo = new Lowest((int)Parameter(1) / 2); //50% от P1 _adxLookBack = new ADX((int)Parameter(2)); _adxThreshold = new ADX((int)Parameter(3)); _atr = new ATR((int)Parameter(4)); _atrStop = (int)Parameter(5); _volume = (int)Parameter(6); //Для выставления лимитных заявок в рынок для гарантированного исполнения _offset = GetSecurity().Tick *10; //Инициализируем алгоритмические заявки InitializationAlgoOrders(); //Подписываемся на события при инициализации стратегии Subscribe(); } catch (Exception ex) { ExceptionMessage(ex, "Strategy"); } }
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); } }
public override void GetAll(IIndicatorValues Ind) { int period = (int)this.IndicatorParameters.List[0]; decimal thresholdADX = (decimal)this.IndicatorParameters.List[1]; if (!Ind.ADXSimple(period, thresholdADX).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 ADX(thresholdADX); } else { prototype = (ADX)Ind.ADXSimple(period, thresholdADX)[1].Clone(); } Get(ref prototype, Ind); Ind.ADXSimple(period, thresholdADX)[0] = (ADX)prototype; Ind.ADXSimple(period, thresholdADX).IsPopulated = true; // set here so instance is guaranteed to exits } Ind.Bar.CurrentBar = oldCurrentBar; } }
public async Task<IndADXEntity[]> GetADX(string code, int start = 0, int end = 0, int period = 14, string type = "day") { TickerEntity[] tickers = await base.getTickerEntityArray(code, start, end, type); List<IndADXEntity> outList = new List<IndADXEntity>(); int len = tickers.Length; double[] close = tickers.Select(t => (double)t.C).ToArray(); double[] high = tickers.Select(t => (double)t.H).ToArray(); double[] low = tickers.Select(t => (double)t.L).ToArray(); double?[] outADX = new double?[len]; double?[] outDi_P = new double?[len]; double?[] outDi_M = new double?[len]; ADX.Calculate(high, low, close, outDi_P, outDi_M, outADX, period); for (int i = 0; i < len; i++) { outList.Add(new IndADXEntity { T = tickers[i].T, P = tickers[i].P, Di_plus = outDi_P[i], Di_minus = outDi_M[i], Adx = outADX[i] }); } return outList.Where(r => (start == 0 || r.P >= start) && (end == 0 || r.P <= end)).ToArray(); }
public void TestCalculateRealData() { TickerBLL tbll = new TickerBLL(_unit); List <Ticker> tList = tbll.GetTickerListByShareDB(1585, null, 21100000); double[] close = new double[tList.Count]; double[] h = new double[tList.Count]; double[] lo = new double[tList.Count]; double?[] adx = new double?[tList.Count]; double?[] diPlus = new double?[tList.Count]; double?[] diMinus = new double?[tList.Count]; var i = 0; foreach (var t in tList) { close[i] = t.Close; h[i] = t.High; lo[i] = t.Low; i++; } ADX.Calculate(h, lo, close, diPlus, diMinus, adx); }
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); } }
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 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 ArsalanADXandMACD(BarItemType barType) { this.barType = barType; this.identityCode = string.Format("{0}({1})", IDENTITY_CODE, barType.Code); macd = new MACD(barType, 3, 10, 18); adx = new ADX(barType, 18); Register(macd, adx); }
public PSARandADX(BarItemType barType) { this.barType = barType; this.identityCode = string.Format("{0}({1})", IDENTITY_CODE, barType.Code); psar = new ParabolicSAR(barType, 5); adx = new ADX(barType, 50); Register(psar, adx); }
public ArsalanADXandEMACross(BarItemType barType) { this.barType = barType; this.identityCode = string.Format("{0}({1})", IDENTITY_CODE, barType.Code); ema3 = new EMA(barType, 3); ema10 = new EMA(barType, 10); adx = new ADX(barType, 14); Register(ema3, ema10, adx); }
public ADXPower(BarItemType barType) { this.barType = barType; this.identityCode = string.Format("{0}({1})", IDENTITY_CODE, barType.Code); ema9 = new EMA(barType, 9); ema26 = new EMA(barType, 26); adx = new ADX(barType, 14); Register(ema9, ema26, adx); }
private async void PlaySelectedTrack() { var track = GetSelectedTrack(TrackType.Track); var cue = GetSelectedCue(); if (track != null && cue != null) { if (track.WaveformWrapper != null) { var afs2Entry = AcbFile.AcbFile.GetAfs2Entry((track.WaveformWrapper.WaveformRef != null) ? track.WaveformWrapper.WaveformRef.AwbId : ushort.MaxValue); if (afs2Entry != null) { audioPlayer.Stop(); switch (track.WaveformWrapper.WaveformRef.EncodeType) { case EncodeType.HCA: case EncodeType.HCA_ALT: await audioPlayer.AsyncSetHcaAudio(afs2Entry.bytes); break; case EncodeType.ADX: audioPlayer.SetAudio(ADX.Decode(afs2Entry.bytes)); break; case EncodeType.ATRAC9: audioPlayer.SetAudio(AT9.Decode(afs2Entry.bytes)); break; } //Set volume float cueBaseVolume = cue.GetBaseVolume(); float cueRandom = cue.GetRandomVolume(); float trackBasekVolume = track.GetBaseVolume(); float trackRandom = track.GetRandomVolume(); float cueVolume = cueBaseVolume + Xv2CoreLib.Random.Range(0, cueRandom); float trackVolume = trackBasekVolume + Xv2CoreLib.Random.Range(0, trackRandom); float finalVolume = ((trackVolume * cueVolume) > 1f) ? 1f : trackVolume * cueVolume; audioPlayer.SetVolume(finalVolume); //Play audioPlayer.Play(); //Force Update UI CommandManager.InvalidateRequerySuggested(); } } } }
protected override void OnBarUpdate() { if (CurrentBar < BarsRequiredToTrade) { return; } // Note: Bars are added to the BarsArray and can be accessed via an index value // E.G. BarsArray[1] ---> Accesses the 1 minute Bars added above if (adx1 == null) { adx1 = ADX(BarsArray[1], 14); } // OnBarUpdate() will be called on incoming tick events on all Bars objects added to the strategy // We only want to process events on our primary Bars object (main instrument) (index = 0) which // is set when adding the strategy to a chart if (BarsInProgress != 0) { return; } if (CurrentBars[0] < 0 || CurrentBars[1] < 0) { return; } // Checks if the 14 period ADX on both instruments are trending (above a value of 30) if (adx[0] > 30 && adx1[0] > 30) { // If RSI crosses above a value of 30 then enter a long position via a limit order if (CrossAbove(rsi, 30, 1)) { // Draws a square 1 tick above the high of the bar identifying when a limit order is issued Draw.Square(this, "My Square" + CurrentBar, false, 0, High[0] + TickSize, Brushes.DodgerBlue); // Enter a long position via a limit order at the current ask price //EnterLongLimit(GetCurrentAsk(), "RSI"); Print(String.Format("{0}: IsUnmanaged={1}", CurrentBar, IsUnmanaged)); //EnterLong(1); EnterLong(0, 1, "RSI"); EnterShort(1, 5, "RSI"); } } // Any open long position will exit if RSI crosses below a value of 75 // This is in addition to the trail stop set in the OnStateChange() method under State.Configure if (CrossBelow(rsi, 75, 1)) { //ExitLong(); ExitLong(0, 1, "ExitRSI", "RSI"); ExitShort(1, 5, "ExitRSI", "RSI"); } }
protected override string GetPresentDetail(IOutputInstant Instant, IIndicatorValues Data, IndicatorParameters IndicatorParameters) { ADX adx = Data.ADXSimple(IndicatorParameters)[Instant.ExposureDate]; if (adx != null) { return(String.Format("{0}|{1}|{2}|{3}|{4}|", adx.MinusDI, adx.PlusDI, adx.ADXValue, (int)adx.Trendiness, adx.Trendiness)); } else { return(String.Format("{0}|{1}|{2}|{3}|{4}|", "", "", "", "", "")); } }
public ThoseFourIndicators(BarItemType barType) { this.barType = barType; this.identityCode = string.Format("{0}({1})", IDENTITY_CODE, barType.Code); cci = new CCI(barType, 14); stoch = new Stochastics(barType, 14, 2, 2); macd = new MACD(barType, 8, 40, 8); adx = new ADX(barType, 14); Register(cci, stoch, macd, adx); }
/// <summary> /// Initializes a new instance of the <see cref="ProcessingTrees"/> class. /// </summary> /// <param name="document">The ADX document.</param> public ProcessingTrees(ADX document, ValidationEventCallback onValidationEvent) { // Add the validation callback this.OnValidationEvent += this.OnValidationEventSink; if (onValidationEvent != null) { this.OnValidationEvent += onValidationEvent; } m_document = document; Build(); // Build the processing trees }
public void ADX() { ADX adx = new ADX(); adx.Load(OhlcList); ADXSerie serie = adx.Calculate(); Assert.IsNotNull(serie); Assert.IsTrue(serie.ADX.Count > 0); Assert.IsTrue(serie.DINegative.Count > 0); Assert.IsTrue(serie.DIPositive.Count > 0); Assert.IsTrue(serie.DX.Count > 0); Assert.IsTrue(serie.TrueRange.Count > 0); }
public void ADX() { ADX adx = new ADX(); adx.Load(Directory.GetCurrentDirectory() + "\\table.csv"); ADXSerie serie = adx.Calculate(); Assert.IsNotNull(serie); Assert.IsTrue(serie.ADX.Count > 0); Assert.IsTrue(serie.DINegative.Count > 0); Assert.IsTrue(serie.DIPositive.Count > 0); Assert.IsTrue(serie.DX.Count > 0); Assert.IsTrue(serie.TrueRange.Count > 0); }
public void TestADX() { double[] high = new double[] { 30.20, 30.28, 30.45, 29.35, 29.35, 29.29, 28.83, 28.73, 28.67, 28.85, 28.64, 27.68, 27.21, 26.87, 27.41, 26.94, 26.52, 26.52, 27.09, 27.69, 28.45, 28.53, 28.67, 29.01, 29.87, 29.80, 29.75, 30.65, 30.60, 30.76, 31.17, 30.89, 30.04, 30.66, 30.60, 31.97, 32.10, 32.03, 31.63, 31.85, 32.71 }; double[] low = new double[] { 29.41, 29.32, 29.96, 28.74, 28.56, 28.41, 28.08, 27.43, 27.66, 27.83, 27.40, 27.09, 26.18, 26.13, 26.63, 26.13, 25.43, 25.35, 25.88, 26.96, 27.14, 28.01, 27.88, 27.99, 28.76, 29.14, 28.71, 28.93, 30.03, 29.39, 30.14, 30.43, 29.35, 29.99, 29.52, 30.94, 31.54, 31.36, 30.92, 31.20, 32.13 }; double[] close = new double[] { 29.87, 30.24, 30.10, 28.90, 28.92, 28.48, 28.56, 27.56, 28.47, 28.28, 27.49, 27.23, 26.35, 26.33, 27.03, 26.22, 26.01, 25.46, 27.03, 27.45, 28.36, 28.43, 27.95, 29.01, 29.38, 29.36, 28.91, 30.61, 30.05, 30.19, 31.12, 30.54, 29.78, 30.04, 30.49, 31.47, 32.05, 31.97, 31.13, 31.66, 32.64 }; int len = close.Length; double?[] outDiPlus = new double?[len]; double?[] outDiMinus = new double?[len]; double?[] outADX = new double?[len]; ADX.Calculate(high, low, close, outDiPlus, outDiMinus, outADX); Console.WriteLine("di plus: " + ObjectHelper.ToJson(outADX)); }
public void CanSerializeToXml_ADX() { var source = new ADX { Symbol = "A", Date = DateTime.Today, ADX14 = 12.0 }; var i = source.ToIndicator(); var target = EntityHelper.DeserializeFromXml <ADX> (i.Data); Assert.IsTrue(source.Symbol == target.Symbol); Assert.IsTrue(source.Date == target.Date); Assert.IsTrue(source.ADX14 == target.ADX14); }
/// <summary> /// Initializes a new instance of the <see cref="AssayResults"/> class. /// </summary> /// <param name="document">The ADX document.</param> public AssayResults(ADX document, ValidationEventCallback onValidationEvent) { // Add the validation callback this.OnValidationEvent += this.OnValidationEventSink; if (onValidationEvent != null) { this.OnValidationEvent += onValidationEvent; } m_document = document; // Build the processing trees for this ADX document. m_processingTrees = new ProcessingTrees(this.Document, onValidationEvent); // Bind the analyses and measurements to the assay results list. this.Bind(); }
public Indicator AnalyzeData(DataState state) { double[] highPrices = _analyseRepo.LoadHighPriceBySymbol(state.Symbol, true).ToArray(); double[] lowPrices = _analyseRepo.LoadLowPriceBySymbol(state.Symbol, true).ToArray(); double[] closePrices = _analyseRepo.LoadClosePriceBySymbol(state.Symbol, true).ToArray(); double[] adxValues = ADXCalculator.CalculateADX(ADXCalculator.Period, highPrices, lowPrices, closePrices); if (adxValues.Length == 0) { return(null); } ADX value = new ADX(); value.Symbol = state.Symbol; value.Date = state.Last.Value; value.ADX14 = AlgorithmHelper.GetLast(adxValues); return(value.ToIndicator()); }
/// <summary> /// Initialise a processing tree for a collection of samples. /// </summary> /// <param name="ADX">The ADX document.</param> /// <param name="refs">The list of sample references.</param> public ProcessingTree(ADX document, SampleReference[] refs, Validation.ValidationEventCallback onValidationEvent) { // Add the validation callback if (onValidationEvent != null) { this.OnValidationEvent += onValidationEvent; } m_document = document; // Set the ADX document // Copy the sample references foreach (SampleReference sampleRef in refs) { SampleReference copyRef = new SampleReference(); copyRef.IdRef = sampleRef.IdRef; m_sampleIds.Add(copyRef); } }
/// <summary> /// Checks the ADX file against the rules for a valid laboratory export. /// </summary> /// <param name="fileName">Name of the file.</param> public void Check(String fileName) { try { ADX document = ADX.Load(fileName); CheckHeader(document); CheckChainOfCustody(document); CheckSamples(document); CheckResults(document); AssayResults assayResults = new AssayResults(document, OnValidationEvent); } catch (System.Exception exc) { } }
/// <summary> /// Checks the ADX results. /// </summary> /// <param name="document">The ADX document.</param> private void CheckResults(ADX document) { // Is there a results section defined ? if (document.Results == null) { this.Add(new ValidationResult(ErrorCodes.Results, ErrorLevel.Error, Languages.Strings.valNoResults)); return; } // Are there processing groups in the results section ? if (document.Results.ProcessingGroup == null) { this.Add(new ValidationResult(ErrorCodes.Results, ErrorLevel.Error, Languages.Strings.valNoResultsProcessingGroups)); return; } // Does each processing group contain results ? foreach (ProcessingGroup processingGroup in document.Results.ProcessingGroup) { // Does it have an ID ? if (String.IsNullOrEmpty(processingGroup.Id)) { this.Add(new ValidationResult(ErrorCodes.Results, ErrorLevel.Warning, Languages.Strings.valNoIdForProcessingGroup)); } // Any results ? if (processingGroup.Result == null) { this.Add(new ValidationResult(ErrorCodes.Results, ErrorLevel.Error, String.Format(Languages.Strings.valNoResultsResult, processingGroup.ToString()))); } else { // Check each result foreach (Result result in processingGroup.Result) { CheckResult(document, result); } } } }
override protected void StrategyExecute() { MACD macd = Indicators.MACD.Series(data.Close, parameters[0], parameters[1], parameters[2], ""); ADX adx = new ADX(data.Bars, parameters[3], ""); int cutlosslevel = (int)parameters[4]; int takeprofitlevel = (int)parameters[5]; double delta = 0, lastDelta = 0; for (int idx = 1; idx < macd.Values.Length; idx++) { delta = (macd.HistSeries[idx] - macd.HistSeries[idx - 1]); //If there is a trend if (adx[idx] > 25) { if (delta > 0 && lastDelta < 0) { BuyAtClose(idx); } } if (delta < 0 && lastDelta > 0) { SellAtClose(idx); } if (is_bought && CutLossCondition(data.Close[idx], buy_price, cutlosslevel)) { SellCutLoss(idx); } if (is_bought && TakeProfitCondition(data.Close[idx], buy_price, takeprofitlevel)) { SellTakeProfit(idx); } lastDelta = delta; } }
public override void OnStrategyStart() { sma = new SMA(Bars, SMALength); sma.Color = Color.Yellow; Draw(sma, 0); // if required, set up the RAVI moving average if (FilterType == FilterType.RAVI) { shortSMA = new SMA(Bars, ShortSMALength); shortSMA.Color = Color.Pink; Draw(shortSMA, 0); } //if required, set up the ADX moving average if (FilterType == FilterType.ADX) { // ADX is a builtin function, like SMA adx = new ADX(Bars, ADXLength); adx.Color = Color.Wheat; Draw(adx, 2); } }
/// <summary> /// Checks the single ADX result. /// </summary> /// <param name="document">The ADX document.</param> /// <param name="result">The ADX result.</param> private void CheckResult(ADX document, Result result) { String sampleIdentifier = result.ToString(); // No processing history defined ? if (result.ProcessingHistory == null) { this.Add(new ValidationResult(ErrorCodes.Results, ErrorLevel.Error, String.Format(Languages.Strings.valNoResultProcessingHistory, sampleIdentifier))); } // Any sample references ? if (result.Sample == null || result.Sample.Length == 0) { this.Add(new ValidationResult(ErrorCodes.Results, ErrorLevel.Error, String.Format(Languages.Strings.valNoSampleRefDefinedForResult, sampleIdentifier))); } // Does each sample reference refer to a sample ? else if (document.Samples != null) { foreach (SampleReference sampleRef in result.Sample) { if (document.Samples.Find(sampleRef) == null) { this.Add(new ValidationResult(ErrorCodes.Results, ErrorLevel.Error, String.Format(Languages.Strings.valUnknownResultSampleRef, sampleRef.IdRef))); } } } // Check each result analysis record if (result.Analysis != null) { foreach (AnalysisRecord analysisRecord in result.Analysis) { CheckAnalysisRecord(document, result, analysisRecord); } } }