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
Using a bool to keep track of state of a trend
Collapse
X
-
Using a bool to keep track of state of a trend
I'm getting confused on something I should understand but my mind is a bit frazzled right now. I created a strategy and Im monitoring 4 dataseries that represent 4 symbols. I have a if statement , that determines if all four are trending up , Ive tried a series bool and static bool . and all four trend down. The entry logic is this: if once set that all four are trending down the bool is set TrendDown == true then its waiting for when all four go TrendUp and TrendDown that was set has to be true then enters a long.and upon entry I reset the bools to false But this is flawed. If I use a series bool and set trenddown to true once the 4 symbols are trend down, it does not remain in that state if any of the symbols change state. So using a series statement like trendUp[0] == true && trenddown[1] == true but since trenddown has changed its not valid unless all 4 symbols are in perfect sync, which is not my intention. So figuring out how to set the value once the condition is met and leave it that way. That's my issue.Tags: None
-
So my solution so far seems to use a combination of signals. I added a Series bool TrendDownstatus with Or statement so that if any of the 4 symbols are trend down on the prev bar and now TrendUp == true it enters the trade. I have a non-series bool that gets set AuSmoothTrend Down == true and AuSmoothTrend Up = false when all 4 have a trend down signal.. The TrendDownStatus is a Series bool that monitors all 4 with an OR statement so that any one trend down it will be true.
(!UseAuSmoothFilter || ( AuSmoothTrendUp == true && TrendDownStatus[idx+1] == true && AuSmoothTrendDown == true )) This part is the entry condition: TrendUp is true that means all 4 just turned true for AuSmoothTrendUp and the previous bar at least one had a TrendDown and the AuSmoothTrendDown is also true as it got set previously when all 4 were Trend down. Dont know if this is perfect idea but I tested in playback and it seemed to do the job.
-
Hello set2win,
A static property would be used for multiple class instances to access the same value. I don't think this is what you want, and I do not suggest you use a static property.
Use Print() to understand the behavior. Print the value of the variable and the time of the bar.
What specifically is not evaluating as true in your condition?
Please provide the output from prints saved to a text file.Chelsea B.NinjaTrader Customer Service
Comment
-
I may be using the wrong term in regards to static. I think series and non series is more appropriate. using a variable that gets set when a certain condition is met and retaining that value even though the conditions change. I think it is working to my satisfaction.
As in this image, i need the 4 trends to be red that sets TrendDown variable to true, then once the 4 trends go green TrendUp is set true, but I want to check that in prev bar that at least one trend was down then Enter Long. So I have a series bool that checks for TrendDownStatus[1] which is an OR statement. on the entry signal reset all the bool to false.
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by SantoshXX, Today, 03:09 AM
|
0 responses
12 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
42 views
0 likes
|
Last Post
by yertle
Today, 01:00 AM
|
||
Started by techgetgame, Yesterday, 11:42 PM
|
0 responses
14 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