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 Mindset, 04-21-2026, 06:46 AM
            0 responses
            88 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by M4ndoo, 04-20-2026, 05:21 PM
            0 responses
            135 views
            0 likes
            Last Post M4ndoo
            by M4ndoo
             
            Started by M4ndoo, 04-19-2026, 05:54 PM
            0 responses
            68 views
            0 likes
            Last Post M4ndoo
            by M4ndoo
             
            Started by cmoran13, 04-16-2026, 01:02 PM
            0 responses
            119 views
            0 likes
            Last Post cmoran13  
            Started by PaulMohn, 04-10-2026, 11:11 AM
            0 responses
            69 views
            0 likes
            Last Post PaulMohn  
            Working...
            X