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

CrossAbove BarsArray[1] and Close[1]

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

    CrossAbove BarsArray[1] and Close[1]

    Hi,

    Questions on CrossAbove() using the secondary time period.

    [1] CrossAbove(BarsArray[1],EMA(BarsArray[1],14),5);

    Does this test the following: Did any part of a secondary-period candle touch below but close above the secondary-period's EMA over the last 5 candles. That is if candle one closed above but had a low below and candle two had a close above then is that deemed to be a cross above when using the BarsArray as an input? I'm getting results I don't understand using BarsArray instead of Close. I presume with Close as the input if candle one closes below and candle two closes above then this is a cross above when using Close.

    [2] CrossAbove(BarsArray[1],EMA(BarsArray[1],10)[0],5);

    Is the '[0]' incorrect because this has CrossAbove taking a single element rather than array in its second variable?

    [3] CrossAbove(Close[1],EMA(BarsArray[1],10),5);

    If I want to only check that a cross above has occurred based on adjacent candle closes of the secondary period, is the above correct? Is Close[1] the close of the second candle of the primary period or an array of closes for the secondary period?

    [4] Is it possible to use CrossAbove comparing arrayOne[n element] against ArrayTwo[n-1 element] over a given number of preceding candles.

    Many thanks,
    darmbk.

    #2
    Hi darmbk,

    Originally posted by darmbk View Post
    Hi,

    Questions on CrossAbove() using the secondary time period.

    [1] CrossAbove(BarsArray[1],EMA(BarsArray[1],14),5);

    Does this test the following: Did any part of a secondary-period candle touch below but close above the secondary-period's EMA over the last 5 candles. That is if candle one closed above but had a low below and candle two had a close above then is that deemed to be a cross above when using the BarsArray as an input? I'm getting results I don't understand using BarsArray instead of Close. I presume with Close as the input if candle one closes below and candle two closes above then this is a cross above when using Close.

    .
    For your example to cross above requires this:
    BarsArray[1][1] < EMA(BarsArray[1], 14)[1] &&
    BarsArray[1][0] >= EMA(BarsArray[1], 14)[0]

    In English it means that on prior bar the BarsArray is below EMA and on current bar is greater or equal to the ema. Since you have a lookback of 5, cross above will evaluate true if this condition occurs on any of the last 5 bars. It may help to Print the current [0] and prior [1] values for each to output window to better see what's going on. This page can help with using print statements:



    [2] CrossAbove(BarsArray[1],EMA(BarsArray[1],10)[0],5);

    Is the '[0]' incorrect because this has CrossAbove taking a single element rather than array in its second variable?
    Nothing incorrect there. For CrossAbove/Below one value must be a series but the other can be a double. You can see supported overloads here:


    [3] CrossAbove(Close[1],EMA(BarsArray[1],10),5);

    If I want to only check that a cross above has occurred based on adjacent candle closes of the secondary period, is the above correct? Is Close[1] the close of the second candle of the primary period or an array of closes for the secondary period?
    Close[1] is the prior value and will depend on the BarsInProgress context. More information is available here on working with multiple time frames:
    http://www.ninjatrader.com/support/helpGuides/nt7/multi_time_frame__instruments.htm

    [4] Is it possible to use CrossAbove comparing arrayOne[n element] against ArrayTwo[n-1 element] over a given number of preceding candles.
    It's not possible to change CrossAbove hard coded behavior. If both inputs are series, then it compares [0] and [1] for both arrays to determine crossing. If one input is a double, then it checks that the series crossed above that double value.
    Last edited by NinjaTrader_RyanM1; 12-04-2013, 10:26 AM.
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Thanks Ryan,

      I understand [2] and [4] but need a little clarity on [1] and [3].

      [1] The help on BarsArray does not give an example of what an element in BarsArray is. If a given bar has OHLC of (90, 100, 70, 80) what would BarsArray return as its value?

      [3] Based on the help file, I need to use Closes[1], and not Close[1], to refer to the array of bar close values for the secondary time frame. Correct?

      Cheers,
      darmbk.

      Comment


        #4
        Good question. BarsArray will be the Close value, or 80 in your OHLC example.

        Correct - Closes[1] refers to array of close values for secondary time frame.
        Ryan M.NinjaTrader Customer Service

        Comment


          #5
          Hi Ryan,

          One final question on your last answer. Is Closes[2] = BarsArray[2] = array of closing values for the third time frame specified by the user; and Closes[1][3] = BarsArray[1][3] = the third closing value in the second time frame array.

          Many thanks,
          darmbk.

          Comment


            #6
            You understand correctly.

            Closes[2]/BarsArray[2] would be the array of closing values for the 3 time frame.

            Closes[1][3] woudl be the 3rd closing value for the second time frame.
            MatthewNinjaTrader Product Management

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Shansen, 08-30-2019, 10:18 PM
            24 responses
            939 views
            0 likes
            Last Post spwizard  
            Started by Max238, Today, 01:28 AM
            0 responses
            7 views
            0 likes
            Last Post Max238
            by Max238
             
            Started by rocketman7, Today, 01:00 AM
            0 responses
            4 views
            0 likes
            Last Post rocketman7  
            Started by wzgy0920, 04-20-2024, 06:09 PM
            2 responses
            28 views
            0 likes
            Last Post wzgy0920  
            Started by wzgy0920, 02-22-2024, 01:11 AM
            5 responses
            33 views
            0 likes
            Last Post wzgy0920  
            Working...
            X