• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

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.

        http://ninjatrader.com/support/forum...ead.php?t=5787

        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.

            http://ninjatrader.com/support/forum...ead.php?t=6652

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

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by abfefmu, Today, 05:33 AM
            0 responses
            1 view
            0 likes
            Last Post abfefmu
            by abfefmu
             
            Started by bbdjad, Today, 04:36 AM
            0 responses
            4 views
            0 likes
            Last Post bbdjad
            by bbdjad
             
            Started by mittie3, Today, 03:33 AM
            0 responses
            7 views
            0 likes
            Last Post mittie3
            by mittie3
             
            Started by Againmain1, Today, 03:04 AM
            0 responses
            8 views
            0 likes
            Last Post Againmain1  
            Started by tonytimpa, Today, 01:33 AM
            0 responses
            5 views
            0 likes
            Last Post tonytimpa  
            Working...
            X