![]() |
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
|
|||||||
| General Programming General NinjaScript programming questions. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Member
Join Date: Jan 2008
Posts: 48
Thanks: 0
Thanked 0 times in 0 posts
|
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. |
|
|
|
|
|
#2 |
|
Administrator
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
|
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;
Ray
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Member
Join Date: Jan 2008
Posts: 48
Thanks: 0
Thanked 0 times in 0 posts
|
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 ; |
|
|
|
|
|
#4 |
|
Administrator
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
|
I edited my original post. Changed the MACD[0] to Macd[0].
Ray
NinjaTrader Customer Service |
|
|
|
|
|
#5 |
|
Member
Join Date: Jan 2008
Posts: 48
Thanks: 0
Thanked 0 times in 0 posts
|
Appreciate the help, you guys are great. I should have caught that as well. But we got it..thanks a million.
|
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
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 |