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

Adding a highlighted region to an indicator in the lower indicator panel

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

    #16
    Hey Jesse,
    I reset the indicator and was looking to add a way to adjust the levels if needed and once I did that it plotted. Not sure why but it is now plotting on the chart.
    Thank you for all your direction. I couldn't have done it without your help.
    Thanks again.
    James

    Comment


      #17
      Hey Jesse,
      Thanks again for all your help.

      I'm getting a "Statement Expected" error on the first line after the OnBarUpdate.
      The indicator compiles and it loads correctly and functions correctly on the chart but not sure how to fix the Statement Expected error.
      Do you have any ideas?
      Thanks again.

      protected override void OnBarUpdate()
      {​​



      double amountUp = 0;
      double amountDown = 0;
      double rmi = 0;

      if (CurrentBar ==0)
      {

      Draw.RegionHighlightY(this,"tag1", false, uppertz, lowertz, TzColor,TzColor, tzopacity );
      avgUp[0] = 0;
      avgDown[0] = 0;

      return;

      }

      if (CurrentBar < (Period + shift))
      {
      return;
      }
      else if (CurrentBar == (Period + shift))
      {
      double sumUp = 0;
      double sumDown = 0;

      for (int barsAgo = 0; barsAgo < Period; barsAgo++)
      {
      amountUp = Input[barsAgo] - Input[barsAgo + shift];
      if (amountUp >= 0)
      {
      amountDown = 0;
      }
      else
      {
      amountDown = -amountUp;
      amountUp = 0;
      }
      sumUp = sumUp + amountUp;
      sumDown = sumDown + amountDown;
      }
      avgUp[0] = sumUp / Period;
      avgDown[0] = sumDown / Period;
      }
      else
      {
      amountUp = Input[0] - Input[shift];
      if (amountUp >= 0)
      {
      amountDown = 0;
      }
      else
      {
      amountDown = -amountUp;
      amountUp = 0;
      }
      avgUp[0] = (avgUp[1] * (Period - 1) + amountUp) / Period;
      avgDown[0] = (avgDown[1] * (Period - 1) + amountDown) / Period;
      }

      if ((avgUp[0] + avgDown[0]) != 0)
      {
      rmi = 100 * avgUp[0] / (avgUp[0] + avgDown[0]);
      }

      else rmi = 0;


      Value[0] = rmi;




      }​

      Comment


        #18
        Hello laoshr,

        Are you using the NinjaScript editor to edit the file? I have seen that type of situation where it compiles but still displays an error in the editor when alternate text editors are used which do not correctly work with C# files. That generally happens when extra characters like incorrect line endings are added. That could also happen if you are copying and pasting code from an external source.
        JesseNinjaTrader Customer Service

        Comment


          #19
          Jesse,
          Good morning. Yes, I'm using the NT editor. I will take a look at those things you stated and see if I can find anything that is out of place or incorrect.
          Thanks again.
          James

          Comment


            #20
            Hello laoshr,

            If you can't find anything specific out of place one solution would be to create a new empty indicator and then move the code over 1 line at a time to avoid any misplaced formatting characters. You would have to first exclude the original indicator from compilation so when you compile the new script you can check if you copied over the part with the problem.
            JesseNinjaTrader Customer Service

            Comment


              #21
              Thanks, Jesse. I will try copying the code over and see what I get.
              Again, thank you for your time.
              James

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by ageeholdings, Today, 07:43 AM
              0 responses
              6 views
              0 likes
              Last Post ageeholdings  
              Started by pibrew, Today, 06:37 AM
              0 responses
              4 views
              0 likes
              Last Post pibrew
              by pibrew
               
              Started by rbeckmann05, Yesterday, 06:48 PM
              1 response
              14 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
              12 views
              0 likes
              Last Post burtoninlondon  
              Working...
              X