retesere20

---recycler---

Sep 26th, 2018
86
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2.  
  3. protected override void OnOrderUpdate(Order order, double limitPrice, double stopPrice, int quantity, int filled, double averageFillPrice, OrderState orderState, DateTime time, ErrorCode error, string nativeError)
  4. {
  5. return;
  6. if (order == null) return;
  7. po("---------------OnOrderUpdate----------------");
  8. //po(order.ToString()) ; //Name:entry_B_o1 Name:Profit target Name:Stop loss
  9. bool isEntryOrder = order.FromEntrySignal == "";
  10. bool isExitOrder = !isEntryOrder;
  11. string FromEntry = order.FromEntrySignal;
  12. if(FromEntry!="") Print(FromEntry);
  13.  
  14. bool Order_Is_Complete = order.OrderState == OrderState.Cancelled || order.OrderState == OrderState.Filled || order.OrderState == OrderState.PartFilled || order.OrderState == OrderState.Rejected;
  15.  
  16. string tradeName= order.Name;
  17. orders_[tradeName] = order;
  18.  
  19. bool is_entry = order.OrderAction == OrderAction.Buy || order.OrderAction == OrderAction.SellShort;
  20.  
  21. if(order.OrderState == OrderState.Filled)
  22. {
  23. //entries
  24. if (is_entry)
  25. {
  26. if( order.OrderAction == OrderAction.Buy)
  27. {
  28. exit_prices[tradeName]=PnF_MaxMin_indi.iLow[0];
  29. }
  30. if( order.OrderAction == OrderAction.SellShort)
  31. {
  32. exit_prices[tradeName]=PnF_MaxMin_indi.iHigh[0];
  33. }
  34. }
  35. //exits
  36. else
  37. {
  38. if (FromEntry!=null)
  39. {
  40. if( order.OrderAction == OrderAction.Sell)
  41. {
  42. if(exit_prices.ContainsKey(FromEntry)) exit_prices.Remove(FromEntry);
  43. }
  44. if( order.OrderAction == OrderAction.BuyToCover)
  45. {
  46. if(exit_prices.ContainsKey(FromEntry)) exit_prices.Remove(FromEntry);
  47. }
  48. }
  49. //empty.. Draw.Text(this, "txt_"+tradeName+ CurrentBar, true, FromEntry, Time[0], High[0], 0, Brushes.White, (new NinjaTrader.Gui.Tools.SimpleFont("Arial", 12)) , TextAlignment.Center, Brushes.Transparent, Brushes.Transparent, 0);
  50. }
  51. }
  52. else if(order.OrderState == OrderState.Cancelled)
  53. {
  54. if(orders_.ContainsKey(tradeName)) orders_.Remove(tradeName);
  55. if(exit_prices.ContainsKey(tradeName)) exit_prices.Remove(tradeName);
  56. }
  57.  
  58. return;
  59. }
RAW Paste Data