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 Rapine Heihei, 04-23-2024, 07:51 PM
            2 responses
            30 views
            0 likes
            Last Post Max238
            by Max238
             
            Started by Shansen, 08-30-2019, 10:18 PM
            24 responses
            943 views
            0 likes
            Last Post spwizard  
            Started by Max238, Today, 01:28 AM
            0 responses
            9 views
            0 likes
            Last Post Max238
            by Max238
             
            Started by rocketman7, Today, 01:00 AM
            0 responses
            5 views
            0 likes
            Last Post rocketman7  
            Started by wzgy0920, 04-20-2024, 06:09 PM
            2 responses
            28 views
            0 likes
            Last Post wzgy0920  
            Working...
            X