I have a very vague question. What is the benefit of setting a BoolSeries for a condition vs just creating a flag for that condition?
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
BoolSeries
Collapse
X
-
BoolSeries
Hello,
I have a very vague question. What is the benefit of setting a BoolSeries for a condition vs just creating a flag for that condition?Tags: None
-
Originally posted by CaptainAmericaXX View PostHello,
I have a very vague question. What is the benefit of setting a BoolSeries for a condition vs just creating a flag for that condition?
The answer is simple.
Is the condition logically associated with each bar?
Is the condition subject to change on a per bar basis?
Would it be useful for someone to be able to lookback, say, 5, 20, or 100 bars ago, and see what & how the condition has changed over time, on a per bar basis?
The point is, if the condition is really a "flag" like condition subject to change on a per bar basis, and you want to retain the history of the flag's value for each bar, well, then you'll need a flag for each bar, right?
Well, duh, there ya go, a BoolSeries, by definition, holds a flag for each bar.
If, on the other hand, the "flag" is timeless and independent of all bars, that is, it represents the state of the total indicator (not past state of each individual bar) then a single Boolean variable is more appropriate.
A DataSeries entire purpose in life is to maintain a small piece of information for each bar.
Whether it be a BoolSeries, IntSeries, DataSeries, etc, the point is, each and every bar has a value stuffed into the series just for that bar.
A BoolSeries is a like a gazillion True/False flags, where each bar only gets one flag.
If you don't need that fine of granularity for your condition, then your condition is probably more associated with the indicator as a whole (not each bar) and therefore a single flag variable makes more sense.Last edited by bltdavid; 11-30-2017, 02:17 AM.
-
Hello CaptainAmericaXX,
Thanks for your post.
Member bltdavid has hit all the key points (thank-you).
I would just add that as an example if you had several conditions that fed into another condition and that the several may have occurred some bars in advance of the last condition a boolseries would give you a bars ago means to lookback to see if the set of conditions were true x bars ago or within x barsago.
So as member bltdavid advises a single flag would be the current status whilst a bool series would provide current status and historical status on each bar,Paul H.NinjaTrader Customer Service
Comment
-
Originally posted by CaptainAmericaXX View PostHello,
I have a very vague question. What is the benefit of setting a BoolSeries for a condition vs just creating a flag for that condition?
If "yes", use a bool series: if "no", use a current value flag?
Comment
-
Thank you all for your answers! Each was insightful to me. Let me see if I have this straight.
If my condition is true from bars 10 - 20 and I set a bool to true during that period, once the condition is false the bool is set false and the program has no knowledge where that bool was ever true or the truth value of each bar, but I could use that bool for other purposes.
If, on the other hand, when the condition is true I set the BoolSeries true, then each of the bars during that period will be marked true. If I then wanted to find the truth value of a bar during that period I could then ask: if(myBool[period]){}? Is this correct? I can see how this will be much more helpful than the flags I've been using.
Comment
-
So after playing around with BoolSeries, IntSeries, etc I'm wondering if there is a way to easily access past values. With High, Low, Close, etc we can use barsago[]. This doesn't work the same with the 'Series' Class'. So far the best way I can see is to link a variable to the CurrentBar with the instance of the Series. Anyone have a trick?
Comment
-
Hello CaptainAmericaXX,
Thanks for your reply.
You should be able to use bars ago same as any other data series (High[], Low[], etc.)
Reference: https://ninjatrader.com/support/help...ries_class.htm Note: Check the last example shown.Paul H.NinjaTrader Customer Service
Comment
-
Hey Paul,
Sorry I wasn't more specific. Let me give an example. If I have myIntSeries and I only want to find the values that were Set myIntSeries then I have to tie the CurrentBar to the instance. If I use barsAgo without knowing how many bars back a value was set to myIntSeries then [0] = 5, [1] = 0, [2] = 0, [3] = 0,.........., [20] = 4, etc.
I was hoping that each time a value was Set that instance would be its own barsAgo index. So instead of [0] = 5........[20] =4 it would be [0]= 5, [1] = 4.
This would actually probably get pretty confusing. I'm just trying to wrap my mind around the concept.
Comment
-
Hello CaptainAmericaXX,
Thanks for your reply.
You are correct, that is confusing!
You can use the bars ago in the same way as any other data series. You can use methods like MAX() and MIN(), HighestBar() and LowestBar() to help you find data in the series.
Sounds like you have some testing to do.Paul H.NinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by SantoshXX, Today, 03:09 AM
|
0 responses
11 views
0 likes
|
Last Post
by SantoshXX
Today, 03:09 AM
|
||
Started by DanielTynera, Today, 01:14 AM
|
0 responses
2 views
0 likes
|
Last Post
by DanielTynera
Today, 01:14 AM
|
||
Started by yertle, 04-18-2024, 08:38 AM
|
9 responses
41 views
0 likes
|
Last Post
by yertle
Today, 01:00 AM
|
||
Started by techgetgame, Yesterday, 11:42 PM
|
0 responses
12 views
0 likes
|
Last Post
by techgetgame
Yesterday, 11:42 PM
|
||
Started by sephichapdson, Yesterday, 11:36 PM
|
0 responses
2 views
0 likes
|
Last Post Yesterday, 11:36 PM |
Comment