Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Take profit on the same Entry bar?

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

    Take profit on the same Entry bar?

    I'm testing a strategy but i get weird results.

    This is what i found:

    (See the attached photo)
    I set 2 limit orders and 2 Take profits on 15% and 16% fib retracement.

    As long as the High of the entry bar covers the target price, the strategy tester will take profit on the same bar.

    Once the target is not covered in the entry bar, it will look for the target on the following bars.

    In the photo, I excepted to see both of the Take profit orders filled on the following bars.

    Is this the way that the strategy tester works? or it might be a bug in my code?

    Thanks.
    Attached Files

    #2
    Hello offeraz,

    Thank you for your note.

    When using backtesting the strategy will run exactly the same as if CalculateOnBarClose is set to true. This is true whenever the strategy runs on historical type data. The reason for this is because the only info known historically is the Bar open, High, Low and close and not all of the ticks that make up the bar.

    If you look at a tick chart covering this period, was the low where your entry order filled, made prior to the rally to 15% or 166.67?

    If you change order fill resolution to High and set type to tick, do you see results closer to what you’d expect?

    I look forward to your reply.
    Alan P.NinjaTrader Customer Service

    Comment


      #3
      Take profit on the same Entry bar?

      Hi,
      Thanks for the quick replay.

      I check it on a 1 tick and the price went up only on the following bars.
      I found this scenario every time that the entry bar contains the take profit price.

      Does NT7 has Order Fill Resolution function? I can't see it on the strategy menu..

      Comment


        #4
        Hello offeraz,

        I apologize for the confusion, no NT7 does not have that feature. This was a big improvement in NT8.

        In NT7 it is possible to add a 1-tick secondary data series to a strategy that runs on a minute chart, which would resolve the issue you are having here in NT7.

        To add the data series to the strategy you’d add the data series under Initialize(), for example,

        Code:
        Add(PeriodType.Tick, 50);
        To then enter an order on the tick series, under OnBarUpdate,

        Code:
        if (BarsInProgress == 1)
        {
        if (SMA(25)[0] > SMA(50)[0])
        {
        EnterLong(1, 1, "Enter Long from Tick Chart");
        }
        }
        I’ve provided a link to a reference example demonstrating how to add and trade off a secondary data series.



        Please let us know if you need further assistance.
        Alan P.NinjaTrader Customer Service

        Comment


          #5
          Thanks.

          Let's assume that I test patterns on different time frames (5 min, 15, 60 etc..).
          Does this code will use the ticks only for the order execution and handling or for the Indicator calculations too?

          My goal is that my primary data series will be any time frame that I want, but when an order executed, it will happen on a tick chart.

          Comment


            #6
            Hello offeraz,

            Adding a secondary data series of type tick, and submit orders to that series, should provide more accurate historical trade results by taking away the issue where the same bar touched the exit price prior to the entry price.

            Using BarsInProgress ==0, would limit the condition to be considered on the primary series only, thus would give you what you want.

            Please see Backtesting NinjaScript Strategies with an intrabar granularity for a reference example on how you’d set this up.

            You can submit orders to different Bars objects. This allows you the flexibility of submitting orders to different timeframes. Like in live trading, taking entry conditions from a 5min chart means executing your order as soon as possible instead of waiting until the next 5min bar starts building. You can achieve this by


            Please let us know if you need further assistance.
            Alan P.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by elderan, Today, 08:03 PM
            0 responses
            2 views
            0 likes
            Last Post elderan
            by elderan
             
            Started by algospoke, Today, 06:40 PM
            0 responses
            10 views
            0 likes
            Last Post algospoke  
            Started by maybeimnotrader, Today, 05:46 PM
            0 responses
            9 views
            0 likes
            Last Post maybeimnotrader  
            Started by quantismo, Today, 05:13 PM
            0 responses
            7 views
            0 likes
            Last Post quantismo  
            Started by AttiM, 02-14-2024, 05:20 PM
            8 responses
            169 views
            0 likes
            Last Post jeronymite  
            Working...
            X