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

ExitShort not working in Strategy Analyzer

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

    ExitShort not working in Strategy Analyzer

    I have long used Market Replay for testing but I'm trying to get the hang of Strategy Analyzer to speed up testing. My strategy uses ExitShort() and ExitLong() to get out of positions. This has always worked in Market Replay but in Strategy Analyzer, it will take the trade but then not close when it's supposed to. In other words, after S/A completes, I open the chart and I see the entry and the exit just gets passed by and doesn't close. What do I need to know to get this working?

    #2
    Hello reynoldsn,

    Thanks for your post.

    To understand exactly how the strategy logic is behaving, it is necessary to add debugging prints to the strategy (outside the conditions) that prints all the values being used in the condition to place the Exit orders along with the time of the bar.

    Prints will appear in a New > NinjaScript Output window.

    See the NinjaTrader Support articles linked below for more information about debugging with Print() and TraceOrders: https://support.ninjatrader.com/s/ar...nd-TraceOrders

    For more information about comparing strategy results and intrabar granularity, see this NinjaTrader Support article: https://support.ninjatrader.com/s/ar...rategy-Results

    If a large amount of data is being output, you could instead write information to a text file using a StreamWriter: https://ninjatrader.com/support/help...o_write_to.htm
    Brandon H.NinjaTrader Customer Service

    Comment


      #3
      Well, today, I finally tried Strategy Analyzer again and now it's taking trades. Not sure what I was doing wrong.
      Having said that, there are other changes I need to make since S/A runs much faster.

      Comment


        #4
        Hello reynoldsn,

        Thanks for your notes.

        I am happy to hear that you see the Strategy Analyzer processing trades when backtesting your custom NinjaScript strategy.

        Computer memory is important for long resource-intensive tests that generate a large number of trades without your machine stalling. Computer processor speed is important to get optimization iterations done quickly and the number of CPU cores allows for more iterations to run simultaneously.

        The amount of data you are testing over could affect the performance of a Backtest/Optimization and the number of iterations being processed affect the performance of the Optimization.

        You could try reducing the amount of data you are testing over to improve the performance of Backtests in the Strategy Analyzer.

        You can easily control the number of iterations involved in Optimizations to improve optimization speed/performance and you can also consider writing your strategies to use IsInstantiatedOnEachOptimizationIteration = false; (Which requires that we reset class level variables in State.DataLoaded.)

        See the help guide documentation below for more information about running optimizations.

        IsInstantiatedOnEachOptimizationIteration —
        https://ninjatrader.com/support/helpGuides/nt8/isinstantiatedoneachoptimizationiteration.htm?zoom _highlightsub=IsInstantiated

        Optimization Tips —
        https://ninjatrader.com/support/helpGuides/nt8/index.html?optimize_a_strategy.htm#UnderstandingFa ctorsThatAffectOptimizationPerformance

        Walk Forward Optimization — https://ninjatrader.com/support/help...e_a_strate.htm

        Genetic Optimization — https://ninjatrader.com/support/helpGuides/nt8/genetic_algorithm.htm
        Last edited by NinjaTrader_BrandonH; 04-30-2024, 02:45 PM.
        Brandon H.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by bortz, 11-06-2023, 08:04 AM
        49 responses
        1,769 views
        0 likes
        Last Post NinjaTrader_RyanS  
        Started by Vietanhnguyen2hotmailcom, Today, 10:29 AM
        3 responses
        9 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Started by milfocs, Yesterday, 07:23 PM
        3 responses
        13 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by kenz987, Today, 10:20 AM
        1 response
        10 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Started by PaulMohn, 04-24-2024, 03:49 AM
        2 responses
        33 views
        0 likes
        Last Post PaulMohn  
        Working...
        X