protected override void OnExecutionUpdate(Execution execution, string executionId, double price, int quantity, MarketPosition marketPosition, string orderId, DateTime time)
{
if (entryOrder01 != null && entryOrder01 == execution.Order)
{
if (execution.Order.OrderState == OrderState.Filled || execution.Order.OrderState == OrderState.PartFilled || (execution.Order.OrderState == OrderState.Cancelled && execution.Order.Filled > 0))
{
// We sum the quantities of each execution making up the entry order
sumFilled01 += execution.Quantity;
// Submit exit orders for partial fills
if (execution.Order.OrderState == OrderState.PartFilled)
{
PlaceBracketExits(01, execution, marketPosition);
barentryonelong = CurrentBar; Print(string.Format("Bar entry {0} ", barentryonelong));
}
// Update our exit order quantities once orderstate turns to filled and we have seen execution quantities match order quantities
else if (execution.Order.OrderState == OrderState.Filled && sumFilled01 == execution.Order.Filled)
{
PlaceBracketExits(01, execution, marketPosition);
barentryonelong = CurrentBar; Print(string.Format("Bar entry {0} ", barentryonelong));
}
// Resets the entryOrder object and the sumFilled counter to null / 0 after the order has been filled
if (execution.Order.OrderState != OrderState.PartFilled && sumFilled01 == execution.Order.Filled)
{
entryOrder01 = null;
sumFilled01 = 0;
}
}
}
//space for more orders
if (entryOrder11 != null && entryOrder11 == execution.Order)
{
if (execution.Order.OrderState == OrderState.Filled || execution.Order.OrderState == OrderState.PartFilled || (execution.Order.OrderState == OrderState.Cancelled && execution.Order.Filled > 0))
{
// We sum the quantities of each execution making up the entry order
sumFilled11 += execution.Quantity;
// Submit exit orders for partial fills
if (execution.Order.OrderState == OrderState.PartFilled)
{
}
// Update our exit order quantities once orderstate turns to filled and we have seen execution quantities match order quantities
else if (execution.Order.OrderState == OrderState.Filled && sumFilled11 == execution.Order.Filled)
{
//if (CurrentBar == barNumberOfLongEntries) Print("L reverse senal 2");
if ( CurrentBar == barentryonelong) Print("L reverse senal 1"); Print(string.Format("Bar entry {0} ", CurrentBar));
{
CancelOpenEntries();
CancelBrackets();
EnterShort(Convert.ToInt32(Order01LotSize * 2), "SS11"); Print("L entrada reverse 1");
SetStopLoss("SS11", CalculationMode.Ticks, Order01SL/2, false); Print("L reverse stop 1");
SetProfitTarget("SS11", CalculationMode.Ticks, Order01PT/2, false); Print("L reverse Limit 1");
}
}
Comment