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

Need little help with Ticks Per minute indicator development

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

    #16
    Originally posted by NinjaTrader_Austin View Post
    cclsys,

    If you want to print out the values for the series that the average runs on to see if there is any funny data (like a negative value), you could do a for loop:
    Code:
    for (int i = 0;i<15;i++)
    {
         Print("TPM[" + i + "]:" + "\t" + TPM[i]);
    }
    Austin. Thanks for the above. Sorry for late reply, have been falling behind with emails recently due to changing computers and suchlike. Will report back after trying this out.

    Comment


      #17
      Well, I am not sure that this is all that different from just printing out the basic TPM or TPMavg. I have found that the problem only happens when using rather short term tick charts whereas with the ones I mainly use (that usually last 30 - 120 seconds) it never comes up.

      I tried changing TPM to being 1 if it was 0 but that still didn't work. Then I changed the timeGap to 1 if it was 0 and that worked because when there are bars that end at the same time the last one ended, i.e. that last 0 seconds, that was throwing it off. So the added line is:

      if (timeGap == 0) {timeGap = 1;}

      Now it works fine.

      FINALLY:

      I would like to be able to change the barcolor when it 'maxes out' based on the code. The reason for the max-out feature is that some bars, especially around reports in certain instruments, have something like 50 times the typical range meaning that the subsequent bars in the panel display as almost invisible midgets making the indicator display a little unbalanced. So the idea is to simply limit the size of these spike bars so that they tell the story without distorting everything else. Ideally, such bars could be painted red, say, versus the default green.

      But I cannot figure out how to change the bar color when that condition exists. I tried writing in:

      if (tpmsys > ATR (21)[0]*6 /TickSize )
      {tpmsys = ATR(21)[0]*6 /TickSize ;
      BarColor = Color.Red; }

      but although it compiled and ran fine, that of course simply changes the bar color in the main chart, not the indicator.

      Any suggestions please for this final embellishment to a now working indicator so that I can change the indicator (TPM) bar color? What I am looking for specifically is that when it 'maxes out' (the if condition in the first line above) that the TPM bar color changes, but when it is not maxed out it remains the default color in the initial line:
      Add(new Plot(Color.FromKnownColor(KnownColor.DarkGreen), PlotStyle.Bar, "TPM"));
      Last edited by cclsys; 07-30-2009, 05:30 AM.

      Comment


        #18
        cclsys, to change the plot colors of your indicator you would need to work with multiple plots (for each color one) in NinjaTrader 6.5 -



        Then you can select which one to use according to your MaxOut conditions in the code.
        BertrandNinjaTrader Customer Service

        Comment


          #19
          Originally posted by NinjaTrader_Bertrand View Post
          cclsys, to change the plot colors of your indicator you would need to work with multiple plots (for each color one) in NinjaTrader 6.5 -



          Then you can select which one to use according to your MaxOut conditions in the code.
          Reply:
          Thanks. First: is that really the only way to change an indicator plot color, by building essentially 2 (or more) separate plots and joining them together?

          Second, assuming this is the case, SUGGESTION for NT7:
          Add in custom command 'PlotColor' which would work the same as BackColor or BarColor except that you can also specify which Plot this applies to. In this case, for example, it could go something like:

          if (maxout ==true)
          { PlotColor = (Plot[0], Color.HotPink); else
          {PlotColor = (Plot[0], Color.DarkGreen);}

          +++++++++++

          Bar Width question:
          Also, is it possible with this same Maxout condition to simply change the width of the bars in the TPM plot?

          I have tried things like:

          if (tpmsys > ATR (21)[0]*6 /TickSize )
          {
          tpmsys = ATR(21)[0]*6 /TickSize ;
          BackColor = Color.Salmon;
          Plots[0].Pen.Width = 5;
          //BarColor = Color.Red;
          }
          else Plots[0].Pen.Width = 3;

          or:

          if (tpmsys > ATR (21)[0]*6 /TickSize )
          {
          tpmsys = ATR(21)[0]*6 /TickSize ;
          BackColor = Color.Salmon;
          Plots[0].Pen.Width = 5;
          else Plots[0].Pen.Width = 3;
          //BarColor = Color.Red;
          }

          Both compile fine and run, but the second just changes all bars in Plot[0] to width 5, and the first changes nothing. Is there a way to do this written out correctly, or am I just trying for something impossible here?

          Comment


            #20
            Hi there, your findings are correct--you can't change the width of individual bars. Each plot has one setting for all data points on the plot.

            As a work-around, you could try Bertrand's suggestion to have multiple plots, and set the value to the correct plot. That way you'd be able to have wide bars, narrow bars, blue bars, and green bars (if you so desired) all on one indicator panel.

            Thank you for your suggestion, I'll forward it on.
            AustinNinjaTrader Customer Service

            Comment


              #21
              Originally posted by cclsys View Post
              Second, assuming this is the case, SUGGESTION for NT7:
              Add in custom command 'PlotColor' which would work the same as BackColor or BarColor except that you can also specify which Plot this applies to. In this case, for example, it could go something like:

              if (maxout ==true)
              { PlotColor = (Plot[0], Color.HotPink); else
              {PlotColor = (Plot[0], Color.DarkGreen);}
              Something very similar is already built in for NT7.
              RayNinjaTrader Customer Service

              Comment


                #22
                Originally posted by NinjaTrader_Austin View Post
                Hi there, your findings are correct--you can't change the width of individual bars. Each plot has one setting for all data points on the plot.

                As a work-around, you could try Bertrand's suggestion to have multiple plots, and set the value to the correct plot. That way you'd be able to have wide bars, narrow bars, blue bars, and green bars (if you so desired) all on one indicator panel.

                Thank you for your suggestion, I'll forward it on.
                reply:
                in order to create the two plots, I have made an additional plot at first in the Initialize section, but now I can't get avgTPM because I only have the tpmsys double for it to reference and since I can't index that double, now I can't get an average of TPM as before because it has been split into two plots so the average calculation basis TPM goes wild.

                I presumed this means I now have to create a parallel data series for the avgTPM to reference which I have done and now I am almost there apart from one little niggle which is that sometimes both colors are plotted on the same bar.

                The section that codes the two plots is:

                tpmseries.Set(tpmsys); /* the data series to reference */

                if (tpmsys == ATR (21)[0]*6 /TickSize )
                {
                TPM2.Set(1, tpmseries[1]);
                TPM2.Set(tpmseries[0]);
                }

                else
                {
                TPM.Set(1, tpmseries[1]);
                TPM.Set(tpmseries[0]);
                }

                I tried reversing the order and logics to:

                if (tpmsys < ATR (21)[0]*6 /TickSize )
                {
                TPM.Set(1, tpmseries[1]);
                TPM.Set(tpmseries[0]);

                }

                else
                {
                TPM2.Set(1, tpmseries[1]);
                TPM2.Set(tpmseries[0]);
                }

                but that made no difference.
                can anyone see why it is double plotting? This happens the first bar that the initial condition is triggered for TPM2. If there are two bars with this condition in a row, then it plots only the max color not both colors for the second or subsequent bars.

                The difference in bar widths is working fine.

                Comment


                  #23
                  Hi, can you please post the full code so we can better see what is going on?

                  If you'd like, you can email it to support at ninjatrader dot com with Attn Austin in the subject line.

                  Thank you.
                  AustinNinjaTrader Customer Service

                  Comment


                    #24
                    As long as we are talking about multiple plots, this is a slightly off topic question. In NT7 are you going to fix the two color line stitching problem when joining two different color line plots together? The workaround we use now is so buggy and inaccurate. If the answer is yes, how is that going to affect current code?
                    eDanny
                    NinjaTrader Ecosystem Vendor - Integrity Traders

                    Comment


                      #25
                      Originally posted by NinjaTrader_Austin View Post
                      Hi, can you please post the full code so we can better see what is going on?

                      If you'd like, you can email it to support at ninjatrader dot com with Attn Austin in the subject line.

                      Thank you.
                      Thanks for help and offer for more. Am happy to keep posting here since others might find it helpful once kinks ironed out.

                      Every time I make an indicator I play around with a few things partly to get better at coding. In this case I have added in the ability to plot the ATR (in ticks) and also a backcolor when the average is rising. To be honest, just seeing the bars is good enough, although it is good to have the limitation based on something to avoid 'report bar' distortions that make subsequent ones hard to see. The backcolor and additional ATR line don't add much to it.


                      I attach the code.
                      Attached Files

                      Comment


                        #26
                        Originally posted by eDanny View Post
                        As long as we are talking about multiple plots, this is a slightly off topic question. In NT7 are you going to fix the two color line stitching problem when joining two different color line plots together? The workaround we use now is so buggy and inaccurate. If the answer is yes, how is that going to affect current code?
                        There have been improvements made to joining two different color plots together, and it will not break your code.

                        From the NT7 announcement:
                        Multi-Colored Plots
                        Support for multi-color plots. Although this can be achieved in 6.5 through the use of multiple plots, in 7.0 this can be achieved more efficiently with the use of a single plot.
                        AustinNinjaTrader Customer Service

                        Comment


                          #27
                          I didnt think it would actually break code but will we have to edit code to take advantage of the fix? I would think the new method would be like code for Bars or Dots where no stitching is needed.
                          eDanny
                          NinjaTrader Ecosystem Vendor - Integrity Traders

                          Comment


                            #28
                            Originally posted by eDanny View Post
                            I didnt think it would actually break code but will we have to edit code to take advantage of the fix? I would think the new method would be like code for Bars or Dots where no stitching is needed.
                            Yes, editing will be necessary.
                            AustinNinjaTrader Customer Service

                            Comment


                              #29
                              cclsys, I've imported and looked at the code, but everything is plotting the same color. It seems the if/else isn't restrictive (too restrictive?) enough. Please see the attached screenshot, I don't quite know what I'm supposed to be looking for.
                              Attached Files
                              AustinNinjaTrader Customer Service

                              Comment


                                #30
                                Originally posted by NinjaTrader_Austin View Post
                                cclsys, I've imported and looked at the code, but everything is plotting the same color. It seems the if/else isn't restrictive (too restrictive?) enough. Please see the attached screenshot, I don't quite know what I'm supposed to be looking for.
                                This is because you loaded a minute chart. (The maximum values were not 6* the ATR value in the condition. If you change the same chart to a tick chart, it should work fine. I don't follow CL, but on ZB, say 45-90 ticks, plenty of examples.

                                Comment

                                Latest Posts

                                Collapse

                                Topics Statistics Last Post
                                Started by Tim-c, Today, 02:10 PM
                                1 response
                                7 views
                                0 likes
                                Last Post NinjaTrader_ChelseaB  
                                Started by Taddypole, Today, 02:47 PM
                                0 responses
                                2 views
                                0 likes
                                Last Post Taddypole  
                                Started by chbruno, 04-24-2024, 04:10 PM
                                4 responses
                                50 views
                                0 likes
                                Last Post chbruno
                                by chbruno
                                 
                                Started by TraderG23, 12-08-2023, 07:56 AM
                                10 responses
                                399 views
                                1 like
                                Last Post beobast
                                by beobast
                                 
                                Started by lorem, Yesterday, 09:18 AM
                                5 responses
                                25 views
                                0 likes
                                Last Post NinjaTrader_ChelseaB  
                                Working...
                                X