Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- protected override void OnBarUpdate()
- {
- if(State==State.Historical) return;
- if (CurrentBar < 20) return;
- if(Close[0] != Close[5] && Position.MarketPosition == MarketPosition.Flat)
- {
- EnterLong(1, "Buy Long A");
- EnterLong(1, "Buy Long B");
- EnterLong(1, "Buy Long C");
- }
- if (Close[0] > xPrice1+3*TickSize)
- {
- ExitLongLimit(0, true, 1, xPrice1 + 4 * TickSize, "Sell 1a", "Buy Long A");
- }
- }
- protected override void OnExecutionUpdate(Execution execution, string executionId, double price, int quantity, MarketPosition marketPosition, string orderId, DateTime time)
- {
- Print(execution.Order.Name.ToString());
- if (execution.Order.Name == "Buy Long A" && execution.Order.OrderState == OrderState.Filled)
- {
- xPrice1 = Position.AveragePrice;
- ExitLongLimit(0, true, 1, xPrice1 + 20 * TickSize, "Sell 1a", "Buy Long A");
- ExitLongStopMarket(0, true, 1, xPrice1 - 12 * TickSize, "Sell Stop A", "Buy Long A");
- }
- if (execution.Order.Name == "Buy Long B" && execution.Order.OrderState == OrderState.Filled)
- {
- xPrice2 = Position.AveragePrice;
- ExitLongLimit(0, true, 1, xPrice2 + 5 * TickSize, "Sell 1b", "Buy Long B");
- ExitLongStopMarket(0, true, 1, xPrice2 - 12 * TickSize, "Sell Stop B", "Buy Long B");
- }
- if (execution.Order.Name == "Buy Long C" && execution.Order.OrderState == OrderState.Filled)
- {
- xPrice3 = Position.AveragePrice;
- ExitLongLimit(0, true, 1, xPrice3 + 6 * TickSize, "Sell 1c", "Buy Long C");
- ExitLongStopMarket(0, true, 1, xPrice3 - 12 * TickSize, "Sell Stop C", "Buy Long C");
- }
- // xPrice1 = Position.AveragePrice;
- //ExitLongLimit(0, true, 1, xPrice+4*TickSize, "Sell 1a", "Buy Long A");
- //ExitLongLimit(0, true, 1, xPrice+5*TickSize, "Sell 1b", "Buy Long B");
- //ExitLongLimit(0, true, 1, xPrice+6*TickSize, "Sell 1c", "Buy Long C");
- //ExitLongStopMarket(0, true, 1, xPrice-12*TickSize, "Sell Stop A", "Buy Long A");
- //ExitLongStopMarket(0, true, 1, xPrice-12*TickSize, "Sell Stop B", "Buy Long B");
- //ExitLongStopMarket(0, true, 1, xPrice-12*TickSize, "Sell Stop C", "Buy Long C");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement