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

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 mattbsea, Today, 05:44 PM
            0 responses
            4 views
            0 likes
            Last Post mattbsea  
            Started by RideMe, 04-07-2024, 04:54 PM
            6 responses
            31 views
            0 likes
            Last Post RideMe
            by RideMe
             
            Started by tkaboris, Today, 05:13 PM
            0 responses
            2 views
            0 likes
            Last Post tkaboris  
            Started by GussJ, 03-04-2020, 03:11 PM
            16 responses
            3,282 views
            0 likes
            Last Post Leafcutter  
            Started by WHICKED, Today, 12:45 PM
            2 responses
            20 views
            0 likes
            Last Post WHICKED
            by WHICKED
             
            Working...
            X