NexusFi: Find Your Edge


Home Menu

 





Accessing another indicator from within an indicator?


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one Fat Tails with 2 posts (10 thanks)
    2. looks_two RambleDog with 2 posts (0 thanks)
    3. looks_3 TheWizard with 1 posts (0 thanks)
    4. looks_4 Quick Summary with 1 posts (0 thanks)
    1. trending_up 8,148 views
    2. thumb_up 10 thanks given
    3. group 5 followers
    1. forum 7 posts
    2. attach_file 1 attachments




 
Search this Thread

Accessing another indicator from within an indicator?

  #1 (permalink)
 RambleDog 
Nampa, ID
 
Experience: Intermediate
Platform: TradeStation and Ninja
Broker: AMP - Zenfire
Trading: ES
Posts: 39 since Jan 2011
Thanks Given: 22
Thanks Received: 30

I have an indicator that I use that plots a 20 period moving average from a 5min chart on a 1 min chart. I like it better than using a "proxy", but I would like to be able to access its value from with in another indicator that I wrote. Not sure what I need to do to be able to access an indicator from with in an indicator? Anyone have some sample code they could share? Not the regular indicators either like a built in Ninja EMA, I got that. Thanks for any advice.

Visit my NexusFi Trade Journal Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
ZombieSqueeze
Platforms and Indicators
Trade idea based off three indicators.
Traders Hideout
MC PL editor upgrade
MultiCharts
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
Better Renko Gaps
The Elite Circle
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Just another trading journal: PA, Wyckoff & Trends
27 thanks
Diary of a simple price action trader
26 thanks
Tao te Trade: way of the WLD
23 thanks
My NQ Trading Journal
14 thanks
HumbleTraders next chapter
9 thanks
  #3 (permalink)
 
Fat Tails's Avatar
 Fat Tails 
Berlin, Europe
Market Wizard
 
Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker: Interactive Brokers
Trading: Keyboard
Posts: 9,888 since Mar 2010
Thanks Given: 4,242
Thanks Received: 27,102



RambleDog View Post
I have an indicator that I use that plots a 20 period moving average from a 5min chart on a 1 min chart. I like it better than using a "proxy", but I would like to be able to access its value from with in another indicator that I wrote. Not sure what I need to do to be able to access an indicator from with in an indicator? Anyone have some sample code they could share? Not the regular indicators either like a built in Ninja EMA, I got that. Thanks for any advice.

If you want to access a first indicator from within a second indicator, this is possible, if the following conditions are met.:

(1) The first indicator must have the values that you want to access exposed in the properties. You cannot access values that are not exposed

(2) Some further restrictions apply for the first indicator. For example the access will not work if the first indicator loads daily bars asynchronously or if it calls ChartControl without checking for null.

(3) The second indicator now can access the first one.


Example

Let us have a look at a simple example. I will take the EMA.

The EMA has only one parameter, which is the period. So you would need to define a variable periodEMA to collect that value from the user.
Put PeriodEMA in the properties section accordingly.

Now that periodEMA exists and contains a value, you can access the indicator by calling it in OnBarUpdate():

 
Code
protected override void OnBarUpdate()
{
       double myDouble;            
       if(EMA(periodEMA).Value.ContainsValue(0)) // checks whether the DataSeries contains a value
            myDouble = EMA(periodEMA).Value.Get(CurrentBar);
       else
            myDouble = 0.0;
      .............................
}

Reply With Quote
  #4 (permalink)
 RambleDog 
Nampa, ID
 
Experience: Intermediate
Platform: TradeStation and Ninja
Broker: AMP - Zenfire
Trading: ES
Posts: 39 since Jan 2011
Thanks Given: 22
Thanks Received: 30

Just sitting down for the evening and it is too late to try to code my indicator this evening, but I can tell from your sample that it is pretty straight forward. I'll give it a try tomorrow morning. Thanks MUCH!

Visit my NexusFi Trade Journal Started this thread Reply With Quote
  #5 (permalink)
 
Jigsaw Trading's Avatar
 Jigsaw Trading  Jigsaw Trading is an official Site Sponsor
 
Posts: 2,988 since Nov 2010
Thanks Given: 831
Thanks Received: 10,393

You can do this without programming... Might not be what you want...

When you add an indicator to a chart you can enter an input series and that can be an indicator.

See attached pic...

Attached Thumbnails
Click image for larger version

Name:	7-1-2011 1-57-53 AM.png
Views:	388
Size:	96.2 KB
ID:	42443  
Visit my NexusFi Trade Journal Reply With Quote
  #6 (permalink)
 mmarco 
boston, MA
 
Experience: Intermediate
Platform: NinjaTrader, T4
Trading: 6E, ES
Posts: 51 since Nov 2011
Thanks Given: 33
Thanks Received: 184

Hey guys,

I purchased a system online and thankfully it was not a scam . That being said, I was interested in backtesting it using the strategy analyzer. The indicator that sets up the signals comes as a downloadable installer and I can't seem to be able to access it anywhere using the ninjascript editor. This may be the whole exposing attributes publicly issue pointed out previously.

