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 kinfxhk, 07-14-2026, 09:39 AM
      0 responses
      91 views
      0 likes
      Last Post kinfxhk
      by kinfxhk
       
      Started by kinfxhk, 07-13-2026, 10:18 AM
      0 responses
      92 views
      0 likes
      Last Post kinfxhk
      by kinfxhk
       
      Started by kinfxhk, 07-13-2026, 09:50 AM
      0 responses
      70 views
      0 likes
      Last Post kinfxhk
      by kinfxhk
       
      Started by kinfxhk, 07-13-2026, 07:21 AM
      0 responses
      87 views
      0 likes
      Last Post kinfxhk
      by kinfxhk
       
      Started by kinfxhk, 07-11-2026, 02:11 AM
      0 responses
      66 views
      0 likes
      Last Post kinfxhk
      by kinfxhk
       
      Working...
      X