1 #region Using statements 2 using System; 3 using System.Drawing; 4 using System.Collections.Generic; 5 using RightEdge.Common; 6 using RightEdge.Common.ChartObjects; 7 using RightEdge.Indicators; 8 #endregion 9 10 #region System class 11 public class MySystem : MySystemBase 12 { 13 public override void Startup() 14 { 15 // Perform initialization or set system wide options here 16 17 } 18 19 20 public override void Shutdown() 21 { 22 23 foreach (Symbol mysym in Symbols) 24 { 25 TimeSpan difftime; 26 SymbolScripts[mysym].LastBarDate = SymbolScripts[mysym].Bars.Current.BarStartTime; 27 SymbolScripts[mysym].TotalBars = SymbolScripts[mysym].LastBarDate.TimeOfDay.TotalMinutes - SymbolScripts[mysym].FirstBarDate.TimeOfDay.TotalMinutes; 28 29 difftime = SymbolScripts[mysym].LastBarDate - SymbolScripts[mysym].FirstBarDate; 30 Console.WriteLine(mysym.Name + " ---------- LastBarDate=" + SymbolScripts[mysym].LastBarDate); 31 Console.WriteLine(mysym.Name + " nb of minutes=" + difftime.TotalMinutes); 32 if (SymbolScripts[mysym].TotalBarGaps == 0) 33 { 34 //Console.WriteLine(mysym.Name + ": No bar missing !"); 35 SystemData.Output.Add(OutputSeverityLevel.Informational, mysym.Name + ": No bar missing !"); 36 } 37 else 38 { 39 //Console.WriteLine(mysym.Name + ": ERROR " + SymbolScripts[mysym].TotalBarGaps + " gaps of missing bars !"); 40 SystemData.Output.Add(OutputSeverityLevel.Error, mysym.Name + ": " + SymbolScripts[mysym].TotalBarGaps + " gaps of missing bars !"); 41 } 42 } 43 //LastBarDate = Bars.Current.BarStartTime; 44 //NbBars = LastBarDate - FirstBarDate; 45 46 } 47 48 49 } 50 #endregion 51 52 53 /* 54 Bars Checkers v0.1 55 56 57 System parameters: 58 59 MaxPercentage = max allowed price jump (close) between two consecutives bars, in percentage (eg 0.05 for 5%) 60 BarFrequency = your data bar frequency in minutes 61 62 */ 63 public class MySymbolScript : MySymbolScriptBase 64 { 65 public DateTime FirstBarDate; 66 public DateTime LastBarDate; 67 public double TotalBars, TotalBarGaps; 68 69 public override void Startup() 70 { 71 // Perform initialization here. 72 TotalBarGaps = 0; 73 } 74 75 public override void NewBar() 76 { 77 // Put your trading code here 78 if (Bars.Count == 1) 79 { 80 FirstBarDate = Bars.Current.BarStartTime; 81 OutputMessage(Symbol.Name + " ---------- FirstBarDate=" + FirstBarDate); 82 //BarLookBackFromDate( 83 } 84 else 85 { 86 TimeSpan bartimediff = Bars.Current.BarStartTime - Bars.LookBack(1).BarStartTime; 87 //TODO compare with system freq or ... 88 if (bartimediff.TotalMinutes > (int) SystemParameters["BarFrequency"]) 89 { 90 TotalBarGaps++; 91 SystemData.Output.Add(OutputSeverityLevel.Error, Symbol.Name + ": bar(s) missing between " + Bars.LookBack(1).BarStartTime + " and " + Bars.Current.BarStartTime); 92 } 93 if (Bars.Current.Close == 0) 94 { 95 SystemData.Output.Add(OutputSeverityLevel.Error, Symbol.Name + " null value at time " + Bars.Current.BarStartTime); 96 } 97 else if (Bars.LookBack(1).Close != 0) 98 { 99 double barreturn = (Bars.Current.Close / Bars.LookBack(1).Close) - 1; 100 if (Math.Abs(barreturn) > SystemParameters["MaxPercentage"]) 101 { 102 SystemData.Output.Add(OutputSeverityLevel.Warning, Symbol.Name + " big jump between two consecutive bars: " + Bars.LookBack(1).Close + " to " + Bars.Current.Close + " at time " + Bars.Current.BarStartTime); 103 } 104 } 105 } 106 107 } 108 109 public override void OrderFilled(Position position, Trade trade) 110 { 111 // This method is called when an order is filled 112 113 } 114 115 public override void OrderCancelled(Position position, Order order, string information) 116 { 117 // This method is called when an order is cancelled or rejected 118 119 } 120 } 121