Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

multiple data series for a strategy

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

    #16
    Hi Jesse,

    What would simply adding
    Add(PeriodType.Tick, 1);

    immediately under
    CalculateOnBarClose = true;

    do? Would that get the strategy to use the next tick data (vs the erroneous renko bar data) after the trade entry or exit logic is hit in the code when backtesting. And would it have any impact on forward testing or trading with the strategy?

    Comment


      #17
      Hello,

      This should have no impact on the script or outcome, the items in Initialize will all be considered when the script is actually run, the order of these two items would not matter.

      This would add a tick series, which would call OnBarUpdate for each Tick.

      Please let me know if I may be of further assistance.
      JesseNinjaTrader Customer Service

      Comment


        #18
        I'm sorry but I don't understand your reply.

        I currently have a strategy that I run over a renko bar type, as I want to use indicator values over that bar type at close as my triggers for trades. But when backtesting, I want the results to reflect trade entry as the next tick after that renko bar closes (not the fictitious renko bar open). And I want the exit results to reflect the price of the next tick after the take profit or stop loss level is hit, regardless of whether the renko bar has closed (e.g., to test a 6-tick trailing stop when the renko bar is brick size of 14).

        Will the insertion of that one additional line ("Add(PeriodType.Tick, 1);") accomplish that? I requested the change I've described from a programmer, and he delivered a modified strategy with just that change. I think he has misunderstood the request. I'm looking at backtest and forward testing results and not understanding what I'm seeing, so thought I would run it past you.

        Comment


          #19
          Hello,

          To clarify my last reply, you had asked:

          What would simply adding
          Add(PeriodType.Tick, 1);

          immediately under
          CalculateOnBarClose = true;
          The order of these two items does not matter, so adding it before or after would not matter.


          If you do add a 1 tick series, then OnBarUpdate would be called for each tick of that series in addition ot the primary series you had applied the script to. Assuming you submit your order on the secondary 1 tick series after the renko bar closed, that would be possible. You would need to do this using logic if that is specifically what you wanted. You can see how bars are built and executed in the document here which could help in determining how your script will ultimately run when you add second series: https://ninjatrader.com/support/help...ub=multi%2Bbar

          Depending on how your logic is formed, you can execute orders on either the primary, secondary or both.

          Regarding the backtesting results you are seeing, what are you currently not understanding about the results? Can you provide an image of the result you are not understanding so that I could also see the same information? I would not be certain of what your developer had programmed/changed to provide an answer here, in most cases we suggest working with your develoepr on the results/debugging as they will be in charge of testing that logic to ensure it works as you instructed them to create it.

          I look forward to being of further assistance.
          JesseNinjaTrader Customer Service

          Comment


            #20
            The new strategy had different results in Strategy Analyzer vs sim. Shouldn't they be the same? I had slippage set to 0 in both. The pic with the charts side by side show Strategy Analyzer trades on the left and Sim on the right.

            Also, I got different results in Sim from the old vs new strategy, when I expected the 'add' statement to only affect Strategy Analyzer results. Please see the pic with a single chart. Both strategies entered at 6743.50, but the strategy with the 'add' statement exited at a much less favorable price. Both strategies are meant to exit at a 22-tick trailing stop loss.

            I am just trying to get accurate results (resembling what I could expect in live trading) in Strategy Analyzer, using conditions that operate on a renko bar type. With my simple strategy that I created in Wizard, after the conditions are met at bar close, it executes the trade assuming an entry price of the open of the next bar, which for a renko dataseries is a fictitious price. I just want it to use the next tick data. And for exit, if my stop loss is hit, I want it to exit on the next tick data, not wait for the bar to close.Would the 'add' statement the programmer added accomplish that in your opinion? If not, is what I'm asking possible?
            Attached Files

            Comment


              #21
              In general, if CalculateOnBarClose = True and the trade exit is a stop loss (let's assume only one data series and time frame):
              - Does the strategy submit the exit order when the stop loss level is hit or wait for the bar to close? Is the answer different for live/forward trading vs Strategy Analyzer? Does Market Replay work like live trading?
              - Is a take profit level treated the same?
              - I've been told that Strategy Analyzer cannot reflect an exit in the middle (range-wise) of a bar. If an exit stop level price on a long position was hit and the bar closed in the middle of the bar range above or below that stop level (for instance a time or tick chart), what would Strategy Analyzer assume to be the exit price? The stop level? Bar close price? Bar low?

              Comment


                #22
                Hello,

                Thank you for the replies.

                The new strategy had different results in Strategy Analyzer vs sim. Shouldn't they be the same?
                No, not necessarily. Historical tests versus forwarding testing in live data will produce differences as there is a granularity difference here. You can read about this here: https://ninjatrader.com/support/help...ightsub=discre

                Also, I got different results in Sim from the old vs new strategy, when I expected the 'add' statement to only affect Strategy Analyzer results
                I would likely expect this as well, you have changed the data that the strategy is using to place orders in both sim and the strategy analyzer by using the Add syntax. Generally, we suggest using Prints to see how this affects your logic but if you are working with a developer you may need to schedule a time with the developer to go over how this would affect your overall logic. I would suggest reviewing the following page together: https://ninjatrader.com/support/help...lightsub=multi The majority of these questions should likely be reviewed with your developer to ensure they understand your overall goals for both realtime and historical trades.

                I am just trying to get accurate results (resembling what I could expect in live trading) in Strategy Analyzer
                While you can get similar results, they will be different when running a backtest specifically as there is no realtime granularity. You will almost always see differences due to how the bars are being processed and how orders are being filled. You can see the details on the differences in the first link provided in this message. Additionally, backtesting on Renko bars specifically is not accurate due to how renko bars are built. The reason for this is the nature of the Renko bar. Renko bars on real-time data re-draw the open based on the direction of the bar. This can not be simulated historically. Backtesting in the Strategy Analyzer is done over the historical data. Each bar in the historical collection has an Open, High, Low, and Close. The OHLC is static and does not change, therefore the accuracy of a Renko backtest is never 100%.

                And for exit, if my stop loss is hit, I want it to exit on the next tick data, not wait for the bar to close.Would the 'add' statement the programmer added accomplish that in your opinion? If not, is what I'm asking possible?
                The add statement would allow tick data to be used but it would be up to the programmer to add logic to account for the extra granularity if it should be used logically. If your stoploss was hit, it should be filled, the developer would need to instead not use a stop loss and use logic here to set up a future exit when the tick happens. Waiting for the next tick would still fill on the Close of that tick, so again this would be 1 tick after the found tick. This isn't really something I could comment on if this would work or provide more accurate results, this would require testing that specific situation if it would be possible in a way that works for your expectation. Likely you would need to work with the developer to see if they can program the strategy to work this way specifically in backtesting only without affecting realtime trades.

                In general, if CalculateOnBarClose = True and the trade exit is a stop loss (let's assume only one data series and time frame):
                - Does the strategy submit the exit order when the stop loss level is hit or wait for the bar to close? Is the answer different for live/forward trading vs Strategy Analyzer? Does Market Replay work like live trading?
                In historical tests we always wait for the Bar Close to do any evaluation, CalculateOnBarClose would specifically be on the bar close. The answer is the same for both realtime or historical testing. A Fill can still occur with intrabar granularity when working in Realtime with CalculateOnBarClose=true, only your logic is being evaluated at this rate to submit. Orders that have been submitted and now reside on the exchange will be filled based on the market that is happening live which is a difference from historical. You can use market replay to gain more similar results to realtime as that is acutally realtime data that was recorded.

                Code:
                - Is a take profit level treated the same?
                Yes.

                Code:
                - I've been told that Strategy Analyzer cannot reflect an exit in the middle (range-wise) of a bar. If an exit stop level price on a long position was hit and the bar closed in the middle of the bar range above or below that stop level (for instance a time or tick chart), what would Strategy Analyzer assume to be the exit price? The stop level? Bar close price? Bar low?
                In relation to this specific case, correct the strategy only knows the OHLC of the bar in historical and would be executed at the Close of the bar. There would not be a possibility for logic to occur in the middle of a bar if it is evaluating the logic at the Close of the bar.

                Please let me know if I may be of further assistance.
                JesseNinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by kempotrader, Today, 08:56 AM
                0 responses
                6 views
                0 likes
                Last Post kempotrader  
                Started by kempotrader, Today, 08:54 AM
                0 responses
                4 views
                0 likes
                Last Post kempotrader  
                Started by mmenigma, Today, 08:54 AM
                0 responses
                2 views
                0 likes
                Last Post mmenigma  
                Started by halgo_boulder, Today, 08:44 AM
                0 responses
                1 view
                0 likes
                Last Post halgo_boulder  
                Started by drewski1980, Today, 08:24 AM
                0 responses
                3 views
                0 likes
                Last Post drewski1980  
                Working...
                X