NinjaTrader Support Forum  
X

Attention!

This website will be down for maintenance from Friday May 24th at 6PM MDT until Saturday May 25th at 11AM MDT. We apologize for the inconvenience. If you need assistance during this time, please email sales@ninjatrader.com


Go Back   NinjaTrader Support Forum > NinjaScript Development Support > Strategy Development

Strategy Development Support for the development of custom automated trading strategies using NinjaScript.

Reply
 
Thread Tools Display Modes
Old 01-30-2011, 05:29 AM   #1
marynja
Member
 
Join Date: Jan 2011
Posts: 54
Thanks: 14
Thanked 0 times in 0 posts
Default Access an indicator var from a strategy?

Its possible acces to a indicator public var from an strategy?

I am trying but the value is always the first declared.

Indicator example code:
Code:
//Indicator var declaration
public int myvar=0;
....

//Indicator update
protected override void OnBarUpdate(){
myvar=x;
...
Strategy example code:
Code:
/Strategy update
protected override void OnBarUpdate(){

//Print indicator var
print(MyIndicator().myvar);
...
And the printed value always is the first declaration value; 0.
How can i take the updated value?

Thank you very much for help.
Mary
marynja is offline  
Reply With Quote
Old 01-30-2011, 05:51 AM   #2
koganam
Senior Member
 
Join Date: Feb 2008
Location: Durham, North Carolina, USA
Posts: 3,219
Thanks: 24
Thanked 1,231 times in 1,002 posts
Send a message via Skype™ to koganam
Default

You need to include an Update() in the get function for the property.

get{myvar = Update(); return value;}

ref: http://www.ninjatrader.com/support/h...tml?update.htm
Last edited by koganam; 01-30-2011 at 06:08 AM.
koganam is offline  
Reply With Quote
Old 01-30-2011, 09:40 AM   #3
marynja
Member
 
Join Date: Jan 2011
Posts: 54
Thanks: 14
Thanked 0 times in 0 posts
Default

Fantastic koganam, thank you very much !!
marynja is offline  
Reply With Quote
Old 01-30-2011, 01:19 PM   #4
NinjaTrader_Austin
NinjaTrader Customer Service
 
NinjaTrader_Austin's Avatar
 
Join Date: Jun 2009
Location: Denver, CO
Posts: 3,149
Thanks: 10
Thanked 89 times in 81 posts
Default

marynja, there is also a reference sample that details how to get an indicator value in a strategy, which is pretty much what you've already done with koganam's help.
NinjaTrader_Austin is offline  
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Public var not updating... Sleeping Troll Indicator Development 2 09-23-2010 11:15 AM
access Strategy object from indicator pbcah Indicator Development 4 06-07-2010 12:28 AM
Can a strategy access the SMA indicator Turtle Trader Strategy Development 3 04-07-2010 04:27 AM
var type b1g3ar5 General Programming 2 11-05-2009 05:27 AM
Can I access Public Indicator Variables from Strategy rrv1980 Strategy Development 13 08-24-2008 05:31 PM


All times are GMT -6. The time now is 05:51 AM.