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

Current Range Bar possible High & Low Plot

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

    #16
    Not sure what I am suppose to be looking for in your picture. Please clarify.
    Josh P.NinjaTrader Customer Service

    Comment


      #17
      I blew it up a little so you could see, but also everything got somewhat 'fat'.

      When the indicator works properly, it simply plots a hash mark above and below the currently forming Range Bar until such time as it is complete, i.e. with a 4-tick range bar the bar is incomplete with only 1,2 or 3 tick range, but as soon as the High-Low = 4 ticks, that Range Bar is 'complete' and the code says that as soon as this condition is met, 'return', i.e. don't plot anything.

      On most charts this is working exactly as desired, but for some reason on some charts, the plots remain there on previous bars making for a messy-looking chart. My picture shows many bars in the past (i.e. not the current bar on the chart, i.e. the last bar) with the hash plots at the High and Low of a bar. It doesn't happen every bar, but on many.

      So I have no idea why most of the time it works fine, but some of the time it does not.

      Comment


        #18
        Once you set the plot it is set. Just because a condition is no longer true does not "unset" the plot.
        Josh P.NinjaTrader Customer Service

        Comment


          #19
          I attach a couple more little pictures showing it working properly, once when the bar is complete but the new bar is not yet up, the second with a new bar (and different range number of 6 versus 4 in the first) showing the hash plots indicating the maximum possible high and/or low of the currently -forming bar. I also show a few previous bars that have no left-over hash plots - as is the case when it is working properly.
          Attached Files

          Comment


            #20
            Once you set a plot it does not get unset just because a condition is no longer true. I suggest you drop the whole plot idea and just simply use DrawLine(). Draw two lines where needed and remove the line objects when not needed.
            Josh P.NinjaTrader Customer Service

            Comment


              #21
              I have also tried printing out to many decimals as in the following:

              Print( PossHigh[0].ToString("0.0000000"));
              Print( PossLow[0].ToString("0.0000000"));
              Print( Close[0].ToString("0.0000000"));

              But although it compiles, it does not print anything to the Output window. This is following the tip in the Help Menu:

              Tips
              1. You can align prices to be formatted for easier debugging such as Low[0].ToString("0.00").


              I suspect I am not understanding how to use those strings, but since nothing is explained am not sure how to proceed. Do I have to alter the main coding to have everything put into string mode? I doubt it, but in any case, don't know how to do that yet.

              Comment


                #22
                Originally posted by NinjaTrader_Josh View Post
                Once you set a plot it does not get unset just because a condition is no longer true. I suggest you drop the whole plot idea and just simply use DrawLine(). Draw two lines where needed and remove the line objects when not needed.
                Thanks. I have no idea how to do what you suggest, i.e. first draw it and then undraw it.

                Also, when you say: "Once you set a plot it does not get unset just because a condition is no longer true.": the funny thing is, it works fine on 90% of the charts, but doesn't only on a few for mysterious reasons. Which is why I sent in the example pictures. in the first 'good' picture, there had been plots above and below but once the bar was formed they were no longer plotted.

                I suspect another reason for this might be that if the bar closes at a high or low which often happens but the next tick is the new bar at which point there is a new Close[0] that the old bar did not have time to have the plots removed, i.e. Tick 300 makes the bar complete and Tick 301 makes a new bar, or maybe even Tick 300 was NOT a complete bar but it trades through the price and the next tick creates a new bar.

                Having written the above I threw up a 2-tick range chart and it works perfectly with only the current forming bar having the two hash marks. Then I threw up a 1-tick range chart, can't get any tighter than that: works great! So: still a mystery!

                If you could provide an example of how to plot a line that is only the width of a hash mark and also tell it to go away afterwards as a new bar forms, that would be much appreciated, since that is all I am trying to do here: plot the possible high and low of a forming Range Bar and once it is formed, have those plots disappear, either whilst the bar is still up there or when the new bar starts, either way is fine. But what I don't want is all those lines/hashes left over simply because it makes the chart look messy.
                Last edited by cclsys; 08-13-2009, 09:33 AM.

                Comment


                  #23
                  Unfortunately I cannot review your code to determine what is happening with it, but I assure you in normal behavior, once set, plots do not just unset.

                  DrawLine() then RemoveDrawObject() when you don't want it anymore.
                  You could even just use DrawLine() with a tag name and then when it is time to draw a new line, use the same tag name which would then move the old line to the new location.
                  Josh P.NinjaTrader Customer Service

                  Comment


                    #24
                    Originally posted by NinjaTrader_Josh View Post
                    Unfortunately I cannot review your code to determine what is happening with it, but I assure you in normal behavior, once set, plots do not just unset.

                    DrawLine() then RemoveDrawObject() when you don't want it anymore.
                    You could even just use DrawLine() with a tag name and then when it is time to draw a new line, use the same tag name which would then move the old line to the new location.
                    Thanks, Josh. It would be much more helpful if in yr replies you wrote out a quick code sample so I can learn what you mean.

                    The Output Window is printing now. I guess when it is connected it only prints new occurrences. I didn't know that. In any case, the decimals seem to be identical so that isn't the issue.

                    Printing question:

                    How do I tell it to print 2 or more things on the same line with spaces in between. There are no examples in the Help Menu. For example:

                    Print(Time, Close[0], my double);

                    Comment


                      #25
                      cclsys,

                      Please look at the Help Guide articles for them. Examples are almost always contained there.



                      Print(Time[0] + " " + Close[0] + " " + double);
                      Josh P.NinjaTrader Customer Service

                      Comment


                        #26
                        Originally posted by NinjaTrader_Josh View Post
                        cclsys,

                        Please look at the Help Guide articles for them. Examples are almost always contained there.



                        Print(Time[0] + " " + Close[0] + " " + double);
                        Thanks for the Print Help. I was messing it up with illicit commas.

                        As to the Drawing Objects, from the Help Menu (before reading your links which are the same) I added in:

                        DrawLine("PossHigh", false, 1, PossHigh[0], 0, PossHigh[0], Color.Olive,DashStyle.Solid, 3);
                        DrawLine("PossLow", false, 1, PossLow[0], 0, PossLow[0], Color.MediumBlue, DashStyle.Solid, 3);


                        Also shorter form:
                        //DrawLine("PossHigh", 1, PossHigh[0], 0, PossHigh[0], Color.Olive);

                        It is working fine although I haven't tested on lots of charts so maybe the same problem will re-occur as it does with the original version.

                        I have the original Plots as Transparent now though probably the whole thing should be re-written to have them just as data series and to start off defining 2 lines, but anyway:

                        Problem: is there any way to emulate the Hash plot which plots above the bar, centred above it. Right now it seems I can only draw a line from the previous bar to the beginning of the current bar. It works, but it would be much nicer if I could at least get it centred and/or stretch it out wider to a little bit past the current bar.

                        I attach pic so you can see the problem.
                        Attached Files

                        Comment


                          #27
                          I would still like to know why sometimes the original works and sometimes it doesn't. It is better (plotting the hash) but also there are occasional times with the new one when the line doesn't move in response to the bar changes, whereas the original plot hashes moved perfectly every time and immediately.

                          Here is the condition:

                          if (
                          ( High[0] == ( Low[0] + (Bars.Period.Value*TickSize) ) )
                          ||
                          ( Low[0] == ( High[0] - (Bars.Period.Value*TickSize) ) )
                          )
                          return;

                          Now it is unnecessary to have both conditions since if one happens so does the other, but I don't think it can hurt. In other words, if the High-Low = the Range set for the bar, don't plot anything.

                          Is there another more foolproof way of doing this?

                          Comment


                            #28
                            cclsys, you will have to get down and dirty with the code and figure out why it is not working via debugging.

                            To get a draw object directly overhead the bar, I would recommend using DrawDot instead of DrawLine. DrawDot plots directly overhead, instead of from the center of the current bar to the center of the previous bar, like with DrawLine.

                            A more efficient way to do your check would be this:
                            Code:
                            if (High[0] == (Low[0] + Bars.Period.Value * TickSize))
                                // do something
                            else if (Low[0] == (High[0] - Bars.Period.Value * TickSize))
                                // do something else
                            When using an "else if" only one if statement will be executed, saving computational resources because it doesn't have to check each one. If the first if statement is true, only the first "// do something" will be executed. If the first if statement is not true, it will move on to the second one and only execute the "// do something else'' if that if statement is true.

                            If you still have questions, let us know.
                            AustinNinjaTrader Customer Service

                            Comment


                              #29
                              I changed the code and I still get the error on the TF.

                              Here is the ES chart that is fine.

                              The TF chart has the errors.
                              Attached Files

                              Comment


                                #30
                                Just to check in, I'm running the code posted near the beginning and everything looks fine to me. Is this what you guys are getting?
                                Attached Files
                                AustinNinjaTrader Customer Service

                                Comment

                                Latest Posts

                                Collapse

                                Topics Statistics Last Post
                                Started by DJ888, 04-16-2024, 06:09 PM
                                4 responses
                                11 views
                                0 likes
                                Last Post DJ888
                                by DJ888
                                 
                                Started by terofs, Today, 04:18 PM
                                0 responses
                                5 views
                                0 likes
                                Last Post terofs
                                by terofs
                                 
                                Started by nandhumca, Today, 03:41 PM
                                0 responses
                                5 views
                                0 likes
                                Last Post nandhumca  
                                Started by The_Sec, Today, 03:37 PM
                                0 responses
                                3 views
                                0 likes
                                Last Post The_Sec
                                by The_Sec
                                 
                                Started by GwFutures1988, Today, 02:48 PM
                                1 response
                                9 views
                                0 likes
                                Last Post NinjaTrader_Clayton  
                                Working...
                                X