![]() |
|
|||||||
| Indicator Development Support for the development of custom indicators using NinjaScript. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Junior Member
Join Date: Feb 2008
Posts: 8
Thanks: 0
Thanked 0 times in 0 posts
|
I have indicatorA with several properties that are user configurable via its indicator panel. I have another indicatorB that wants to use some of the same settings and I don't want the user to have to set the properties in both places.
From indicatorB, when I code IndicatorA().PropertyName from within onbarupdate(), I get the original default value as set in indicatorA variable section and not the value the user set via indicatorA's dialog. I use configurable properties all the time and the work great when only reference by the indicator that set them. Is there a way to get the value the user has set in the dialog from another indicator? Code:
///****IndicatorA
private int propertyTest = 2;
// Initialize has nothing related
// OnBarUpdate has nothing related
#region Properties
[Category("Whatever")]
[Description("Sets the whatever")]
[NinjaTrader.Gui.Design.DisplayName("Whatever Property)")]
public int PropertyTest
{
get { return propertyTest ; }
set { propertyTest = value; }
}
#endregion
Code:
//**** IndicatorB
...OnBarUpdate()
{
Print("Test: " + IndicatorA().PropertTest) <----- always prints "2"
}
Code:
Test: 2 Test: 10 |
|
|
|
|
|
#2 |
|
NinjaTrader Customer Service
Join Date: Sep 2008
Location: Germany
Posts: 22,377
Thanks: 252
Thanked 966 times in 949 posts
|
Hi ActiveHawk,
Thanks for your post. Please review those two links here - 1. http://www.ninjatrader-support2.com/...ead.php?t=4991 2. http://www.ninjatrader-support.com/H...V6/Update.html It is important that you use the Update() method to force an update of the embedded indicator values.
Bertrand
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Junior Member
Join Date: Feb 2008
Posts: 8
Thanks: 0
Thanked 0 times in 0 posts
|
Thanks for the reply. I'm familier with the use of Update() but this doesn't seem to be a problem with calling Update(). It fails with or without the call to Update() in the property getter. It has to do with variables that are changed by the user not being available to other indicators.
I've included two simple test indicators. TestIndB calls TestIndA to get the value of A's user configurable property (ExposedVariable) but can only ever get the default and not the value set by the user. The ExposedVariable can be changed all you want in the dialog of TestIndA and the output window will always show "Exposed Variable: 2". See simple test code below... TestIndA.cs Code:
public class TestIndA : Indicator
{
private int exposedVariable = 2;
protected override void Initialize()
{
Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line, "Plot0"));
CalculateOnBarClose = true;
Overlay = true;
PriceTypeSupported = false;
}
protected override void OnBarUpdate()
{
Plot0.Set(Close[0] + (10*TickSize));
}
[Browsable(false)]
[XmlIgnore()]
public DataSeries Plot0
{
get { return Values[0]; }
}
// [Browsable(false)] // user configurable property
// [XmlIgnore()] // user configurable property
public int ExposedVariable
{
get { Update(); return exposedVariable; } // Update() doesn't matter here.
set { exposedVariable = value; }
}
}
Code:
public class TestIndB : Indicator
{
protected override void Initialize()
{
Add(new Plot(Color.FromKnownColor(KnownColor.Red), PlotStyle.Line, "Plot0"));
CalculateOnBarClose = true;
Overlay = true;
PriceTypeSupported = false;
}
protected override void OnBarUpdate()
{
Print("Exposed variable from TestIndB: " + TestIndA().ExposedVariable);
}
[Browsable(false)]
[XmlIgnore()]
public DataSeries Plot0
{
get { return Values[0]; }
}
}
|
|
|
|
|
|
#4 |
|
NinjaTrader Customer Service
Join Date: Sep 2008
Location: Germany
Posts: 22,377
Thanks: 252
Thanked 966 times in 949 posts
|
Hi ActiveHawk,
Thanks for posting the test indicators. You cannot make a user defined input variable directly available to other indicators. For that matter please create another variable that tracks the user defined input one and expose that to access it from the other study.
Bertrand
NinjaTrader Customer Service |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Add indicator line with configurable level | RandyT | General Programming | 5 | 10-14-2008 09:16 PM |
| Access to values of some indicators | lgarcia3 | Miscellaneous Support | 6 | 04-15-2008 09:45 AM |
| Beta bug? Strategy Analyzer backtest properties window showing wrong properties | OregonSun | Historical NinjaTrader 6.5 Beta Threads | 2 | 01-27-2008 05:42 PM |
| Bugs with DrawTextFixed and saving templates with configurable fonts | Wizard | Historical NinjaTrader 6.5 Beta Threads | 4 | 12-12-2007 07:57 AM |
| Programmatic Access to all Power Volume Indicators | Forex Ninja | Suggestions And Feedback | 1 | 05-21-2007 08:24 AM |