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

Indicator won't paint bars

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

    Indicator won't paint bars

    Hello, I have this indicator that is supposed to paint bars and outlines a color depending on a specified size, but it isn't doing anything. Any clue as to what the problem is? I can't get it to work at all, even without any other indicators and just the default chart.
    Attached Files

    #2
    Hello augustfay,

    Thank you for your reply.

    First, I suggest you print what the value of range is on each bar to see what the values you're getting - you're only painting a different color if the range is greater than 20, but the values I get on, for example, a 1 minute ES chart are generally between 0.25 and 2.25, which would never be true based on your conditions. If you're wanting the number of ticks in the range, you should divide those values by TickSize.

    Also, you're not resetting the bar brushes back to the original colors after the bars would get painted. You'd want to modify that to something like this:


    Code:
                if (range >= barSize)
                {
                    BarBrushes[0] = region3Color;
                    CandleOutlineBrushes[0] = region3Color;
                }
                else
                {
                    BarBrushes[0]= null;
                    CandleOutlineBrushes[0] = null;
                }
    Setting them back to null when the condition is not true will have the bar be painted the original color.

    Please let us know if we may be of further assistance to you.


    Kate W.NinjaTrader Customer Service

    Comment


      #3
      Hello again Kate, thank you for your reply. Sorry, I’m very new at all of this and I’m not sure how to go about dividing it by tick size or where exactly to put enter the values. So it’s 0.25 for ticksize, I should use Range()?

      Comment


        #4
        Hello augustfay,

        Thank you for your reply.

        You could just change the calculation to something like this:

        Code:
        range = Instrument.MasterInstrument.RoundToTickSize((High[0]-Low[0])/TickSize);
        Please let us know if we may be of further assistance to you.
        Kate W.NinjaTrader Customer Service

        Comment


          #5
          Thank you Kate, what I’m really trying to accomplish this weekend includes an indicator that colors bars based on the percentage of the bar. So for example if a bar closes above 50% it’s overall size, or less than 30%, etc. is there a simple way to convert this indicator to paint according to bar percent instead of according to bar size?

          Comment


            #6
            Hello augustfay,

            Thank you for your reply.

            I'm assuming you mean what percent of the bar including the high and low of the bar, is that correct? So something like the Low/Close as a percentage of the High/Low?

            Thank you in advance; I look forward to assisting you further.
            Kate W.NinjaTrader Customer Service

            Comment


              #7
              I'm not sure, but I'm starting fresh. I just have this simple script, let me try and explain.
              I can paint bars such as...

              dojis: if (Open[0] == Close[0])

              strong bullish: if(Close[0] >= Low[0] + 80*(High[0]-Low[0]))

              but I can't for the life of me figure out how to paint bars that for example, have larger up and down wicks than body sizes, such as these in the photo.
              Do you have a suggestion? I feel like there has to be something simple and efficient that accomplishes all of this but I'm either just overcomplicating it or I maybe I don't know how to describe it properly. Thank you for your help.

              Comment


                #8
                Hello augustfay,

                Well, you'd need to calculate the wick size differently depending if it's an up or a down bar.

                So something like

                Code:
                if (Open[0] > Close[0])
                {
                double upWick = High[0] - Open[0];
                double downWick = Close[0] - Low[0];
                double bodySize = Open[0] - Close[0]
                
                //do whatever comparison you like here and paint the bar accordingly.
                }
                else if (Open[0] < Close[0]
                {
                double upWick = High[0] - Close[0];
                double downWick = Open[0] - Low[0];
                double bodySize = Close[0] - Open[0]
                
                // do whatever comparison you want and paint the bar accordingly
                }
                Please let us know if we may be of further assistance to you.
                Kate W.NinjaTrader Customer Service

                Comment


                  #9
                  Hello Kate, I wrote a response to this over a week ago but it was during that week with the forum maintenance going on and it looks as though a couple of my replies that day were either deleted or not posted at all. Just wanted to say thank you for always being so helpful. I am also a little unclear on how you would adjust these parameters, I had an example script that I wrote directly into this reply box and I can't remember it now. Would something like this work? Or am I totally off. Thank you again.
                  if (Open[0] > Close[0])
                  {
                  double bodySize = close[0] - open[0] < 40* open[0]-high[0]

                  Comment


                    #10
                    Hello augustfay,

                    Thank you for your note.

                    Are you trying to calculate a percentage of the Open minus the High? You can't assign a comparison to a variable like you're trying to do there - the result of the comparison would either be true or false, and you're trying to assign that result to a double when those could only be saved in a bool variable - you'd definitely get a compile error trying this. Also, It's unlikely that the close minus the open would ever be greater than 40 times the Open minus the High. If you are calculating 40 percent of the Open - the High, you'd need to be multiplying by 0.40, not 40.

                    What exactly are you trying to calculate there? Could you explain the logic you're trying to achieve?

                    Thanks in advance, I look forward to assisting you further.
                    Kate W.NinjaTrader Customer Service

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by kujista, Today, 05:44 AM
                    0 responses
                    6 views
                    0 likes
                    Last Post kujista
                    by kujista
                     
                    Started by ZenCortexCLICK, Today, 04:58 AM
                    0 responses
                    8 views
                    0 likes
                    Last Post ZenCortexCLICK  
                    Started by sidlercom80, 10-28-2023, 08:49 AM
                    172 responses
                    2,281 views
                    0 likes
                    Last Post sidlercom80  
                    Started by Irukandji, Yesterday, 02:53 AM
                    2 responses
                    18 views
                    0 likes
                    Last Post Irukandji  
                    Started by adeelshahzad, Today, 03:54 AM
                    0 responses
                    11 views
                    0 likes
                    Last Post adeelshahzad  
                    Working...
                    X