| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566 |
- using MuchInfo.Chart.Data.Interfaces;
- using MuchInfo.Chart.WPF.Primitives.Interfaces;
- using System;
- using System.Diagnostics;
- namespace MuchInfo.Chart.WPF.Primitives.Drawing
- {
- public abstract class Drawing2PointLinkedBase : Drawing2PointBase
- {
- protected Drawing2PointLinkedBase()
- {
- }
- public abstract override bool CanPlotOnAllSymbols();
- protected ILineDataSetWithUid GetLinkedPlot()
- {
- bool flag = this.mLastScale != null && this.mLastScale.AllPlots.Count > 0;
- ILineDataSetWithUid result;
- if (flag)
- {
- PlotBase plotBase = this.mLastScale.AllPlots[0];
- flag = (plotBase is LinePlot);
- if (flag)
- {
- result = ((LinePlot)plotBase).LinePlot_4866();
- return result;
- }
- }
- result = null;
- return result;
- }
- protected void CalcHighLowForPoints(DateTime date1, DateTime date2, ref float High, ref float Low)
- {
- ILineDataSet linkedPlot = this.GetLinkedPlot();
- bool flag = linkedPlot == null;
- checked
- {
- if (!flag)
- {
- int num = -1;
- int num2 = -1;
- DateTime dateTime = date1;
- DateTime dateTime2 = date2;
- flag = (DateTime.Compare(dateTime, dateTime2) > 0);
- if (flag)
- {
- DateTime dateTime3 = dateTime;
- dateTime = dateTime2;
- dateTime2 = dateTime3;
- }
- int num3 = linkedPlot.DataPoints.Count - 1;
- while (true)
- {
- int arg_E8_0 = num3;
- int num4 = 0;
- if (arg_E8_0 < num4)
- {
- break;
- }
- flag = (num2 == -1 && DateTime.Compare(linkedPlot.DataPoints[num3].Date, dateTime2) <= 0);
- if (flag)
- {
- num2 = num3;
- }
- flag = (num == -1 && DateTime.Compare(linkedPlot.DataPoints[num3].Date, dateTime) <= 0);
- if (flag)
- {
- num = num3;
- }
- flag = (num2 >= 0 && num >= 0);
- if (flag)
- {
- break;
- }
- num3 += -1;
- }
- flag = (num == -1 || num2 == -1);
- if (!flag)
- {
- int arg_10B_0 = num;
- int num5 = num2;
- int num6 = arg_10B_0;
- while (true)
- {
- int arg_24B_0 = num6;
- int num4 = num5;
- if (arg_24B_0 > num4)
- {
- break;
- }
- flag = (num6 == num);
- if (flag)
- {
- bool flag2 = linkedPlot.DataPoints[num6] is IOHLCDataPoint;
- if (flag2)
- {
- High = ((IOHLCDataPoint)linkedPlot.DataPoints[num6]).High;
- Low = ((IOHLCDataPoint)linkedPlot.DataPoints[num6]).Low;
- }
- else
- {
- High = linkedPlot.DataPoints[num6].Value;
- Low = linkedPlot.DataPoints[num6].Value;
- }
- }
- else
- {
- bool flag2 = linkedPlot.DataPoints[num6] is IOHLCDataPoint;
- if (flag2)
- {
- High = Math.Max(High, ((IOHLCDataPoint)linkedPlot.DataPoints[num6]).High);
- Low = Math.Min(Low, ((IOHLCDataPoint)linkedPlot.DataPoints[num6]).Low);
- }
- else
- {
- High = Math.Max(High, linkedPlot.DataPoints[num6].Value);
- Low = Math.Min(Low, linkedPlot.DataPoints[num6].Value);
- }
- }
- num6++;
- }
- }
- }
- }
- }
- protected void CalcRegressionForPoints(DateTime Date1, DateTime Date2, ref float Val1, ref float Val2)
- {
- ILineDataSet linkedPlot = this.GetLinkedPlot();
- bool flag = linkedPlot == null;
- checked
- {
- if (!flag)
- {
- int num = -1;
- int num2 = -1;
- DateTime dateTime = Date1;
- DateTime dateTime2 = Date2;
- bool flag2 = false;
- flag = (DateTime.Compare(dateTime, dateTime2) > 0);
- if (flag)
- {
- flag2 = true;
- DateTime dateTime3 = dateTime;
- dateTime = dateTime2;
- dateTime2 = dateTime3;
- }
- int num3 = linkedPlot.DataPoints.Count - 1;
- while (true)
- {
- int arg_F3_0 = num3;
- int num4 = 0;
- if (arg_F3_0 < num4)
- {
- break;
- }
- flag = (num2 == -1 && DateTime.Compare(linkedPlot.DataPoints[num3].Date, dateTime2) <= 0);
- if (flag)
- {
- num2 = num3;
- }
- flag = (num == -1 && DateTime.Compare(linkedPlot.DataPoints[num3].Date, dateTime) <= 0);
- if (flag)
- {
- num = num3;
- }
- flag = (num2 >= 0 && num >= 0);
- if (flag)
- {
- break;
- }
- num3 += -1;
- }
- flag = (num == -1 || num2 == -1);
- if (!flag)
- {
- int num5 = num2 - num + 1;
- flag = (num5 == 0);
- if (!flag)
- {
- int arg_12F_0 = num;
- int num6 = num2;
- int num7 = arg_12F_0;
- double num9 = 0;
- double num10 = 0;
- double num11 = 0;
- double num12 = 0;
- while (true)
- {
- int arg_19D_0 = num7;
- int num4 = num6;
- if (arg_19D_0 > num4)
- {
- break;
- }
- int num8 = num7 - num + 1;
- unchecked
- {
- num9 += (double)num8;
- num10 += (double)linkedPlot.DataPoints[num7].Value;
- num11 += (double)(linkedPlot.DataPoints[num7].Value * (float)num8);
- num12 += Math.Pow((double)num8, 2.0);
- }
- num7++;
- }
- unchecked
- {
- flag = ((double)num5 * num12 - Math.Pow(num9, 2.0) == 0.0);
- if (!flag)
- {
- double num13 = ((double)num5 * num11 - num9 * num10) / ((double)num5 * num12 - Math.Pow(num9, 2.0));
- double num14 = (num10 - num13 * num9) / (double)num5;
- flag = flag2;
- if (flag)
- {
- Val2 = (float)(num13 * 1.0 + num14);
- Val1 = (float)(num13 * (double)num5 + num14);
- }
- else
- {
- Val1 = (float)(num13 * 1.0 + num14);
- Val2 = (float)(num13 * (double)num5 + num14);
- }
- }
- }
- }
- }
- }
- }
- }
- protected float CalcRaffRegressionForPoints(DateTime Date1, DateTime Date2, ref float Val1, ref float Val2)
- {
- ILineDataSet linkedPlot = this.GetLinkedPlot();
- bool flag = linkedPlot == null;
- checked
- {
- float result = 0f;
- if (!flag)
- {
- int num = -1;
- int num2 = -1;
- DateTime dateTime = Date1;
- DateTime dateTime2 = Date2;
- bool flag2 = false;
- flag = (DateTime.Compare(dateTime, dateTime2) > 0);
- if (flag)
- {
- flag2 = true;
- DateTime dateTime3 = dateTime;
- dateTime = dateTime2;
- dateTime2 = dateTime3;
- }
- int num3 = linkedPlot.DataPoints.Count - 1;
- while (true)
- {
- int arg_F8_0 = num3;
- int num4 = 0;
- if (arg_F8_0 < num4)
- {
- break;
- }
- flag = (num2 == -1 && DateTime.Compare(linkedPlot.DataPoints[num3].Date, dateTime2) <= 0);
- if (flag)
- {
- num2 = num3;
- }
- flag = (num == -1 && DateTime.Compare(linkedPlot.DataPoints[num3].Date, dateTime) <= 0);
- if (flag)
- {
- num = num3;
- }
- flag = (num2 >= 0 && num >= 0);
- if (flag)
- {
- break;
- }
- num3 += -1;
- }
- flag = (num == -1 || num2 == -1);
- if (!flag)
- {
- int num5 = num2 - num + 1;
- flag = (num5 == 0);
- if (!flag)
- {
- int arg_134_0 = num;
- int num6 = num2;
- int num7 = arg_134_0;
- double num9 = 0;
- double num10 = 0;
- double num11 = 0;
- double num12 = 0;
- while (true)
- {
- int arg_1A2_0 = num7;
- int num4 = num6;
- if (arg_1A2_0 > num4)
- {
- break;
- }
- int num8 = num7 - num + 1;
- unchecked
- {
- num9 += (double)num8;
- num10 += (double)linkedPlot.DataPoints[num7].Value;
- num11 += (double)(linkedPlot.DataPoints[num7].Value * (float)num8);
- num12 += Math.Pow((double)num8, 2.0);
- }
- num7++;
- }
- unchecked
- {
- flag = ((double)num5 * num12 - Math.Pow(num9, 2.0) == 0.0);
- if (!flag)
- {
- double num13 = ((double)num5 * num11 - num9 * num10) / ((double)num5 * num12 - Math.Pow(num9, 2.0));
- double num14 = (num10 - num13 * num9) / (double)num5;
- flag = flag2;
- if (flag)
- {
- Val2 = (float)(num13 * 1.0 + num14);
- Val1 = (float)(num13 * (double)num5 + num14);
- }
- else
- {
- Val1 = (float)(num13 * 1.0 + num14);
- Val2 = (float)(num13 * (double)num5 + num14);
- }
- float num15 = 0f;
- int arg_257_0 = num;
- int num16 = num2;
- int num17 = arg_257_0;
- while (true)
- {
- int arg_328_0 = num17;
- int num4 = num16;
- if (arg_328_0 > num4)
- {
- break;
- }
- float num18 = (float)(num13 * (double)checked(num17 - num + 1) + num14);
- flag = (linkedPlot.DataPoints[num17] is IOHLCDataPoint);
- float num19;
- float num20;
- if (flag)
- {
- num19 = Math.Abs(num18 - ((IOHLCDataPoint)linkedPlot.DataPoints[num17]).High);
- num20 = Math.Abs(num18 - ((IOHLCDataPoint)linkedPlot.DataPoints[num17]).Low);
- }
- else
- {
- num19 = Math.Abs(num18 - linkedPlot.DataPoints[num17].Value);
- num20 = Math.Abs(num18 - linkedPlot.DataPoints[num17].Value);
- }
- num15 = Math.Max(num15, Math.Max(num19, num20));
- checked
- {
- num17++;
- }
- }
- result = num15;
- }
- }
- }
- }
- }
- return result;
- }
- }
- protected float StandardDeviationBetweenPoints(DateTime Date1, DateTime Date2)
- {
- ILineDataSet linkedPlot = this.GetLinkedPlot();
- bool flag = linkedPlot == null;
- checked
- {
- float result = 0f;
- if (!flag)
- {
- int num = -1;
- int num2 = -1;
- DateTime dateTime = Date1;
- DateTime dateTime2 = Date2;
- flag = (DateTime.Compare(dateTime, dateTime2) > 0);
- if (flag)
- {
- DateTime dateTime3 = dateTime;
- dateTime = dateTime2;
- dateTime2 = dateTime3;
- }
- int num3 = linkedPlot.DataPoints.Count - 1;
- while (true)
- {
- int arg_F3_0 = num3;
- int num4 = 0;
- if (arg_F3_0 < num4)
- {
- break;
- }
- flag = (num2 == -1 && DateTime.Compare(linkedPlot.DataPoints[num3].Date, dateTime2) <= 0);
- if (flag)
- {
- num2 = num3;
- }
- flag = (num == -1 && DateTime.Compare(linkedPlot.DataPoints[num3].Date, dateTime) <= 0);
- if (flag)
- {
- num = num3;
- }
- flag = (num2 >= 0 && num >= 0);
- if (flag)
- {
- break;
- }
- num3 += -1;
- }
- flag = (num == -1 || num2 == -1);
- if (!flag)
- {
- int num5 = num2 - num + 1;
- flag = (num5 == 0);
- if (!flag)
- {
- int arg_12F_0 = num;
- int num6 = num2;
- int num7 = arg_12F_0;
- double num8 = 0;
- while (true)
- {
- int arg_15A_0 = num7;
- int num4 = num6;
- if (arg_15A_0 > num4)
- {
- break;
- }
- unchecked
- {
- num8 += (double)linkedPlot.DataPoints[num7].Value;
- }
- num7++;
- }
- double num9 = num8 / (double)num5;
- int arg_168_0 = num;
- int num10 = num2;
- int num11 = arg_168_0;
- double num12 = 0;
- while (true)
- {
- int arg_1A3_0 = num11;
- int num4 = num10;
- if (arg_1A3_0 > num4)
- {
- break;
- }
- unchecked
- {
- num12 += Math.Pow((double)linkedPlot.DataPoints[num11].Value - num9, 2.0);
- }
- num11++;
- }
- num12 = Math.Abs(num12 / (double)num5);
- result = (float)Math.Sqrt(num12);
- }
- }
- }
- return result;
- }
- }
- protected float StandardErrorBetweenPoints(DateTime Date1, DateTime Date2)
- {
- ILineDataSet linkedPlot = this.GetLinkedPlot();
- bool flag = linkedPlot == null;
- checked
- {
- float result = 0f;
- if (!flag)
- {
- int num = -1;
- int num2 = -1;
- DateTime dateTime = Date1;
- DateTime dateTime2 = Date2;
- flag = (DateTime.Compare(dateTime, dateTime2) > 0);
- if (flag)
- {
- DateTime dateTime3 = dateTime;
- dateTime = dateTime2;
- dateTime2 = dateTime3;
- }
- int num3 = linkedPlot.DataPoints.Count - 1;
- while (true)
- {
- int arg_F3_0 = num3;
- int num4 = 0;
- if (arg_F3_0 < num4)
- {
- break;
- }
- flag = (num2 == -1 && DateTime.Compare(linkedPlot.DataPoints[num3].Date, dateTime2) <= 0);
- if (flag)
- {
- num2 = num3;
- }
- flag = (num == -1 && DateTime.Compare(linkedPlot.DataPoints[num3].Date, dateTime) <= 0);
- if (flag)
- {
- num = num3;
- }
- flag = (num2 >= 0 && num >= 0);
- if (flag)
- {
- break;
- }
- num3 += -1;
- }
- flag = (num == -1 || num2 == -1);
- if (!flag)
- {
- int num5 = num2 - num + 1;
- flag = (num5 == 0);
- if (!flag)
- {
- int arg_12F_0 = num;
- int num6 = num2;
- int num7 = arg_12F_0;
- double num8 = 0;
- while (true)
- {
- int arg_15A_0 = num7;
- int num4 = num6;
- if (arg_15A_0 > num4)
- {
- break;
- }
- unchecked
- {
- num8 += (double)linkedPlot.DataPoints[num7].Value;
- }
- num7++;
- }
- double num9 = num8 / (double)num5;
- int arg_168_0 = num;
- int num10 = num2;
- int num11 = arg_168_0;
- double num12 = 0;
- while (true)
- {
- int arg_1A3_0 = num11;
- int num4 = num10;
- if (arg_1A3_0 > num4)
- {
- break;
- }
- unchecked
- {
- num12 += Math.Pow((double)linkedPlot.DataPoints[num11].Value - num9, 2.0);
- }
- num11++;
- }
- num12 = Math.Abs(num12 / (double)num5);
- result = (float)(Math.Sqrt(num12) / Math.Sqrt((double)num5));
- }
- }
- }
- return result;
- }
- }
- }
- }
|