/// <summary> /// Resets the highscore save files, variables, and labels. /// </summary> private void ResetHighScores() { StreamWriter HS; HS = File.CreateText("EasyHighScore.txt"); HS.WriteLine(0); Thread.Sleep(50); HS.Close(); StreamWriter HS2; HS2 = File.CreateText("MediumHighScore.txt"); HS2.WriteLine(0); Thread.Sleep(50); HS2.Close(); StreamWriter HS3; HS3 = File.CreateText("HardHighScore.txt"); HS3.WriteLine(0); Thread.Sleep(50); HS3.Close(); StreamWriter HS4; HS4 = File.CreateText("CustomHighScore.txt"); HS4.WriteLine(0); Thread.Sleep(50); HS4.Close(); LoadHighScores(); }
protected override void OnBarUpdate() { if (CurrentBars[0] < 121) { return; } if (Bars == null) { return; } if (!Data.BarsType.GetInstance(Bars.Period.Id).IsIntraday) { return; } if (Bars.Period.Id == PeriodType.Minute && Bars.Period.Value > minutes / 2) { return; } if (!isLoaded && !isInit) { isInit = true; hourlyBars = Data.Bars.GetBars(Bars.Instrument, new Period(PeriodType.Minute, minutes, MarketDataType.Last), Bars.From, Bars.To, (Session)Bars.Session.Clone(), Data.Bars.SplitAdjust, Data.Bars.DividendAdjust); existsHistHourlyData = (hourlyBars.Count <= 1) ? false : true; isInit = false; isLoaded = true; } IBar hourlyBar; if (CurrentBar == 0) { return; } if (existsHistHourlyData) { DateTime intradayBarTime = Time[0].AddMinutes(-minutes); hourlyBar = hourlyBars.Get(hourlyBars.GetBar(intradayBarTime)); double high = hourlyBar.High; double low = hourlyBar.Low; double close = hourlyBar.Close; HPP.Set((high + low + close) / 3); if (HPP[0] != HPP[1]) { DrawRay("pp", true, 1, HPP[0], 0, HPP[0], Plots[0].Pen.Color, Plots[0].Pen.DashStyle, (int)Plots[0].Pen.Width); } HS1.Set(2 * HPP[0] - high); if (HS1[0] != HS1[1]) { DrawRay("hs1", true, 1, HS1[0], 0, HS1[0], Plots[1].Pen.Color, Plots[1].Pen.DashStyle, (int)Plots[1].Pen.Width); } HR1.Set(2 * HPP[0] - low); if (HR1[0] != HR1[1]) { DrawRay("hr1", true, 1, HR1[0], 0, HR1[0], Plots[4].Pen.Color, Plots[4].Pen.DashStyle, (int)Plots[4].Pen.Width); } HS2.Set(HPP[0] - (high - low)); if (HS2[0] != HS2[1]) { DrawRay("hs2", true, 1, HS2[0], 0, HS2[0], Plots[2].Pen.Color, Plots[2].Pen.DashStyle, (int)Plots[2].Pen.Width); } HR2.Set(HPP[0] + (high - low)); if (HR2[0] != HR2[1]) { DrawRay("hr2", true, 1, HR2[0], 0, HR2[0], Plots[5].Pen.Color, Plots[5].Pen.DashStyle, (int)Plots[5].Pen.Width); } HS3.Set(HS2[0] - (high - low)); if (HS3[0] != HS3[1]) { DrawRay("hs3", true, 1, HS2[0], 0, HS2[0], Plots[3].Pen.Color, Plots[3].Pen.DashStyle, (int)Plots[3].Pen.Width); } HR3.Set(HR1[0] + (high - low)); if (HR3[0] != HR3[1]) { DrawRay("hr3", true, 1, HR2[0], 0, HR2[0], Plots[6].Pen.Color, Plots[6].Pen.DashStyle, (int)Plots[6].Pen.Width); } } else { return; } }