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 argusthome, 03-08-2026, 10:06 AM
      0 responses
      94 views
      0 likes
      Last Post argusthome  
      Started by NabilKhattabi, 03-06-2026, 11:18 AM
      0 responses
      49 views
      0 likes
      Last Post NabilKhattabi  
      Started by Deep42, 03-06-2026, 12:28 AM
      0 responses
      31 views
      0 likes
      Last Post Deep42
      by Deep42
       
      Started by TheRealMorford, 03-05-2026, 06:15 PM
      0 responses
      35 views
      0 likes
      Last Post TheRealMorford  
      Started by Mindset, 02-28-2026, 06:16 AM
      0 responses
      71 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Working...
      X