Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Composite momentum
Collapse
X
-
-
Dear koganam,
its been long time since I asked u for help
. I wanted to ask u the following: given an indicator which plots a combination of two other indicators, in my case is that mass flow rate in previous posts, vol/time, is it possible to make NT plot in the same bar the two different indicators? In other words, is it possible to "ask" NT to show me how much each indicator contributes to the single bar? Is it clear what Im saying? I tried to put something like
double mfr = volume[0]/(time[0]);
double vol = volume[0];
Value.Set(mfr);
volume.Set(vol);
PlotColors[0][0] = upColor;
PlotColors[1][0] = dnColor;
where the first should plot the vol/time and the second only the volume, hoping that it would plot the relative percentages in the same bar but clearly it doesnt: if it did I wouldnt be here bothering u
Thank u for ur time (even just for reading it)
Regards
Comment
-
You should be able to plot anything that you want. I am not sure that I understand the question. Provided time is a DataSeries, and that time[0] is never zero, that should plot fine.Originally posted by michael fantoni View PostDear koganam,
its been long time since I asked u for help
. I wanted to ask u the following: given an indicator which plots a combination of two other indicators, in my case is that mass flow rate in previous posts, vol/time, is it possible to make NT plot in the same bar the two different indicators? In other words, is it possible to "ask" NT to show me how much each indicator contributes to the single bar? Is it clear what Im saying? I tried to put something like
double mfr = volume[0]/(time[0]);
double vol = volume[0];
Value.Set(mfr);
volume.Set(vol);
PlotColors[0][0] = upColor;
PlotColors[1][0] = dnColor;
where the first should plot the vol/time and the second only the volume, hoping that it would plot the relative percentages in the same bar but clearly it doesnt: if it did I wouldnt be here bothering u
Thank u for ur time (even just for reading it)
Regards
Which plot are you missing?
What errors are noted in the log?
Comment
-
Hello koganam,
thank u for replying!!
There r not errors whatsoever in the log: no outside range, nothing! Its not plotting the volume, I only get the vol/time, in green, the upColor: I checked the values of the bars against it the other indicator I had in the Data Box
I post the script so u can see it:
{
[Description(" blabla")]
public class MassFlowRate2 : Indicator
{
#region Variables
private DataSeries volume;
private DataSeries mfr;
private Color upColor = Color.Green;
private Color dnColor = Color.Red;
#endregion
protected override void Initialize()
{
Add(new Plot(new Pen(Color.Red, 9), PlotStyle.Bar, "mfr"));
Add(new Plot(new Pen(Color.Blue, 9), PlotStyle.Line, "volume"));
mfr = new DataSeries(this);
volume = new DataSeries(this);
}
protected override void OnBarUpdate()
{
if (CurrentBar==0)
{
mfr.Set(0);
volume.Set(0);
Value.Set(0);
}
else
{
mfr.Set((Time[0]-Time[1]).TotalMinutes);
volume.Set(Volume[0]);
double mfr2 = Volume[0]/(mfr[0]);
double vol = Volume[0];
Value.Set(mfr2);
volume.Set(vol);
PlotColors[0][0] = upColor;
PlotColors[1][0] = dnColor;
}}
}}
Comment
-
Offhand, it looks like you may have some "circular definitions" and/or "name clashes". You have two Plots that are named exactly the same as 2 private DataSeries. You may be seeing an assignment clash. Without seeing how the plots properties are defined, it is hard to definitely say that that is the caseOriginally posted by michael fantoni View PostHello koganam,
thank u for replying!!
There r not errors whatsoever in the log: no outside range, nothing! Its not plotting the volume, I only get the vol/time, in green, the upColor: I checked the values of the bars against it the other indicator I had in the Data Box
I post the script so u can see it:
{
[Description(" blabla")]
public class MassFlowRate2 : Indicator
{
#region Variables
private DataSeries volume;
private DataSeries mfr;
private Color upColor = Color.Green;
private Color dnColor = Color.Red;
#endregion
protected override void Initialize()
{
Add(new Plot(new Pen(Color.Red, 9), PlotStyle.Bar, "mfr"));
Add(new Plot(new Pen(Color.Blue, 9), PlotStyle.Line, "volume"));
mfr = new DataSeries(this);
volume = new DataSeries(this);
}
protected override void OnBarUpdate()
{
if (CurrentBar==0)
{
mfr.Set(0);
volume.Set(0);
Value.Set(0);
}
else
{
mfr.Set((Time[0]-Time[1]).TotalMinutes);
volume.Set(Volume[0]);
double mfr2 = Volume[0]/(mfr[0]);
double vol = Volume[0];
Value.Set(mfr2);
volume.Set(vol);
PlotColors[0][0] = upColor;
PlotColors[1][0] = dnColor;
}}
}}
Comment
-
-
Also, I did name the plots the same as the series cos originally I thought that was the problem: I only get one plot if I name the plots differently!
Comment
-
Yep, I saw that a bit later
But I dont understand. I looked at the default MACD bundled with NT and it plots all of them. If u had 2 dataseries named alpha and beta, how would u go about plotting? wouldnt u write what I did?
Also, it would be nice if I could choose not to get log off the forum while Im banging on the script
Comment
-
OHHHHHHHHHHHHHH!!! Finally! It works! I can plot them both and see how big one wrt the other! I attach it just in case u want to have a look at it. It doesnt say much but I needed to compare things on the same bar.
Thank u for all the support koganam!
Take careAttached Files
Comment
-
Well, as you can see, once you cleared up your Plot naming issues, everything was tickety-boo.Originally posted by michael fantoni View PostOHHHHHHHHHHHHHH!!! Finally! It works! I can plot them both and see how big one wrt the other! I attach it just in case u want to have a look at it. It doesnt say much but I needed to compare things on the same bar.
Thank u for all the support koganam!
Take care
Glad that I could help.
Comment
-
Hello there!
hope all gd!
I would have a quick question and I havent found the topic in the forum. How could I tell NT to take the factorial of a quantity when building an indicator, the usual n! found in maths?
Regards
Comment
-
There is no C# Math() function for factorial. Are you asking for a coded function to call, or are you asking for a third-party library that might contain a factorial function?Originally posted by michael fantoni View PostHello there!
hope all gd!
I would have a quick question and I havent found the topic in the forum. How could I tell NT to take the factorial of a quantity when building an indicator, the usual n! found in maths?
Regards
Comment
-
Hello koganam
I would like to take the factorial of lets say the WMA(Close,1)[0]. I know there is a limit to how big a number I can take the factorial of. But for prices around 1-10 units that should work. How could I go round it?
Thank u
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
581 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
338 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
103 views
0 likes
|
Last Post
by Mindset
02-09-2026, 11:44 AM
|
||
|
Started by Geovanny Suaza, 02-02-2026, 12:30 PM
|
0 responses
554 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
552 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment