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 02-15-2008, 12:40 PM   #1
winJR
Member
 
Join Date: Jan 2008
Posts: 48
Thanks: 0
Thanked 0 times in 0 posts
Default Basic programming question

Hello, new to Ninjascript. I have a question. I am trying to paint the bars a color when 3 parts of the macd are above the zero line. (macd, avg, diff), or when two are above and one is below, etc. I use barcolor = Color.Red and I can get it to work if I only program for one of the variables. My challenge is getting the coding correct when I want all three variables (mulitple conditions in other words). I am doing something wrong. Using "and" to add multiple conditions doesnt seem to work.
For example:
if A > 0 and
B > 0 and
C < 0
BarColor = Color. Red ;
this doesnt seem towork. I am probably messing up with the basic coding. Help...lol.
winJR is offline  
Reply With Quote
Old 02-15-2008, 12:58 PM   #2
NinjaTrader_Ray
Administrator
 
NinjaTrader_Ray's Avatar
 
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
Default

You would need to do something like:

Code:
if (MACD(12, 26, 9).Macd[0] > 0 && MACD(12, 26, 9).Avg[0] > 0 && MACD(12, 26, 0).Diff[0] > 0)
    BarColor = Color.Red;
NinjaTrader_Ray is offline  
Reply With Quote
Old 02-15-2008, 01:37 PM   #3
winJR
Member
 
Join Date: Jan 2008
Posts: 48
Thanks: 0
Thanked 0 times in 0 posts
Default Thanks Ray, but still have a problem

Ray, you are awesome. I used the &&; however, I am still getting an error.
"Cannot apply indexing with [] to an expression of type 'method group'

here is my code:
if (MACD(12,26,9).MACD[0] > 0 && MACD(12,26,9).Diff[0] > 0 && MACD(12,26,9).Avg[0] > 0)
BarColor = Color.Red ;


winJR is offline  
Reply With Quote
Old 02-15-2008, 03:03 PM   #4
NinjaTrader_Ray
Administrator
 
NinjaTrader_Ray's Avatar
 
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
Default

I edited my original post. Changed the MACD[0] to Macd[0].
NinjaTrader_Ray is offline  
Reply With Quote
Old 02-15-2008, 04:12 PM   #5
winJR
Member
 
Join Date: Jan 2008
Posts: 48
Thanks: 0
Thanked 0 times in 0 posts
Default thanks, that did it...I should have caught that

Appreciate the help, you guys are great. I should have caught that as well. But we got it..thanks a million.
winJR 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
Programming connections Gumphrie Connecting 6 12-11-2009 03:09 AM
Programming references bobajob78 General Programming 1 02-11-2008 03:32 PM
Advanced Programming sbtrader General Programming 3 10-26-2007 10:11 AM
Basic multi-time frame question jonesr227 Strategy Development 8 08-26-2007 03:24 PM
Basic Question Jappenzeller Strategy Development 3 06-06-2007 09:29 AM


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