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 CarlTrading, 03-31-2026, 09:41 PM
      1 response
      36 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, Yesterday, 02:41 AM
      0 responses
      16 views
      0 likes
      Last Post CarlTrading  
      Started by CaptainJack, 03-31-2026, 11:44 PM
      0 responses
      25 views
      1 like
      Last Post CaptainJack  
      Started by CarlTrading, 03-30-2026, 11:51 AM
      0 responses
      40 views
      0 likes
      Last Post CarlTrading  
      Started by CarlTrading, 03-30-2026, 11:48 AM
      0 responses
      34 views
      0 likes
      Last Post CarlTrading  
      Working...
      X