Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Array to make life Easier!!?

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

    Array to make life Easier!!?

    Is there a way to make an Array[] that holds these values:

    Code:
    // Condition set 2, 
                if (beginLongs == buyStep
                    && Variable1 >= Variable3
                    && Close[4] >= Variable3 //The close of 4 bars ago must be above the Lowest EMA
                    && Close[3] >= Variable3 //The close of 3 bars ago must be above the Lowest EMA
                    && Close[2] >= Variable3 //The close of 2 bars ago must be above the Lowest EMA
                    && Close[1] >= Variable3 //The close of 1 bars ago must be above the Lowest EMA
                    && CrossAbove(High, Variable2, 1))
    I'm trying to Compare the Close from what ever barsAgo and I want it to continue counting till it reaches Close[1]. In the sample code I only used 4 bars ago, but Is there a way to make some kind of For statement that can place a variable in an Array. In other words, I don't want to type Close[10] && Close[9] etc...I want to just place it on one array or something so it's done easier.

    Sample Codes Please.

    Thank You!!

    #2
    Hi ginx10k,

    Try using MIN(Close, 4)[0] >= Variable3.

    http://www.ninjatrader.com/support/h...inimum_min.htm

    You could also loop over the Close..

    for (var i=0; i<4; i++)
    if (Close[i] < Variable3)
    // set variable or execute code

    You could also make your own list (a type of array).
    http://www.dotnetperls.com/list
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Thank YOU

      Thanks Chelsea, much appreciated!!

      Comment


        #4
        Quick modification question.

        So I did the code
        Code:
        if(MIN(Close, 10)[1] >= MIN(EMA3, 10)[1]) //The MIN displays the Close of the Last 5 bars starting with [1] bar ago.
        				{ upTrend = true;		downTrend = false;	}
        I'm trying to get the just below the Close by like 1 tick. so I tried
        Code:
        if(MIN(Close  + 1 * TickSize, 10)[1] >= MIN(EMA3, 10)[1])
        but keep getting Error.

        Can someone tell me where do i Place the +1*TickSize statement to make this read 1 tick above or Below the Close.

        Thank You!!

        Comment


          #5
          Hi ginx10k,

          You will not be able to add a tick to an entire data series...

          Instead, check that the value on the right of the equation is a tick lower.

          if(MIN(Close, 10)[0] >= MIN(EMA3, 10)[0]-1*TickSize)

          Also, MIN(Close, 10)[1] will not include the current bar in the check for the lowest bar. Are you using this intentionally to not include the current bar with the check for the lowest bar in the close?
          Chelsea B.NinjaTrader Customer Service

          Comment


            #6
            Great. thanks So Much!!

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            579 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            334 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            101 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            554 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            551 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X