Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Shortcut?

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

    Shortcut?

    Let me preface this with saying I'm a complete programming noob.

    I wanted to tinker around with the coding for an existing Ninjascript system indicator. I created a new custom indicator, then copied and pasted a system indicator (CandleStickPattern) into my newly created indicator. When I tried compiling it, the errors popped up. I would like to find a NinjaSript similar to what I'm looking for and see what I can do with playing around with it. Anyone know if there is a way to do this?

    Thanks,

    #2
    Gennaker, welcome to our forums - please delete just created custom indicator again from the platform.

    And then start this process by opening up a system indicator you wish to copy and right click in the code selecting then 'save as' and enter a new name for the script to be copied into. Then you could gradually work your changes in this script.

    For getting started in NinjaScript, I generally recommend taking a look at those tutorials:

    Comment


      #3
      The tutorials were helpful and I've been able to manipulate some of the coding to create a few indicators I want. However, I tried to delete a draft NinjaScript and got an error message saying it was referenced by another NinjaScript and these dependencies must be removed first. I've gone back through all the files I worked on today and can not find where I may have done this. I guess there is no harm in leaving it there?

      Comment


        #4
        Gennaker, great to hear on your successes - I would then simply leave it there for now.

        Comment


          #5
          NinjaTrader_Bertrand, when trying to use the following statement: if (SMA(10) > High[1]), I get an error message saying I can use '>' with Ninja.Trader.SMA and 'double'. I've used a similar 'double' statement in other indicators. Would appreciate your insight.

          Comment


            #6
            Gennaker, you would need to pick a double value from the SMA series for comparison :

            if (SMA(10)[0] > High[1])

            Comment


              #7
              That did the trick. Thanks. I've run into a different problem. I was able to create 4 indicators that worked by editing an existing ninjascript. Now 3 of the 4 will not work. I haven't been diligent about deleting previous versions of ninjascripts as I work through different approaches. Could this cause them to stop workin?

              Comment


                #8
                Gennaker, can you please clarify what you mean by 'not working'? So they stopped working as you applied them to your charts? Or would they show compile errors? This could be the case already if one script has as issue in the code, NinjaTrader compiles all scripts into one assembly to be used at runtime then, so they all would have to be compilable and free of any offending code.

                Comment


                  #9
                  They stopped working as I applied them to the charts.

                  Comment


                    #10
                    Any errors then in your Control Center log tab after you've applied them on the charts?

                    Comment


                      #11
                      I hadn't checked that. It did register an OnUpdateBar error saying I was accessing an invalid index since it's out of range. It doesn't make sense because I'm dealing with candlestick scripts that only go back one bar. I tried to comment out anything else including indexes. Plus I've downloaded 5 days of historical data and am using a 5 minute chart. Can't figure out why this would happen.

                      Comment


                        #12
                        Please check into this tip here - http://www.ninjatrader.com/support/f...ead.php?t=3170

                        and then ensure a CurrentBar's check is added to all your scripts OnBarUpdate() as needed.

                        Comment


                          #13
                          I did use an SMA(10) index, but that's only 10 bars back.

                          Comment


                            #14
                            So for SMA(10), I would need to use a code like,

                            If (CurrentBar < 10)
                            Return;
                            ?

                            Comment


                              #15
                              Yes, that did the trick. Danke shoen, Bertrand.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                              0 responses
                              581 views
                              0 likes
                              Last Post Geovanny Suaza  
                              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                              0 responses
                              338 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by Mindset, 02-09-2026, 11:44 AM
                              0 responses
                              103 views
                              0 likes
                              Last Post Mindset
                              by Mindset
                               
                              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                              0 responses
                              554 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by RFrosty, 01-28-2026, 06:49 PM
                              0 responses
                              552 views
                              1 like
                              Last Post RFrosty
                              by RFrosty
                               
                              Working...
                              X