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!
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
NinjaTrader
Need little help with Ticks Per minute indicator development
Collapse
X
-
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
-
BertrandNinjaTrader Customer Service
Comment
-
Originally posted by NinjaTrader_Bertrand View Post
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
-
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
-
Originally posted by cclsys View PostSecond, 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);}RayNinjaTrader Customer Service
Comment
-
Originally posted by NinjaTrader_Austin View PostHi 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.
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
-
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?
Comment
-
Originally posted by NinjaTrader_Austin View PostHi, 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.
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
-
Originally posted by eDanny View PostAs 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?
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
-
Originally posted by eDanny View PostI 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.AustinNinjaTrader Customer Service
Comment
-
Originally posted by NinjaTrader_Austin View Postcclsys, 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.
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by ETFVoyageur, Today, 07:55 PM
|
0 responses
6 views
0 likes
|
Last Post
by ETFVoyageur
Today, 07:55 PM
|
||
Started by janio973, Today, 07:24 PM
|
1 response
7 views
0 likes
|
Last Post Today, 07:35 PM | ||
Started by aligator, 01-06-2022, 12:14 PM
|
4 responses
242 views
0 likes
|
Last Post
by john_44573
Today, 06:11 PM
|
||
Started by reynoldsn, Today, 05:56 PM
|
0 responses
13 views
0 likes
|
Last Post
by reynoldsn
Today, 05:56 PM
|
||
Started by bortz, 11-06-2023, 08:04 AM
|
51 responses
1,996 views
0 likes
|
Last Post
by aligator
Today, 05:50 PM
|
Comment