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

About generate report from strategy

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

    About generate report from strategy

    Dear all,

    Is there any way to generate a report, such as a computing result, out from ninja ?
    For example, when building a new strategy, after we choose the conditions, then in the "Do the following" section, it only allows us to draw something or do some order. Can I do some computing or export out some information about the data selected by the strategy?

    Thanks

    #2
    keven, yes this is possible but not from within the Wizard. Please see this reference sample for writing data to a text file.
    AustinNinjaTrader Customer Service

    Comment


      #3
      Oh, thanks very much Austin. It really helps. But I have a question now, how can I simply use it in the strategies? For example, if I want to select some bars via a strategy and save their information, then should I need to write codes to do the thing like the sample every time?
      Is there any easy way to achieve this? e.g. by including a indicator?


      Thanks

      Comment


        #4
        keven, you could definitely code an indicator to write out specific bar information and then attach that to your strategy to streamline the coding process. That would probably be the easiest solution so you only have to write the code once, and then include the indicator in every strategy you want.
        AustinNinjaTrader Customer Service

        Comment


          #5
          Ok, I will try it. Thank you very much Austin!

          Comment


            #6
            Keven, you are very welcome. Please let us know if you have any other questions.
            AustinNinjaTrader Customer Service

            Comment


              #7
              haha, I come again.

              What I want to do now is: I want to do some calculation on bars which are selected by the strategy,
              and then write the results to a file. Now I know how to write file, I want to encapsulate all the
              calculation into a function in the indicator, then call the function in the strategy.
              How to achieve such goal ?

              A simple example,
              I choose bars whose Close price is greater than 10 days ago in the strategy, then I want to
              calculate the gap between the Close price and that of 10 days ago's, write it to a file.
              Can I implement the computing function in a indicator, then call the function in the strategy?
              Since I don't want to write the function every time I building a new strategy. Moreover, the
              calculation would not be such simple.

              Can you give me some sample code?

              Thanks
              Keven

              Comment


                #8
                Keven, there is actually a "strategy" file that is accessible from every strategy you code. It is called UserDefinedMethods and you can write your functions there and then call those functions from your strategies. To get to UserDefinedMethods, please go to Tools -> Edit NinjaScript -> Strategy -> UserDefinedMethods. There is a separate UserDefinedMethods for indicators, so please keep that in mind if you need to access your methods in an indicator as well.

                Take a look at the attached screenshot for an example of a simple adding method created in the UDM and then used in the strategy.
                Attached Files
                AustinNinjaTrader Customer Service

                Comment


                  #9
                  Dear Austin,

                  It's great ! That's exactly what I need.

                  Thanks a lot !

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by bortz, 11-06-2023, 08:04 AM
                  47 responses
                  1,603 views
                  0 likes
                  Last Post aligator  
                  Started by jaybedreamin, Today, 05:56 PM
                  0 responses
                  8 views
                  0 likes
                  Last Post jaybedreamin  
                  Started by DJ888, 04-16-2024, 06:09 PM
                  6 responses
                  18 views
                  0 likes
                  Last Post DJ888
                  by DJ888
                   
                  Started by Jon17, Today, 04:33 PM
                  0 responses
                  4 views
                  0 likes
                  Last Post Jon17
                  by Jon17
                   
                  Started by Javierw.ok, Today, 04:12 PM
                  0 responses
                  12 views
                  0 likes
                  Last Post Javierw.ok  
                  Working...
                  X