Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Check "BoolSeries mybool" for true/false
Collapse
X
-
If you do indeed have a series of bool values, then I think you need to declare in Variables:Hello. How to check "BoolSeries mybool" for true/false. When I wrote "if(mybool==true) do something", NT report bag, that I can't use "==" for BoolSeries.
myBoolSeries = new BoolSeries(this);
See Help:
http://www.ninjatrader.com/support/h...ries_class.htm
If, on the other hand, you have a simple boolean, declaring in Variables:
private bool mybool = true;
In OnBarUpdate(), this works with, e.g.
if (mybool == false
&&...)
Hope this helps.
-
NT said I can't use "==" for BoolSeries.Code:#region Variables .... private BoolSeries myBool; .... protected override void Initialize() {..... myBool = new BoolSeries(this); ..... protected override void OnBarUpdate() {.... myBool.Set(true); ...... if(myBool==true) do smth
Comment
-
A BoolSeries is a series. You cannot compare a series to a variable. You want to compare a value in the series to a variable. That means that you must specify the index for the comparison. e.g.,Originally posted by alexstox View PostNT said I can't use "==" for BoolSeries.Code:#region Variables .... private BoolSeries myBool; .... protected override void Initialize() {..... myBool = new BoolSeries(this); ..... protected override void OnBarUpdate() {.... myBool.Set(true); ...... if(myBool==true) do smth
Even more elegant:Code:if (myBool[0] == true) ...
Code:if (myBool[0]) ...
Last edited by koganam; 02-09-2014, 04:19 PM.
Comment
-
But there is only one BoolSeries in script - myBool. Even so I should use myBool[0]?Originally posted by koganam View PostA BoolSeries is a series. You cannot compare a series to a variable. You want to compare a value in the series to a variable. That means that you must specify the index for the comparison. e.g.,
Even more elegant:Code:if (myBool[0] == true) ...
Code:if (myBool[0]) ...
Comment
-
I am not sure what that has to do with it. My original response explained it. A series is exactly that: a series of values. You need to specify which of the values you want to reference. It has nothing to do with how many series are defined.Originally posted by alexstox View PostBut there is only one BoolSeries in script - myBool. Even so I should use myBool[0]?
Comment
-
Hello Alexstox,
Thank you for your post and to koganam and arbuthnot for their assistance.
The BoolSeries is a series of booleans, the index is referencing the latest value when you call [0]. Tying it the bar series with myBoolSeries = new BoolSeries(this); allows us to call the value of previous bars as well via the index. So [1] would be the previous value before the most recent, and [2] would be the value before that.
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
558 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
324 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
101 views
0 likes
|
Last Post
by Mindset
02-09-2026, 11:44 AM
|
||
|
Started by Geovanny Suaza, 02-02-2026, 12:30 PM
|
0 responses
545 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
547 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment