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 #endregion 20 21 public class MySymbolScript : MySymbolScriptBase 22 { 23 public override void Startup() 24 { 25 // Perform initialization here. 26 this.Indicators["Highest"].ChartSettings.ShowInChart = true; 27 this.Indicators["Lowest"].ChartSettings.ShowInChart = true; 28 29 } 30 31 32 33 public override void NewBar() 34 { 35 // Put your trading code here 36 37 if (this.Close.Current >= this.Indicators["Highest"].Current && this.OpenPositions.Count == 0) 38 { 39 PositionSettings ps = new PositionSettings(); 40 ps.Description = "Buy"; 41 ps.OrderType = OrderType.Market; 42 ps.PositionType = PositionType.Long; 43 ps.StopLoss = this.Indicators["Lowest"].Current; 44 ps.StopLossType = TargetPriceType.Price; 45 ps.TrailingStopType = TargetPriceType.Percentage; 46 ps.TrailingStop = 0.08; 47 48 49 50 Position pos = this.OpenPosition(ps); 51 //PositionManager.SetTrailingStop(pos.ID, 0.05, TargetPriceType.Percentage); 52 53 } 54 } 55 56 57 58 public override void OrderFilled(Position position, Trade trade) 59 { 60 // This method is called when an order is filled 61 62 63 64 } 65 66 public override void OrderCancelled(Position position, Order order, string information) 67 { 68 // This method is called when an order is cancelled or rejected 69 position.CloseAtMarket(); 70 } 71 } 72