Announcement
Collapse
Looking for a User App or Add-On built by the NinjaTrader community?
Visit NinjaTrader EcoSystem and our free User App Share!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less
Partner 728x90
Collapse
NinjaTrader
Check "BoolSeries mybool" for true/false
Collapse
X
-
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.
-
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
-
Originally posted by alexstox View PostCode:#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
Code:if (myBool[0] == true) ...
Code:if (myBool[0]) ...
Last edited by koganam; 02-09-2014, 04:19 PM.
Comment
-
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.,
Code:if (myBool[0] == true) ...
Code:if (myBool[0]) ...
Comment
-
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 bortz, 11-06-2023, 08:04 AM
|
47 responses
1,603 views
0 likes
|
Last Post
by aligator
Today, 07:22 PM
|
||
Started by jaybedreamin, Today, 05:56 PM
|
0 responses
8 views
0 likes
|
Last Post
by jaybedreamin
Today, 05:56 PM
|
||
Started by DJ888, 04-16-2024, 06:09 PM
|
6 responses
18 views
0 likes
|
Last Post
by DJ888
Today, 05:12 PM
|
||
Started by Jon17, Today, 04:33 PM
|
0 responses
4 views
0 likes
|
Last Post
by Jon17
Today, 04:33 PM
|
||
Started by Javierw.ok, Today, 04:12 PM
|
0 responses
12 views
0 likes
|
Last Post
by Javierw.ok
Today, 04:12 PM
|
Comment