Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Fake the execution price?

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

    Fake the execution price?

    Hello,

    is it possible to open / close position on price which is different from market price?
    e.g.: Market is at 100 but I would like to Buy for 150 at this time?

    It sounds as a non-sense, but I would like to simulate option strategy (simulate some fixed Profit/Loss).

    In summary to fake opening / closing price to get some P/Ls?

    Peter

    #2
    Hi Peter, out of the box this would not be supported unfortunately, but I think that would be doable via a custom filltype for example, where you just set to take the price as specified for example when working via limit orders. Right now you would be limited by the bar height, even if a custom slippage was included.

    The types could be reviewed under Documents > NinjaTrader7 > bin > custom > type

    Comment


      #3
      Thanks for hint,
      you mean to change logic of the following code and save the custom fill type as a new file?

      Code:
      else if (order.OrderType == OrderType.Limit)
                  {
                      // Orders are filled when traded through the limit price not at the limit price
                      double nextLow    = NextLow;
                      double nextHigh = NextHigh;
                      if ((order.OrderAction == Cbi.OrderAction.Buy                    && order.LimitPrice > nextLow + epsilon)
                              || (order.OrderAction == Cbi.OrderAction.BuyToCover    && order.LimitPrice > nextLow + epsilon)
                              || (order.OrderAction == Cbi.OrderAction.Sell            && order.LimitPrice < nextHigh - epsilon)
                              || (order.OrderAction == Cbi.OrderAction.SellShort    && order.LimitPrice < nextHigh - epsilon))
                          FillPrice = order.LimitPrice;
      But as you said, it is not possible to have LimitPrice outside of candle height (e.g.: 150 on candle with min 90 and max 110?

      Peter

      Comment


        #4
        Correct, that would be the idea.

        You could look into forcing the fill price to be simply your order limit price for example, so what ever you pass in is used and it would not check if you're outside the bar or not -

        Code:
        if (order.OrderType == OrderType.Limit)
        			{
        				if (order.OrderAction == Cbi.OrderAction.Buy || order.OrderAction == Cbi.OrderAction.BuyToCover)			// set fill price
        					FillPrice = (order.LimitPrice + SlippagePoints);
        				else
        					FillPrice = (order.LimitPrice - SlippagePoints);
        			}

        Comment


          #5
          Perfect, it does exactly what I need.
          Thank you
          Peter

          Comment


            #6
            One more thing, in case there is opened position on back-test finish, it is automatically closed on market.

            Is it possible to use the same mechanism here and close it on the limit?

            Or to check, there is last day of the back-test to create this faked Limit order?

            Peter

            Comment


              #7
              Hi Peter, no that would be an internally generated market order at all times. You look into checking if you're in position on the last day (given by Bars.BarsData.To) and then issue a custom order to prevent that mechanism to kick in for your script as you already took yourself flat.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
              0 responses
              648 views
              0 likes
              Last Post Geovanny Suaza  
              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
              0 responses
              369 views
              1 like
              Last Post Geovanny Suaza  
              Started by Mindset, 02-09-2026, 11:44 AM
              0 responses
              108 views
              0 likes
              Last Post Mindset
              by Mindset
               
              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
              0 responses
              572 views
              1 like
              Last Post Geovanny Suaza  
              Started by RFrosty, 01-28-2026, 06:49 PM
              0 responses
              573 views
              1 like
              Last Post RFrosty
              by RFrosty
               
              Working...
              X