Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Custom fill types

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    #16
    Hello AnotherTrader,

    I see now you're looking at StopLimit fills.

    With default it will use the limit price specified always. With this you can sometimes see orders filled outside of bars.
    FillPrice = order.LimitPrice;

    With liberal it will look at the bars high and low and fill no further than those extremes.
    FillPrice = (order.OrderAction == Cbi.OrderAction.Buy || order.OrderAction == Cbi.OrderAction.BuyToCover) ? Math.Min(order.LimitPrice, nextHigh) : Math.Max(order.LimitPrice, nextLow);
    Last edited by NinjaTrader_RyanM1; 02-10-2011, 12:30 PM.
    Ryan M.NinjaTrader Customer Service

    Comment


      #17
      Thanks for the response.

      "Default" has:
      Code:
       
      else if (order.OrderType == OrderType.StopLimit)
      {
      // Stop limit orders are triggered when traded at the stop price and traded through the limit price
      double nextLow = NextLow;
      double nextHigh = NextHigh;
      if (!order.StopTriggered
      && ((order.Action == Cbi.Action.Buy && order.StopPrice <= nextHigh + Strategy.TickSize / 2)
      || (order.Action == Cbi.Action.BuyToCover && order.StopPrice <= nextHigh + Strategy.TickSize / 2)
      || (order.Action == Cbi.Action.Sell && order.StopPrice >= nextLow - Strategy.TickSize / 2)
      || (order.Action == Cbi.Action.SellShort && order.StopPrice >= nextLow - Strategy.TickSize / 2)))
      order.StopTriggered = true; // stop limit order was triggered
       
      if (order.StopTriggered
      && ((order.Action == Cbi.Action.Buy && order.LimitPrice [COLOR=red]>[/COLOR] nextLow + Strategy.TickSize / 2)
      || (order.Action == Cbi.Action.BuyToCover && order.LimitPrice [COLOR=red]>[/COLOR] nextLow + Strategy.TickSize / 2)
      || (order.Action == Cbi.Action.Sell && order.LimitPrice [COLOR=red]<[/COLOR] nextHigh - Strategy.TickSize / 2)
      || (order.Action == Cbi.Action.SellShort && order.LimitPrice [COLOR=red]<[/COLOR] nextHigh - Strategy.TickSize / 2)))
      [COLOR=red]FillPrice = order.LimitPrice; // set fill price[/COLOR]
      }

      "Liberal" has:
      Code:
       
      else if (order.OrderType == OrderType.StopLimit)
      {
      // Stop limit orders are triggered when traded at the stop price and traded through the limit price
      double nextLow = NextLow;
      double nextHigh = NextHigh;
      if (!order.StopTriggered
      && ((order.Action == Cbi.Action.Buy && order.StopPrice <= nextHigh + Strategy.TickSize / 2)
      || (order.Action == Cbi.Action.BuyToCover && order.StopPrice <= nextHigh + Strategy.TickSize / 2)
      || (order.Action == Cbi.Action.Sell && order.StopPrice >= nextLow - Strategy.TickSize / 2)
      || (order.Action == Cbi.Action.SellShort && order.StopPrice >= nextLow - Strategy.TickSize / 2)))
      order.StopTriggered = true; // stop limit order was triggered
       
      if (order.StopTriggered
      && ((order.Action == Cbi.Action.Buy && order.LimitPrice [COLOR=red]>=[/COLOR] nextLow - Strategy.TickSize / 2)
      || (order.Action == Cbi.Action.BuyToCover && order.LimitPrice [COLOR=red]>=[/COLOR] nextLow - Strategy.TickSize / 2)
      || (order.Action == Cbi.Action.Sell && order.LimitPrice [COLOR=red]<=[/COLOR] nextHigh + Strategy.TickSize / 2)
      || (order.Action == Cbi.Action.SellShort && order.LimitPrice [COLOR=red]<=[/COLOR] nextHigh + Strategy.TickSize / 2)))
      [COLOR=red]FillPrice = (order.Action == Cbi.Action.Buy || order.Action == Cbi.Action.BuyToCover) ? Math.Min(order.LimitPrice, nextHigh) : Math.Max(order.LimitPrice, nextLow);[/COLOR]
      I hope you can see the differences that I have tried to highlight in red.

      It's all in the "<", ">", "<=" and ">=", so to speak!
      Last edited by AnotherTrader; 02-10-2011, 12:37 PM.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Mindset, 04-21-2026, 06:46 AM
      0 responses
      115 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by M4ndoo, 04-20-2026, 05:21 PM
      0 responses
      163 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by M4ndoo, 04-19-2026, 05:54 PM
      0 responses
      83 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by cmoran13, 04-16-2026, 01:02 PM
      0 responses
      127 views
      0 likes
      Last Post cmoran13  
      Started by PaulMohn, 04-10-2026, 11:11 AM
      0 responses
      87 views
      0 likes
      Last Post PaulMohn  
      Working...
      X