Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

blank indicators on chart?

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

    blank indicators on chart?

    Greetings,

    I'm trying to test an indicator on a chart. I've got the historical bars loaded on the chart but when I apply the indicator to the chart there are no plots in the bottom area where the indicator is to appear below the chart...

    I have "Print" statements applied within the indicator in an attempt to determine what the calculations are, however I'm not seeing any output anywhere...how am I to determine how the indicator is operating/calculating??

    #2
    Hi,

    I was able to see something in the log, a message that reads:

    "...index was out of range. Must be non-negative and less than the size of the collection"...does somebody know the meaning of such as message?

    Comment


      #3
      I suggest reading our educational resources, e.g. here http://www.ninjatrader-support.com/v...splay.php?f=31

      In particular: http://www.ninjatrader-support.com/v...ead.php?t=3170

      Comment


        #4
        Hello,

        I've added the following line to my code, but am still not getting the print statements to give me calculated values:

        if(CurrentBar < 6){return;}

        I still am seeing the same error in the log...

        Comment


          #5
          You are going to need to go through your logic and find where it breaks. Comment out complex code segments and leave just the bare necessity. Then, one by one, uncomment segments to see which ones work and which ones don't.

          Also, use an arbitrarily large number for your CurrentBar check to see if it is just a mathematically mistake. Try something like
          Code:
          if (CurrentBar < 100)
               return;
          If the code works after that then it means you just had not enough bars loaded.
          Josh P.NinjaTrader Customer Service

          Comment


            #6
            Greetings,

            OK I tried changing the "min. bars" requirement to 100 and that doesn't seem to be the issue. I have no problem with commenting out lines--however I don't understand why I'm not seeing output to the Output Window. For example the first lines of my strategy (in the "OnBarUpdate" function) are:

            if(CurrentBar < 6){return;}

            Print(
            "The SMI value is: " + SMIndex(2, 13, 3, 25).SMI[0]);
            Print(
            "The LAST SMI value is: " + SMIndex(2, 13, 3, 25).SMI[1]);
            Print(
            "The ROC value is: " + SMIndex(2, 13, 3, 25).ROC[0]);
            Print(
            "The NEW_ROC value is: " + SMIndex(2, 13, 3, 25).NEW_ROC[0]);

            Regardless of the values there should be some sort of output someplace--even if the values are "0", correct? I don't know where I'm supposed to accomplish my debugging...

            Comment


              #7
              I suggest adding more Print statements....

              1. Add a Print statement at the beginning and end of Initialize() just inside the curly braces.
              2. Add a Print statement before and after the "if(CurrentBar < 6) {return;}"

              And don't put any variables in these print statements.

              I do this myself. Sometimes when I've been extraordinarily obtuse, I've inserted a Print statement before/after almost every line of code.

              This will find the line that's causing the problem, fast. Then the error will usually "jump out at you", and if not, post the line(s) in question here.

              Good luck.

              Comment


                #8
                Thank you for your reply. I've added some print statements in places you suggest and removed the variables from within them. I still do not seem to have any print output anyplace I can find (the Output Window and the log)...

                I'm attaching 2 screenshots to show part of the indicator code showing where the print statements are, and the second shot shows the indicator running on a chart...if you look at that chart, I'd like to try to determine why the "ROC" and "NEW_ROC" variables are always 100 and 0 respectively. I cannot do this without any output that gives me some idea how the code is calculating these values...
                Attached Files

                Comment


                  #9
                  Hi Burga1,

                  One of my mistakes when I started developing indicators was that I opened the Output Window after adding an indicator and wondering why it is blank.
                  The window needs to be open before adding the indicator, just mentioning it as a possible source of error.

                  Cheers

                  Comment


                    #10
                    Thanks Rollins, that info is helpful...

                    Comment


                      #11
                      Hi,

                      I might be making some progress as I'm getting some messages in the log now...I have a question. I'm getting an error that reads:

                      "A buy order placed at "date/time" has been ignored since the stop price is less than or equal to the close of the current bar"

                      My question is, well of course--what's the problem? I'm simply trying to place (buy) orders (when conditions for the strategy exist in the current bar) at 2 pips above the HIGH of the current bar and set a stop at 1 pip below the LOW of the current bar...it would be common for that error message to be true...

                      Comment


                        #12
                        To send stop loss orders you want to use the SetStopLoss() method.
                        Josh P.NinjaTrader Customer Service

                        Comment


                          #13
                          Thank you Josh. I've made the change as suggested, although I'm not sure why it is needed because the code I had there before was wizard-generated:

                          EnterLongStopLimit(10000, High[0] + 2 * TickSize, Low[0] + -1 * TickSize, "");

                          Can somebody also please explain why, after looking at my screenshot, I have this output in the "Output Window" and nothing else...

                          Begin Init
                          End Init
                          Begin Init
                          End Init

                          as can be seen in the screenshot I have those print statements in the "Initialize" function but I don't understand why it always outputs the "Output Window" twice like that and nothing else shows up...despite that I have other print statements in the strategy...
                          Attached Files

                          Comment


                            #14
                            EnterLongStopLimit() is not a stop order in the sense of stoploss orders associated with an already open position. Please review this tip for further clarification: http://www.ninjatrader-support.com/v...ead.php?t=3271

                            The reason it prints twice is because it prints once when you bring up the Strategy Window to start a strategy and again when you actually start the strategy. Your OnBarUpdate() prints will only print out if there are bars to update. Please throw your strategy up onto a chart with a rolling data feed and you will see it print.
                            Josh P.NinjaTrader Customer Service

                            Comment

                            Latest Posts

                            Collapse

                            Topics Statistics Last Post
                            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                            0 responses
                            597 views
                            0 likes
                            Last Post Geovanny Suaza  
                            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                            0 responses
                            343 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
                            556 views
                            1 like
                            Last Post Geovanny Suaza  
                            Started by RFrosty, 01-28-2026, 06:49 PM
                            0 responses
                            555 views
                            1 like
                            Last Post RFrosty
                            by RFrosty
                             
                            Working...
                            X