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

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.
    Paul H.NinjaTrader Customer Service

    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.
        Paul H.NinjaTrader Customer Service

        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 gravdigaz6, Today, 11:40 PM
          0 responses
          3 views
          0 likes
          Last Post gravdigaz6  
          Started by MarianApalaghiei, Today, 10:49 PM
          3 responses
          9 views
          0 likes
          Last Post NinjaTrader_Manfred  
          Started by XXtrader, Today, 11:30 PM
          0 responses
          3 views
          0 likes
          Last Post XXtrader  
          Started by love2code2trade, Yesterday, 01:45 PM
          4 responses
          28 views
          0 likes
          Last Post love2code2trade  
          Started by funk10101, Today, 09:43 PM
          0 responses
          9 views
          0 likes
          Last Post funk10101  
          Working...
          X