Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Outputting data (values) of indicators (at the time of entry) from a strategy

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

    Outputting data (values) of indicators (at the time of entry) from a strategy

    Hi All,

    I am trying to analyze values of a set of indicators (different that strategy variables/indicators) at the time of each entry taken by my strategy. I want to see if I can correlate market environment conditions and trade outcomes (win/loss). I am a newbie to ninjatrader strategy builder and to coding itself.
    I would appreciate any code help and code guidance to plan and get to code running within the strategy.

    Logic is as follows:

    @ Entry E1 save Indicator values of X1, X2, X3... and close of E1 save PnL result

    and output this data

    I hope others can use this as well. I believe that this can help find correlations between equity curve slopes and market conditions. This could lead to reduce draw downs or improved position sizing.

    Thank you in advance,
    G
    Last edited by jokepie; 07-01-2019, 12:35 PM.

    #2
    Hello jokepie,

    Thanks for your post.

    In the strategy builder it would be easier to accomplish your goal but harder at the same time. The strategy builder would not be able to open/save data to a file. You could, however, print the data to the New>Ninjascript output window and from the output window copy/save the data manually to a file that could be imported to a spreadsheet.

    In the strategy builder then, in the set where your entry conditions are, you would add one or more Print statements (via Misc>Print) to output the values of the indicator of interest. For the exit, this would be more difficult but I would suggest using a bool variable that is set true when you are in a position and then when you are in a flat position and the bool indicates you were in a position, you would print out the next set of information in the same way and also reset the bool to false. So this would cover you for both entry and exit.

    Alternately, if you work directly in Ninjascript you can create a file that can be automatically added to and imported into a spreadsheet. We have an example of writing a file (sends the OHLC and time stamp data) to a designated file. Here is a link: https://ninjatrader.com/support/help...o_write_to.htm

    Comment


      #3
      NinjaTrader_PaulH This sounds good. I will try the solution. Since, I only need to do this during strategy development. I don't have to code it in ninja script and avoid coding anxiety
      Thank you so much !

      Comment


        #4
        hello jokepie,

        Thanks for your reply.

        Just to get you a leg up on print statement how to, I've created a short video: https://Paul-ninjaTrader.tinytake.co...MV8xMDk0NDIxMQ This shows printing variables on each entry with a strategy set to Calculate.OnBarClose

        Tip: If you use a print statement in a set without any conditions, the print will output on every bar (or every tick if using Calculate.OnEachTick, or every price change if using Calculate.OnPriceChange).

        Comment


          #5
          NinjaTrader_PaulH You are awesome. This is very helpful. I really liked the idea of using one string for label and the other for data value, would be so helpful while importing and analyzing. I would not have thought of it myself. Thank you again and have an amazing week ahead.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by NullPointStrategies, 03-13-2026, 05:17 AM
          0 responses
          92 views
          0 likes
          Last Post NullPointStrategies  
          Started by argusthome, 03-08-2026, 10:06 AM
          0 responses
          152 views
          0 likes
          Last Post argusthome  
          Started by NabilKhattabi, 03-06-2026, 11:18 AM
          0 responses
          80 views
          0 likes
          Last Post NabilKhattabi  
          Started by Deep42, 03-06-2026, 12:28 AM
          0 responses
          53 views
          0 likes
          Last Post Deep42
          by Deep42
           
          Started by TheRealMorford, 03-05-2026, 06:15 PM
          0 responses
          63 views
          0 likes
          Last Post TheRealMorford  
          Working...
          X