inputs: LogOrders(true); Using elsystem; Using strategy; using tsdata.common; using tsdata.trading; var: bool Optimizing(GetAppInfo(aiOptimizing) = 1), Intrabarpersist StrategyPosition(0), Intrabarpersist ActualMP(0), AccountID( GetAccountID() ), PositionsProvider PositionInfo( NULL ), Strategy.StrategyHost sh( NULL ), Strategy.Signal sig( Null ); Method override void InitializeComponent() { This method gets called by EasyLanguage one time at the beginning to create and initialize the components } begin sh = new StrategyHost; sh.Connect = true; If LogOrders and Optimizing = false then begin sh.NewOrder += NewOrder; //Method to be called when a strategy generates a new order sh.OrderFill += OrderFill; // Declare Event Handler Method to be called when an order fills end; PositionInfo = new PositionsProvider ; PositionInfo.Accounts += AccountID ; PositionInfo.Symbols += Symbol ; // set the symbol PositionInfo.Realtime = true ; // set the position provider to run on real-time ticks PositionInfo.Load = true ; // load (activate) the positions provider with current positions info If Optimizing = False then PositionInfo.Updated += PositionUpdate ; // if any position changes occur, startup the PositionUpdate Method end; Method void OrderFill( Object sender, StrategyFillOrderEventArgs args ) begin sig = sh.Signals[args.SignalIndex]; print( _DateTime, "OrderFill: ", _StrategyOrderDirection(sig.OrderDirection astype int), Rightstr(sig.Name & " ",6), args.RequestedQty:7:0, " at ", args.TargetPrice:0:5, " ", _StrategyOrderType(sig.StopLimit astype int), " Avg Price = ", args.AvgPrice:0:5); End; Method void NewOrder( elsystem.Object sender, strategy.StrategyNewOrderEventArgs args ) begin sig = sh.Signals[args.SignalIndex]; print(_DateTime, "NewOrder: ", _StrategyOrderDirection(sig.OrderDirection astype int), Rightstr(sig.Name & " ",6), args.RequestedQty:7:0, " at ", args.TargetPrice:0:5, " ", _StrategyOrderType(sig.StopLimit astype int), " Strategy Position = ", StrategyPosition:8:0, " ActualMP = ", ActualMP:8:0); end; Method void PositionUpdate( Object PositionInfoSender, PositionUpdatedEventArgs PositionInfoUpdateArgs ) begin if PositionInfo.Count > 0 then begin ActualMP = PositionInfo[0].Quantity; end else ActualMP = 0 ; StrategyPosition = MarketPosition * CurrentShares; end;