![]() |
|
|||||||
| General Programming General NinjaScript programming questions. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Junior Member
Join Date: Nov 2007
Posts: 15
Thanks: 0
Thanked 0 times in 0 posts
|
Is it possible to define a variable with an expression containing Ninja Trader Indicators such as
SMA(10)[0] < SMA(20)[0] where the expression can now be used as any other variable?? In other words, can I use the above expression as a bool type variable and if so how would the syntax read? Thanks for any input. JT454 |
|
|
|
|
|
#2 |
|
Junior Member
Join Date: Feb 2010
Posts: 3
Thanks: 0
Thanked 0 times in 0 posts
|
You could store it like this and just pass around the variable isLess:
Code:
bool isLess = SMA(10)[0] < SMA(20)[0]; Code:
bool IsLess()
{
|
|
|
|
|
|
#3 |
|
Member
Join Date: Jan 2009
Posts: 94
Thanks: 0
Thanked 14 times in 12 posts
|
Because of precedence of operators, I would add parentheses to avoid ambigious statements. Like this:
bool isLess = (SMA(10)[0] < SMA(20)[0]); But bool has only two values, true and false, hardly a real variable; so for readibility concerns, the conditional statement would commonly be part of an if statement. Like this: if ( SMA(10) < SMA(20)) { // set bool variable to true or false, or do something else } |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| indicator as variable | e-man | Version 7 Beta General Questions & Bug Reports | 3 | 10-20-2009 03:38 PM |
| Variable input? | ju1234 | Strategy Development | 3 | 11-24-2008 09:15 AM |
| Variable Declaration? | GreenTrade | Strategy Development | 7 | 07-03-2008 01:34 PM |
| Global Variable... | maxpi | Strategy Development | 6 | 11-26-2007 09:47 PM |
| Variable rounded | Richard Von | Indicator Development | 3 | 08-03-2007 06:55 AM |