Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Automated Creation of Horizontal Lines in Indicators

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

    Automated Creation of Horizontal Lines in Indicators

    Hello -

    I would like to add horizontal lines programmatically to my indicator rather than hard-coding them.

    Is there a way to do this?

    Thanks,
    Mark

    #2
    Welcome to our forums here Mark - you could use the DrawHorizontalLine command in NinjaScript to achieve this.

    Comment


      #3
      Memory leak when using negative numbers in DrawRegion

      Hello -

      I ended up using DrawRegion instead. It works pretty well and allows me to shade regions.

      My indicator is essentially an oscillator which travels around zero.
      I want to shade the negative regions.

      I ended up doing this:
      //DataSeries: regionLevel 1
      regionLevel1.Set(theTop);
      //the top: a double of 0.01
      //the bottom: a double of -0.01
      DrawRegion("region", CurrentBar, 0, regionLevel1, theBottom, Color.Black, colourLevel1, 5);

      When I use negative values of -0.02 for the top and -0.04 for the bottom, it does not render properly. I get a hack running where I get one portion of the indicator shaded.

      However, when I run this code, NT has some sort of memory leak and it gradually consumed 2.5 GB of ram by EO day today (I have 8 GB of ram). I don't want this to happen. Is there a way to shade below zero regions using DrawRegion without the memory leak?

      System specs:
      Win 7 SP1
      8 GB memory
      NT 7.0.1000.25 (live)

      Thanks,
      Mark
      Attached Files

      Comment


        #4
        Hello Mark,

        Thank you for your response.

        Can you provide the code for DrawRegion that does not work for negative values?

        There should be no issue with negative values, and I am not aware of any memory issues.

        I look forward to assisting you further.

        Comment


          #5
          I figured it out.
          I was instantiating the same Data Series object twice - in 2 separate methods.

          That was the culprit.

          Thanks for your help!

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by CaptainJack, 05-29-2026, 05:09 AM
          0 responses
          256 views
          0 likes
          Last Post CaptainJack  
          Started by CaptainJack, 05-29-2026, 12:02 AM
          0 responses
          166 views
          0 likes
          Last Post CaptainJack  
          Started by charlesugo_1, 05-26-2026, 05:03 PM
          0 responses
          170 views
          1 like
          Last Post charlesugo_1  
          Started by DannyP96, 05-18-2026, 02:38 PM
          1 response
          253 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by CarlTrading, 05-11-2026, 05:56 AM
          0 responses
          203 views
          0 likes
          Last Post CarlTrading  
          Working...
          X