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!
See more
See less

Partner 728x90

Collapse

Using a bool to keep track of state of a trend

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    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.

    #2
    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.

    Comment


      #3
      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


        #4
        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. Click image for larger version

Name:	4_Index.png
Views:	157
Size:	139.0 KB
ID:	1212155
        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 elirion, Today, 01:36 AM
        0 responses
        2 views
        0 likes
        Last Post elirion
        by elirion
         
        Started by gentlebenthebear, Today, 01:30 AM
        0 responses
        2 views
        0 likes
        Last Post gentlebenthebear  
        Started by samish18, Yesterday, 08:31 AM
        2 responses
        9 views
        0 likes
        Last Post elirion
        by elirion
         
        Started by Mestor, 03-10-2023, 01:50 AM
        16 responses
        389 views
        0 likes
        Last Post z.franck  
        Started by rtwave, 04-12-2024, 09:30 AM
        4 responses
        31 views
        0 likes
        Last Post rtwave
        by rtwave
         
        Working...
        X