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

Backtesting variable values at time of entry

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

    Backtesting variable values at time of entry

    Hi,

    When running a backtest I would like to know the values of the variables that triggered each of my entry and exit signals. Say my entry signal was if RSI was above 50 and the last minutes volume was above 100 lots. Is there a way of reporting then for example that on a given entry that RSI was 56 and volume was 233? Even if it were plotted on the chart beside the entry that would be something.

    Thanks,
    darmbk.

    #2
    Hello darmbk,

    Yes, that would be possible. If you "Add" the indicator to your Strategy, or set the "Plot on chart" true (in the Strategy Wizard) this will add the indicator to the chart so that when you apply the Strategy to a chart it will plot the indicator as well. Then once the Indicator is there you can use the Data Box to be able to view the Indicator values.

    For more information about the Data Box on a chart you may view the following link.


    Note that you can also check it using custom code by using the Print() statement as well.
    JCNinjaTrader Customer Service

    Comment


      #3
      Hi JC,

      Thanks for your reply. To take a generic example, say I am using the difference between the volume in the last minute versus that of the minute prior to that as a ratio called volRatio. volRatio is not designed as an indicator on its own but rather is simply a private double of the strategy. Do I need to create an indicator with this calculation before I can show it on a chart in a backtest using StrategyAnalyzer? With respect to the options you suggest, I am not using the StrategyWizard to code the strategy in question, so I am looking for a c# method to use. Firstly, in StrategyWizard could you direct me to the "Plot on Chart" option, and secondly, I don't think you are suggesting using Add() as that adds Bar objects to a strategy? Could you point me to an example where a variable of a strategy is included as an indicator on a chart.

      Thanks,
      darmbk.

      PS More generally I suppose I'm interested to understand how strategy designers go about testing their codes workings? at the moment I am assuming this is done by getting to view variable values at the point that they lead to strategy actions (entries, exits, ...) as above.
      Last edited by darmbk; 06-06-2013, 07:58 AM.

      Comment


        #4
        Hello darmbk,

        You may not need to create an Indicator if it can simply be calculated inside of your Strategy as a variable since it work work the same basically.

        Here is a link to our Help Guide that goes over the Strategy Wizard and "How to make indicator to value comparisons" that will have an image of the "Plot on chart" that you can switch to true on any indicator you add to the Strategy Wizard.



        Here is the Help Guide that goes over how to Add() and Indicator to a strategy that will have the Indicator plot for display purposes that you may view.


        As for as testing out your Strategy or seeing how it works, the easiest way you may accomplish this may be to Print() out the variable so that you can make sure you are getting the values that you expect. Here is a thread that goes over different methods on how you may debug your NinjaScript code that you may view for reference.


        Happy to be of further assistance.
        JCNinjaTrader Customer Service

        Comment


          #5
          Hey JC,

          Thanks again. From reviewing the options you propose, using Print() commands to publish output to an Output Window seems the preferred solution for me. The Add() method would be ideal if I were writing indicators to add to the chart which I may do later.

          Thanks,
          darmbk.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by rocketman7, Today, 01:00 AM
          0 responses
          1 view
          0 likes
          Last Post rocketman7  
          Started by wzgy0920, 04-20-2024, 06:09 PM
          2 responses
          27 views
          0 likes
          Last Post wzgy0920  
          Started by wzgy0920, 02-22-2024, 01:11 AM
          5 responses
          32 views
          0 likes
          Last Post wzgy0920  
          Started by wzgy0920, 04-23-2024, 09:53 PM
          2 responses
          74 views
          0 likes
          Last Post wzgy0920  
          Started by Kensonprib, 04-28-2021, 10:11 AM
          5 responses
          193 views
          0 likes
          Last Post Hasadafa  
          Working...
          X