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 > General Programming

General Programming General NinjaScript programming questions.

Reply
 
Thread Tools Display Modes
Old 04-10-2009, 01:17 PM   #1
maxsys
Junior Member
 
Join Date: Dec 2008
Posts: 15
Thanks: 0
Thanked 0 times in 0 posts
Default Assigning a variable

I am stuck on what looks to be a straight forward variable assignment. Here is the code:
#region Variables
private double wmR = -50.0; // WilliamsM
private int WMRvar = 14; // WilliamsM var
#endregion

/// <summary>
protected override void Initialize()
{
CalculateOnBarClose = true;
}

/// <summary>
protected override void OnBarUpdate()
{
PrintWithTimeStamp("wmR: " + wmR);

The output window shows:
4/9/2009 1:00:00 PM wmR: 1

I have been recompiling and reloading Ninjascript in the chart to test.

WTF
maxsys is offline  
Reply With Quote
Old 04-10-2009, 01:27 PM   #2
mrlogik
Certified NinjaScript Consultant
 
mrlogik's Avatar
 
Join Date: Sep 2006
Location: New York, USA
Posts: 774
Thanks: 1
Thanked 7 times in 5 posts
Default

Two thoughts.

1. Is this an input? If so, are you using something like Math.Max(value,1) on the input assignment?
2. Its good practice to do wmR.ToString() when printing a variable string.

hope this helps.
"You look closely enough, you can find everything has a ... weak spot where it can break, sooner or later"

PureLogikTrading
mrlogik is offline  
Reply With Quote
Old 04-10-2009, 01:48 PM   #3
maxsys
Junior Member
 
Join Date: Dec 2008
Posts: 15
Thanks: 0
Thanked 0 times in 0 posts
Default

Thanks mrlogik,

I tried wmR.ToString(), with no change. This is an input so I tried changing the max value to -100, and that worked.

set { wmR = Math.Max(-100, value); }

Thanks again.
maxsys 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
Variable input? ju1234 Strategy Development 3 11-24-2008 09:15 AM
Passing variable caldolegare General Programming 6 11-17-2008 09:23 AM
Assigning indicator values ericadam Strategy Development 1 09-06-2008 11:19 PM
Global Variable... maxpi Strategy Development 6 11-26-2007 09:47 PM
Assigning port numbers for three or more IB TWS instances JangoFolly Connecting 6 11-29-2006 01:33 AM


All times are GMT -6. The time now is 03:15 AM.