NinjaTrader Support Forum  

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 11-07-2008, 09:03 AM   #1
clint2008
Member
 
Join Date: Sep 2008
Posts: 62
Thanks: 0
Thanked 0 times in 0 posts
Default Question about UserDefinedMethods

I'm using UserDefinedMethods.cs to store some basic coding to be able to reuse it in different strategies. It seems that the prices and positions are available to methods without passing them as variables. The question is are variables instantiated within your strategy? So will I be able to maintain a value within a method or should I keep the value locally stored within the strategy? (Maybe this is a General Programming question?)
clint2008 is offline  
Reply With Quote
Old 11-07-2008, 10:37 AM   #2
NinjaTrader_Ben
NinjaTrader Customer Service
 
NinjaTrader_Ben's Avatar
 
Join Date: May 2008
Location: Denver, CO
Posts: 3,157
Thanks: 0
Thanked 3 times in 3 posts
Default

Hello,

The availability of a variable is defined by what scope you give it. If you only allow it to be used within the method, you will only have access to it in that method. If you declare the variable in the Variables section you will have access to it throughout the entire strategy.
NinjaTrader_Ben 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
userdefinedmethods 8DTK8 Strategy Development 4 02-22-2009 07:49 AM
Export Strategy with UserDefinedMethods Error mjuviler Strategy Development 1 06-04-2008 12:34 PM
Sharing UserDefinedMethods between indicators and strategies FireFly General Programming 1 05-16-2008 10:20 AM
Compile error with UserDefinedMethods NinjaTrader_Josh Indicator Development 6 06-06-2007 08:34 AM


All times are GMT -6. The time now is 07:13 PM.