Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Converting Strategy into Indicator

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

    Converting Strategy into Indicator

    Hey, I'm new to ninjascript. So I'm trying to find out if it's possible to convert a simple strategy that I've created in Strategy Wizard into an Indicator. I've searched everywhere and can't find an answer. The code doesn't require any orders to be placed. It simply contains a few Conditional statements. "IF (this is true) then Show Arrow here...etc...." something like that. It works just fine as a Strategy. But I want to make it into an indicator.

    Anyone know of a simple way to do this. Reason I ask, cause the indicator Code won't let me type in conditional statements.

    If you can't build indicator with Strategy wizard. then HOW DO YOU BUILD CONDITIONAL STATEMENTS for Indicators?
    Last edited by ginx10k; 12-30-2013, 09:15 AM.

    #2
    Hello ginx10k,

    Thanks for the post and welcome to the NinjaTrader forums!

    As long as the code you're currently using in the strategy does not submit orders, then you should be able to use the same code in an indicator. You can use conditional statements in an indicator the same way as done in a strategy. What is happening exactly when you try to use a conditional statement in an indicator?

    cause the indicator Code won't let me type in conditional statements.
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      I copy from strategy the part that's whithin the namespace NinjaTrader.Strategy . which is the public class for strategy, and I get error that says "Ninjatrader.Strategy is a namespace but is used like a type.

      Then I tried to replace the entire namespace inidcator with the complete namespace strategy code. and I get a bunch of errors.

      Can you tell me which part of the Strategy Code I should copy, and which part of the indicator code I SHOULDN't TOUCH. or maybe I should replace.

      I can't find what the exact problem is, but I can't get it to compile either.

      COPY WHAT and PASTE it WHERE?

      Comment


        #4
        Unfortunately you will not be able to copy - paste the entire code. If you open the strategy code there will be OnBarUpdate section where most of the logic will be. Indicators will have the same section.

        Code:
        protected override void OnBarUpdate()
        {
        //all your conditions here. 
        }
        If you are not sure what the code errors are, best would be to remove the files completely and start over. You can do this through Tools > Edit NinjaScript > Indicator/Strategy > Select the file and click delete.

        As you are just getting started, it may help to go through the tutorials so you can get a feel for each section of code and get comfortable with basic structure. You can find these tutorials here. Please let me know if you have any additional questions.
        Last edited by NinjaTrader_RyanM1; 12-30-2013, 10:57 AM.
        Ryan M.NinjaTrader Customer Service

        Comment


          #5
          I got it

          Thanks for the help. I just successfully converted a Strategy into an Indicator. With your assistance and NT support:
          To export your script do the following:

          Comment out any lines causing errors in all scripts
          Click File -> Utilities -> Export NinjaScript
          Enter a unique name for the file in the value for 'File name:'
          Select the strategy from the objects list on the left -> click the right facing arrow ">" to add the strategy to the export
          Click the 'Export' button -> click 'yes' to add any referenced indicators to the export -> click OK to clear the export location message
          By default your exported file will be in the following location:

          (My) Documents/NinjaTrader 7/bin/Custom/ExportNinjaScript/<export_file_name.zip>.

          I tried it on my chart and it already works.

          AWESOME!!

          Thanks again for you help.

          Comment


            #6
            I'm very happy to hear you were able to successfully create your first indicator. Thank you for posting a follow-up.
            Ryan M.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            639 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            366 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            107 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            569 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            572 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X