Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Change Needed, Custom NinjaScript Indicator

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

    Change Needed, Custom NinjaScript Indicator

    Hello,

    I have a custom indicator that I developed with the help of the Ninjatrader support forum staff (much appreciated), and I would like to change one thing.

    The indicator draws a LimeGreen or DeepPink horizontal line when a few criteria are met (RSI, EMA, Parabolic SAR, etc). But it seems that the indicator only evaluates this criteria after the price bar close.

    I would like the indicator to evaluate the criteria and to draw the horizontal line on a price change if possible. If that is not possible, then I would like the option of testing the indicator to evaluate the criteria on each tick.

    What change would I need to make?

    Screenshots attached with red rectangles drawn where I see 'Close' settings in the indicator.

    Would I change the 'Close' text to 'On price change' or something similar? If so, what specifically?

    Thanks for your time,
    Attached Files

    #2
    Hello i2w8am9ii2,

    Thanks for your post.

    I suggest that you apply the indicator to a chart and change the Calculate Mode in the indicator panel to test either OnEachTick or OnPriceChange, that way you don't have to change the indicator code (until you find what works best).

    The settings in the indicator panel will override how the indicator is coded.

    With Calculate.OnEachTick or OnPriceChange, Close[0] would represent the current price.

    Comment


      #3
      Hi Paul,

      Thanks for your reply and for the info.

      I checked my saved 'Calculate Mode' settings in the indicator and they all are set to 'On price change' on all of my charts.

      But the indicator behavior (at least on my minute-based charts) is not as I expected at times. What I mean is, for one of the criteria, I only want for a LimeGreen horizontal line to be drawn if the candlestick real body is green

      if (High[0] > Open[0]
      Draw.HorizontalLine(this, "soTag002", Close[0] - numTicksBeyondCandle * TickSize, Brushes.LimeGreen, DashStyleHelper.Solid, lineThickness);


      But at times I will see a red candlestick real body and a LimeGreen horizontal line on the chart, and vise versa.

      Can you see anything in my code above or in the screenshots of my post that would need to be changed to get the desired behavior I'm wanting?

      Comment


        #4
        Hello i2w8am9ii2,

        Thanks for your reply.

        I suspect that you have a condition that is setting it one color but the opposite condition isn't firing which means you would need to debug your code to find out why, As a suggestion, you would need to add a print statement in each action section so that you know when it has been true.

        In your condition set 1 you actually have 3 action sections so add a print statement for each one so that you know you are in the draw section and then when each draw is executed. Same for condition set 2.

        Note, you are not using {} in each section so to add another action with each if statement you will need to add braces, for example:
        if (multiple conditions)
        {
        Print ("time: "+Time[0].TimeOfDay+" Condition 1 set true");
        if (High[0]>Open[0])
        {
        Draw(....);
        Print ("time: "+Time[0].TimeOfDay+" High[0]>Open[0] is true");
        }
        else if (Low[0] < Open[0])
        {
        Draw(...);
        Print ("time: "+Time[0].TimeOfDay+" Low[0] < Open[0] is true");
        }
        }


        I've shown the matching braces with colors, you will need to make sure you watch this careful or you will generate a number of compiling errors.

        Comment


          #5
          Hi Paul,

          Great. Thanks for the info.

          I will see what I can do and hopefully I will be able to get the desired behavior.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          558 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          324 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          101 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          546 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          547 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X