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

Custom indicator

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

    Custom indicator

    Hi all,

    I am new here with a little NT coding experience. I have created a custom indicator, but non of the defined indicator parameters are showing in the Indicator Properties window even though my code compiles without errors and I have restarted NinjaTrader. I can see my indicator on the available list, but only showing very basic properties! Any help would be greatly appreciated.

    Thanks so much.
    Regards,

    #2
    Make sure your properties are public and you're not using [Browsable(false)] attribute.

    Comment


      #3
      Hello Horizon,

      Thanks for your post.

      Leeroy_Jenkins has provided some great information on this topic.

      You would need to make sure your defined properties are public, that you are not using the [Browsable(false)] attribute, and that you are using the NinjaScriptPropertyAttribute.

      See the help guide documentation below for more information.

      NinjaScriptPropertyAttribute: https://ninjatrader.com/support/help...yattribute.htm
      Creating User-Defined Input Parameters: https://ninjatrader.com/support/help...d_input_pa.htm
      Brandon H.NinjaTrader Customer Service

      Comment


        #4
        Thanks so much Leeroy for providing info. Still i am struggling to get it work, but I will keep trying and will post a question if could not figure it out!

        Thanks again.

        Comment


          #5
          Hello Horizon,

          Thanks for your notes.

          Something you could consider doing is using the Strategy Builder (New > Strategy Builder) to create user-defined inputs on the Inputs and Variables screen.

          Once you have created the inputs in the Strategy Builder, you could click the 'View code' button to see the generated syntax and implement that syntax in your script.
          Brandon H.NinjaTrader Customer Service

          Comment


            #6
            Thanks so much all, I was able to build my first indicator and plot it on the chart. Now I would like to add the seconds data series into my chart (e.g,, SMA). would would be the best approach? thanks a lot.

            Comment


              #7
              Hello Horizon,

              Thanks for your notes.

              The AddDataSeries() method could be used to add a secondary data series to a custom NinjaScript indicator or strategyto use for calculations. The added secondary in the script will not appear on the chart visually and there are no NinjaScript methods or properties available to force the added data series to show on the chart.

              AddDataSeries(): https://ninjatrader.com/support/help...=AddDataSeries

              Working with Multi-Timeframe/Multi-Instrument NinjaScripts: https://ninjatrader.com/support/help...nstruments.htm

              In the Strategy Builder, the Additional Data screen could be used to add a secondary data series to a strategy.

              Additional Data Screen: https://ninjatrader.com/support/help...er_screens.htm

              I see you mentioned " I would like to add the seconds data series into my chart (e.g. SMA)" in your post. SMA is an indicator, not a data series.

              To clarify, are you wanting to add a secondary data series to your script to use for calculations? Or, are you wanting to plot the SMA indicator on the chart?

              ​​​​​​​I look forward to assisting further.
              Brandon H.NinjaTrader Customer Service

              Comment


                #8
                Thanks for the quick respond.
                Yes, I am trying to use SMA data series to do calculations and at the same time would like to be able to visualize it on the same chart that currently have.
                Regards,
                Last edited by Horizon; 10-31-2023, 01:17 PM.

                Comment


                  #9
                  Sorry, correct myself, want SMA indicator to be added to my exiting script then I can use it to do the calculations. thanks

                  Comment


                    #10
                    Hello Horizon,

                    Thanks for your notes.

                    The SMA() system indicator method could be used to access SMA indicator values in a script for calculations.

                    SMA(): https://ninjatrader.com/support/help...simple_sma.htm

                    In the Strategy Builder, the SMA indicator could be found in the Indicators folder when creating conditions and actions on the Conditions and Actions screen.

                    If you check the 'Plot on chart' checkbox when selecting an indicator for conditions or actions in a Strategy Builder strategy, the SMA indicator would appear on the chart when the strategy is enabled.

                    Builder Screens: https://ninjatrader.com/support/help...er_screens.htm
                    Conditions: https://ninjatrader.com/support/help...on_builder.htm
                    Actions: https://ninjatrader.com/support/help...t8/actions.htm

                    The 'How to make indicator to value comparisons' section of the Conditions help guide page linked above demonstrates using an indicator for conditions.
                    Brandon H.NinjaTrader Customer Service

                    Comment


                      #11
                      Thanks so much Brandon for the note. I will give it a try to see how far I can go! .

                      thanks a lot again.

                      Comment


                        #12
                        I was able to create my strategy using the Strategy Builder. I have defined a condition (one indicator crosses above another indicator) and defined an action which was draw arrow. everting seems working the way I defined but but I can not see any arrow displaying on the chart. Any help would be appreciated, thanks.

                        Comment


                          #13
                          Hello Horizon,

                          Thanks for your notes.

                          Do you receive an error on screen? Are there errors on the Log tab of the Control Center? If so, what do these errors report?

                          Have you added debugging prints to the script to understand how the logic in the script is evaluating?

                          Does your Arrow draw object use a unique tag name, such as CurrentBar (Misc folder > CurrentBar?

                          I have attached a simple example script that demonstrates drawing an arrow on the chart when a crossover condition occurs. Note that the arrow draw object uses a unique tag name to that the arrow is drawn multiple times on the chart historically instead of modifying the same draw object.​
                          Attached Files
                          Brandon H.NinjaTrader Customer Service

                          Comment


                            #14
                            Thanks so much. the example was very useful. I was not getting any error, I did not have a right Y set-up.

                            Once again, thanks so much for your help!

                            Regards.

                            Comment


                              #15
                              Hi All,

                              How to define a strategy in strategy builder to stop auto trading after certain profit or loss? thanks a lot.​

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by rbeckmann05, Yesterday, 06:48 PM
                              1 response
                              12 views
                              0 likes
                              Last Post bltdavid  
                              Started by llanqui, Today, 03:53 AM
                              0 responses
                              6 views
                              0 likes
                              Last Post llanqui
                              by llanqui
                               
                              Started by burtoninlondon, Today, 12:38 AM
                              0 responses
                              10 views
                              0 likes
                              Last Post burtoninlondon  
                              Started by AaronKoRn, Yesterday, 09:49 PM
                              0 responses
                              15 views
                              0 likes
                              Last Post AaronKoRn  
                              Started by carnitron, Yesterday, 08:42 PM
                              0 responses
                              11 views
                              0 likes
                              Last Post carnitron  
                              Working...
                              X