When you refer to TICK, are you referring to the fact that you have a indicator or strategy that adds a tick-based data series?
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Indicator calling another Indicator
Collapse
X
-
How are you using the ADD method? ADD typically is used in strategies to add a indicator to a chart, rather than have it used for other calculations. You can reference the indicator just by calling it like a function and referring to the correct dataseries.Originally posted by Benske View Post
When you refer to TICK, are you referring to the fact that you have a indicator or strategy that adds a tick-based data series?Last edited by NinjaTrader_AdamP; 03-05-2012, 02:11 PM.
-
I'm a bit confused about referencing exposed variables...
I"m not understanding something about your "sampleboolseries."
Here's what I want to do, using your example, if I put the SampleBoolSeries on 2 charts, one is on ADD index the other on TICK index. Now I want to access the current value of your bool Series in another code that says:
If the sampleboolseries.bullindication of TICK and sampleboolseries.bullindication of ADD are both true then if the MACD of this chart say of IBM is also bullish then give me an up arrow on the on the current chart, in this case IBM.
The part that I can't seem to get is how do I reference your SampleBoolSeries and differrentiate it for TICK and ADD.
I can certainly Add the TICK dataseries and ADD date series and then use that to calculate MACD within my code for each dataseries but I already have that calculating on the 2 charts and I want to reference the values there so that I don't have to have it recalculated within this new code, or in this case the bull and bear indication already being calculated on the TICK and ADD
I guess simply put what is the syntax for accessing and differenctiating the SampleBoolSeries being used for TICK then again for ADD indices?
That is:
What do I have to add to:
"SampleBoolSeries().Bullindication" to point to one that's being calculated for TICK and then the one for ADD?
.
Leave a comment:
-
This is now being tracked under # 957 in our system, thanks again for the input to further enhance NinjaTrader.
Leave a comment:
-
You're welcome thebean and thanks for the input, I'll ask product management to have this added to our feedback lists.
Leave a comment:
-
Thanks NinjaTrader_Bertrand, I will consider this. Could this be included as an enhancement request to programmatically select the session type?
Leave a comment:
-
Great you got it resolved, a programmatic change of the template used in unfortunately not possible. But perhaps you add a check for the template and if those do not fit, you issue a log error?
Leave a comment:
-
I figured out what the problem was. The TRIN indicator was downloading data but using the default Session setting for each of the data series that I added. The problem was that a couple of the instruments were using 'US Equities RTH' instead of 'Default 24/X' as their sessions. Changing the default values for those instruments worked!
Just for future reference, if I wanted to override the session programmatically, could I? Thanks for the suggestions!
Leave a comment:
-
thebean, in the series you are calling, you need to add Update() - please see here for the help guide reference for Update() - http://www.ninjatrader.com/support/h...nt7/update.htm.
Leave a comment:
-
Hi NinjaTrader_Austin, thanks for the suggestion. I saw that tip before and tried to incorporate it somehow into the indicator with little success.
Right now I am adding a data series for each of the data points that are needed to calculate the TRIN value. For example:
Add(advanceIndex, periodtype, periodInterval);
Then in OnBarUpdate() I have the following 2 lines:
Value.Set(trinValue);
TRINLine.Set(trinValue);
The indicator appears to be drawing itself properly. What I am noticing now is that the SMA indicator doesn't draw properly unless I also include the underlying data series as part of the chart as well. Is there a way to fix that?
Leave a comment:
-
thebean, how are you constructing this TRIN indicator? I would recommend making a named plot for the TRIN indicator instead of just using Value, and then you should be able to read it from another indicator no problem. This link can help get you started - http://www.ninjatrader-support2.com/...ead.php?t=4991.
Leave a comment:
-
I developed a TRIN indicator and am trying to call it from the SMA indicator. The SMA line appears to be plotting based on the underlying TRIN's data series value instead of the TRIN value.
I have calls to Value.Set in the TRIN indicator, but that doesn't seem to make a difference. Is there something that I should be doing to get the SMA indicator to use the TRIN value instead?
Leave a comment:
-
Dear Mr. Austin and Koganam,
Thanks for your feedbacks.
if (CurrentBar < lookBack) return;
have solved the problem.
And I didn't know that errors on indicators will also be mentioned under the logs tab.
I was assuming only strategy errors will be mentioned here.
Thank you for your kind support.
Leave a comment:
-
Unless you escape the lookBack bars initially, that should fail with an indexing error. Look in your logs to see if there is such an error. If there is, there is more than one way to fix it. An inelegant but very effective method is to simply not process those bars where the indexed value does not yet exist.
You can do that by adding, at the start of the OnBarUpdate() method, the following line:
Code:if (CurrentBar < lookBack) return;
Leave a comment:
-
hana_maui, are you receiving any errors in the logs (right-most tab of Control Center)?
If you want to use a value of an indicator, you can just call it directly:
Code:// to get the 10 period ATR from 3 bars ago double atr_value = ATR(10)[3]; // 20 period sma from 10 bars ago double sma_value = SMA(20)[10];
Leave a comment:
-
Dear Customer Support,
I have a similar question regarding referencing indicator value from another indicator.
When I try to call indicator value for say SMA(10)[10] from another indicator on OnBarUpdate, it seems that the indicator value is not being referenced.
It seems that I can only call indicator value for current bar Value[0], but not the past bar say Value[10].
I'm just trying to plot the following line but it is not working.
Plot0.Set(Math.Log(SMA(10)[0] / SMA(10)[30]));
When I make a DataSeries within the new indicator and copy the SMA value to this DataSeries, and then reference the past bar value, it works (like you find in the code of MACD). But it is alittlebit annoying copying incidator value to a DataSeries.
Is there any simple way that I can use, when I want to create an indicator which use past bar value of another indicator? (Like Add method you can use in a strategy?)
Look forward to hearing from you.
<Sample Code is as follows>
public class SampleIndicator : Indicator
{
#region Variables
// Wizard generated variables
private int lookBack = 1; // Default setting for LookBack
// User defined variables (add any user defined variables below)
#endregion
/// <summary>
/// This method is used to configure the indicator and is called once before any bar data is loaded.
/// </summary>
protected override void Initialize()
{
Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line, "Plot0"));
Overlay = false;
}
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
// Use this method for calculating your indicator values. Assign a value to each
// plot below by replacing 'Close[0]' with your own formula.
//Plot0.Set(Math.Log(SMA(10)[0] / SMA(10)[lookBack]));
Plot0.Set(SMA(10).Value[lookBack]);
}
Leave a comment:
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by cmoran13, 04-16-2026, 01:02 PM
|
0 responses
46 views
0 likes
|
Last Post
by cmoran13
04-16-2026, 01:02 PM
|
||
|
Started by PaulMohn, 04-10-2026, 11:11 AM
|
0 responses
28 views
0 likes
|
Last Post
by PaulMohn
04-10-2026, 11:11 AM
|
||
|
Started by CarlTrading, 03-31-2026, 09:41 PM
|
1 response
163 views
1 like
|
Last Post
|
||
|
Started by CarlTrading, 04-01-2026, 02:41 AM
|
0 responses
98 views
1 like
|
Last Post
by CarlTrading
04-01-2026, 02:41 AM
|
||
|
Started by CaptainJack, 03-31-2026, 11:44 PM
|
0 responses
158 views
2 likes
|
Last Post
by CaptainJack
03-31-2026, 11:44 PM
|

Leave a comment: