1 #Region "Imports statements" 2 Imports System 3 Imports System.Drawing 4 Imports System.Collections.Generic 5 Imports System.Linq 6 Imports RightEdge.Common 7 Imports RightEdge.Common.ChartObjects 8 Imports RightEdge.Indicators 9 #End Region 10 11 12 Public Class MySystem 13 Inherits MySystemBase 14 Public Overloads Overrides Sub Startup() 15 ' Perform initialization or set system wide options here 16 SystemData.EnableTradeOnClose = True 17 AddHandler SystemData.BarClosing, AddressOf BarClosing 18 End Sub 19 20 Public Sub BarClosing(ByVal sender As Object, ByVal args As NewBarEventArgs) 21 For Each SymbolScript As MySymbolScript In SymbolScripts 22 SymbolScript.BarClosing() 23 Next 24 End Sub 25 End Class 26 27 28 Public Class MySymbolScript 29 Inherits MySymbolScriptBase 30 Public Overloads Overrides Sub Startup() 31 ' Perform initialization here 32 33 End Sub 34 35 Public Overloads Overrides Sub NewBar() 36 ' Put your new bar trading code here 37 38 End Sub 39 40 Public Sub BarClosing() 41 If Bars.Count < 2 Then 42 Return 43 End If 44 If Close.Current < Open.Current AndAlso Close.LookBack(1) < Open.LookBack(1) Then 45 ' Open a position after two down bars in a row. 46 OpenPosition(PositionType.Long, OrderType.Market) 47 End If 48 End Sub 49 50 Public Overloads Overrides Sub OrderFilled(ByVal position As Position, ByVal trade As Trade) 51 ' This method is called when an order is filled 52 53 End Sub 54 55 Public Overloads Overrides Sub OrderCancelled(ByVal position As Position, ByVal order As Order, ByVal information As String) 56 ' This method is called when an order is cancelled or rejected 57 58 End Sub 59 End Class 60