retesere20

some order

Apr 20th, 2018
68
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. protected override void OnBarUpdate()
  2. {
  3. if(State==State.Historical) return;
  4. if (CurrentBar < 20) return;
  5.  
  6. if(Close[0] != Close[5] && Position.MarketPosition == MarketPosition.Flat)
  7. {
  8.  
  9. EnterLong(1, "Buy Long A");
  10. EnterLong(1, "Buy Long B");
  11. EnterLong(1, "Buy Long C");
  12. }
  13.  
  14. if (Close[0] > xPrice1+3*TickSize)
  15. {
  16. ExitLongLimit(0, true, 1, xPrice1 + 4 * TickSize, "Sell 1a", "Buy Long A");
  17. }
  18.  
  19.  
  20. }
  21. protected override void OnExecutionUpdate(Execution execution, string executionId, double price, int quantity, MarketPosition marketPosition, string orderId, DateTime time)
  22. {
  23. Print(execution.Order.Name.ToString());
  24. if (execution.Order.Name == "Buy Long A" && execution.Order.OrderState == OrderState.Filled)
  25. {
  26. xPrice1 = Position.AveragePrice;
  27. ExitLongLimit(0, true, 1, xPrice1 + 20 * TickSize, "Sell 1a", "Buy Long A");
  28. ExitLongStopMarket(0, true, 1, xPrice1 - 12 * TickSize, "Sell Stop A", "Buy Long A");
  29. }
  30. if (execution.Order.Name == "Buy Long B" && execution.Order.OrderState == OrderState.Filled)
  31. {
  32. xPrice2 = Position.AveragePrice;
  33. ExitLongLimit(0, true, 1, xPrice2 + 5 * TickSize, "Sell 1b", "Buy Long B");
  34. ExitLongStopMarket(0, true, 1, xPrice2 - 12 * TickSize, "Sell Stop B", "Buy Long B");
  35. }
  36. if (execution.Order.Name == "Buy Long C" && execution.Order.OrderState == OrderState.Filled)
  37. {
  38. xPrice3 = Position.AveragePrice;
  39. ExitLongLimit(0, true, 1, xPrice3 + 6 * TickSize, "Sell 1c", "Buy Long C");
  40. ExitLongStopMarket(0, true, 1, xPrice3 - 12 * TickSize, "Sell Stop C", "Buy Long C");
  41. }
  42.  
  43.  
  44. // xPrice1 = Position.AveragePrice;
  45.  
  46. //ExitLongLimit(0, true, 1, xPrice+4*TickSize, "Sell 1a", "Buy Long A");
  47. //ExitLongLimit(0, true, 1, xPrice+5*TickSize, "Sell 1b", "Buy Long B");
  48. //ExitLongLimit(0, true, 1, xPrice+6*TickSize, "Sell 1c", "Buy Long C");
  49.  
  50. //ExitLongStopMarket(0, true, 1, xPrice-12*TickSize, "Sell Stop A", "Buy Long A");
  51. //ExitLongStopMarket(0, true, 1, xPrice-12*TickSize, "Sell Stop B", "Buy Long B");
  52. //ExitLongStopMarket(0, true, 1, xPrice-12*TickSize, "Sell Stop C", "Buy Long C");
  53.  
  54. }
RAW Paste Data