Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

find two bools in the last x number of bars?

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

    #31
    Hello tkaboris,

    In the old script were you assigning the bool variable a value before checking the bool variable in a condition?

    Have you modified the new script to assign the bool series a value within the logic block of the condition before it's checked in a nested condition?
    Chelsea B.NinjaTrader Customer Service

    Comment


      #32
      hi

      n the old script were you assigning the bool variable a value before checking the bool variable in a condition? - No.

      Have you modified the new script to assign the bool series a value within the logic block of the condition before it's checked in a nested condition? - No

      Comment


        #33
        Hello tkaboris,

        "n the old script were you assigning the bool variable a value before checking the bool variable in a condition? - No."

        If this is the case, then if the bool was ever true, it was set to true on a previous bar and remained true. (As it is a single value and not a separate value for each bar on the chart)

        "Have you modified the new script to assign the bool series a value within the logic block of the condition before it's checked in a nested condition? - No"

        If you choose not to, the series bool value will always be false for each new bar.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #34
          So how can I modify this bool in my case so its true? my script is below.


          if (isHighSequence && trendDirection == 1 && High[0] > Close[0])
          {
          double slope = (High[lookbackPeriod - 1] - High[0]) / lookbackPeriod;
          trendlineValueDn = (slope * 0) + High[0];
          string newLineTagB = "BullFlag" + bullFlagCounter;
          if (bullFlag[0] && bullFlagCounter > 0)
          {
          RemoveDrawObject("BullFlag" + (bullFlagCounter - 1));
          }
          Draw.Line(this, newLineTagB, true, lookbackPeriod - 1, High[lookbackPeriod - 1], 0, High[0], BullFlagColor, DashStyleHelper.Solid, 2);
          bullFlag[0] = true;
          bullFlagCounter++;
          }​

          Comment


            #35
            Hello tkaboris,

            Assign the bool series a value directly above the condition that checks the value.

            From post # 27:

            The assignment should be above the conditions that compare the value.

            bullFlag[0] = true;

            Should be above 'if (bullFlag[0] && bullFlagCounter > 0)' in the code.
            The bools series would always be true for the updating bar if this code is reached.

            (It doesn't appear that this bool or bool series is even needed. The bool series is assigned a value in the same logic block as the nested condition.)


            If you are looking for a previous bar's value in the condition, use the barsAgo index of the bar you want the value from. Ensure the barsAgo index is equal to or less than CurrentBar.
            Chelsea B.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by NullPointStrategies, Today, 05:17 AM
            0 responses
            43 views
            0 likes
            Last Post NullPointStrategies  
            Started by argusthome, 03-08-2026, 10:06 AM
            0 responses
            124 views
            0 likes
            Last Post argusthome  
            Started by NabilKhattabi, 03-06-2026, 11:18 AM
            0 responses
            65 views
            0 likes
            Last Post NabilKhattabi  
            Started by Deep42, 03-06-2026, 12:28 AM
            0 responses
            42 views
            0 likes
            Last Post Deep42
            by Deep42
             
            Started by TheRealMorford, 03-05-2026, 06:15 PM
            0 responses
            46 views
            0 likes
            Last Post TheRealMorford  
            Working...
            X