It does however plot signals as it goes, so I was hoping to access the attributes of previous bars (ie. color), or the drawings (see the purple hashes in the attached img). Is this possible? This ninja forum says not, but I'd figure I should ask the good people here for some enlightenment.

Test colour Bar - [AUTOLINK]NinjaTrader[/AUTOLINK] Support Forum

Thanks!

Visit my NexusFi Trade Journal Reply With Quote
  #7 (permalink)
 
Fat Tails's Avatar
 Fat Tails 
Berlin, Europe
Market Wizard
 
Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker: Interactive Brokers
Trading: Keyboard
Posts: 9,888 since Mar 2010
Thanks Given: 4,242
Thanks Received: 27,102


mmarco View Post
Hey guys,

I purchased a system online and thankfully it was not a scam . That being said, I was interested in backtesting it using the strategy analyzer. The indicator that sets up the signals comes as a downloadable installer and I can't seem to be able to access it anywhere using the ninjascript editor. This may be the whole exposing attributes publicly issue pointed out previously.

It does however plot signals as it goes, so I was hoping to access the attributes of previous bars (ie. color), or the drawings (see the purple hashes in the attached img). Is this possible? This ninja forum says not, but I'd figure I should ask the good people here for some enlightenment.

Test colour Bar - [AUTOLINK]NinjaTrader[/AUTOLINK] Support Forum

Thanks!

You cannot edit a commercial indicator, but you can access the exposed values. To find out which are the exposed values, open the NinjaTrader editor, type the name of the indicator followed by a dot. For example for the SMA, you would type

 
Code
SMA.


You should then see the exposed DataSeries that you can access (and a lot of other junk as well). Or you ask the supplier of your commercial indicator, which of the values are exposed.

Reply With Quote
  #8 (permalink)
 
TheWizard's Avatar
 TheWizard 
Houston, TX
Market Wizard
 
Experience: Intermediate
Platform: NinjaTrader
Broker: Optimus Futures, AMP, CQG
Trading: 6E
Posts: 1,731 since Jun 2009
Thanks Given: 517
Thanks Received: 4,224


RambleDog View Post
I have an indicator that I use that plots a 20 period moving average from a 5min chart on a 1 min chart. I like it better than using a "proxy", but I would like to be able to access its value from with in another indicator that I wrote. Not sure what I need to do to be able to access an indicator from with in an indicator? Anyone have some sample code they could share? Not the regular indicators either like a built in Ninja EMA, I got that. Thanks for any advice.

Don't know if this helps, but it's a little ditty I wrote a long time ago, creating a new indicator in which d9ParticleOscillator is referenced twice (14 period and 34 perod). Simple. It compares the 14 period raw trend to the 34 period raw trend and draws an arrow.

{
#region Variables
private bool showarrows = true;
private double arrowoffset = 1;
private Color uparrow = Color.Lime;
private Color downarrow = Color.Red;
#endregion
protected override void Initialize()
{
CalculateOnBarClose = true;
}

protected override void OnBarUpdate()
{
// Condition set 1
if (CrossAbove(d9ParticleOscillator_V2(14, 0).RawTrend, d9ParticleOscillator_V2(34, 0).Prediction, 1))
{
if(showarrows) DrawArrowUp("Up arrow" + CurrentBar, false, 0, Low[0]-arrowoffset*TickSize, Uparrow);
}

// Condition set 2
if (CrossBelow(d9ParticleOscillator_V2(14, 0).RawTrend, d9ParticleOscillator_V2(34, 0).Prediction, 1))
{
if(showarrows) DrawArrowDown("Down arrow" + CurrentBar, false, 0, High[0]+arrowoffset*TickSize, Downarrow);
}
}



#region Properties
[Description("Show Arrow Signals?")]
[Category("Visual")]
public bool ShowArrows
{
get { return showarrows; }
set { showarrows = value; }
}
[Description("Arrow Signal Offset")]
[Category("Visual")]
public double Arrowoffset
{
get { return arrowoffset; }
set { arrowoffset = value; }
}
[Description("Up Arrow")]
[Category("Visual")]
[Gui.Design.DisplayNameAttribute("Up Arrow")]
public Color Uparrow
{
get { return uparrow; }
set { uparrow = value; }
}

/// <summary>
/// </summary>
[Browsable(false)]
public string uparrowSerialize
{
get { return NinjaTrader.Gui.Design.SerializableColor.ToString(uparrow); }
set { uparrow = NinjaTrader.Gui.Design.SerializableColor.FromString(value); }
}
/// <summary>
/// </summary>
[XmlIgnore()]
[Description("Down Arrow")]
[Category("Visual")]
[Gui.Design.DisplayNameAttribute("Down Arrow")]
public Color Downarrow
{
get { return downarrow; }
set { downarrow = value; }
}
/// <summary>
/// </summary>
[Browsable(false)]
public string downarrowSerialize
{
get { return NinjaTrader.Gui.Design.SerializableColor.ToString(downarrow); }
set { downarrow = NinjaTrader.Gui.Design.SerializableColor.FromString(value); }
}
#endregion
}

After all, it's what you learn AFTER you know it all, that counts!
Reply With Quote




Last Updated on July 25, 2012


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts