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

Higher time frame adx

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

    Higher time frame adx

    Hi Guys,
    I am trying to incorporate a higher time frame, 360 min ADX indicator into a startegy. I have read through the threads and tried a few different things but keep getting errors when compiling. I am not sure what I am missing. I have probably confused the issue, I believe it should be Add(ADX,PeriodType.Minute, 360); but that didn't work either.

    any help appreciated.
    thanks raef

    protectedoverridevoid Initialize()
    {
    Add(Instrument, PeriodType.Minute,
    360);
    Add(ADX(Adx));
    SetProfitTarget(
    "", CalculationMode.Ticks, Target);
    SetStopLoss(
    "", CalculationMode.Ticks, Stop, false);
    CalculateOnBarClose =
    true;
    }
    ///<summary>
    /// Called on each bar update event (incoming tick)
    ///</summary>
    protectedoverridevoid OnBarUpdate()
    {
    // Condition set 1
    if (ADX(BarsArray[1], 360)(Adx)[1] > 30
    && CrossBelow(EMA(Emafast), EMA(Emaslow), 2))

    #2
    Hello,

    Thank you for your post.

    If you are adding a 360 minute data series of the same instrument for your ADX to caculate, you would want to add it using the following syntax:

    Code:
    protected override void Initialize()
    {
    Add(PeriodType.Minute, 360);
    Notice that you do not need to specify the instrument as this will just add a 360 minute data series of the primary data series.

    Then in on bar update, you do not need to specify 360 again for the BarsArray - this is already added in Initialize. All you need to do is specify this array that you added using [1].

    Code:
    protected override void OnBarUpdate()
    
    {
    if (ADX(BarsArray[1], Adx)[1] > 30)
    Fore more information on Multi-Time Frame & Instruments please see our Help Guide on this topic:

    MatthewNinjaTrader Product Management

    Comment


      #3
      Thanks Mathew I realy enjoy when I get a solution sorted, I understand the time period stuff a bit better now will come in handy.
      Thanks raef

      Comment


        #4
        Glad to hear that sorted it out and hope this helps for the future as well.

        Have a nice weekend!
        MatthewNinjaTrader Product Management

        Comment


          #5
          Not true statement

          I have another little problem just wondering if I could get pointed in the right direction.
          I want to make a not true statement with a cross below but the compiler is saying that I am using too many arguments. Do I have to do this in reverse and describe all the true stements only or can I put it in a second stement on its own.
          if ( !=(CrossBelow(ADX(BarsArray[1],6), Adxl, 4))

          Any help appreciated
          Thanks Raef


          Comment


            #6
            Hi Raef,

            Just looks like extra = in there. Either line below should work to express "no cross below on this bar"
            if (!CrossBelow(ADX(BarsArray[1],6), Adxl, 4)) { }

            if (CrossBelow(ADX(BarsArray[1],6), Adxl, 4) == false) { }
            Ryan M.NinjaTrader Customer Service

            Comment


              #7
              Hi Guys,

              I am having a go at adding a momentum indicator as well. I am unsure on where I can put the Bars Array command. Any help appreciated.
              raef

              && Momentum(EMA(BarsArray[1](12), 12))[1] >= Momentum(EMA(BarsArray[1](12), 12)[3] + 1 * TickSize

              Comment


                #8
                raefon,

                There were a few syntax errors, mainly you will want to put BarsArray as an Argument in the EMA method, separated by a comma between the period. Please see below:

                Code:
                && Momentum(EMA([B]BarsArray[1], 12)[/B], 12)[1] >= Momentum(EMA([B]BarsArray[1], 12[/B]), 12)[3] + 1 * TickSize
                MatthewNinjaTrader Product Management

                Comment


                  #9
                  Thanks Mathew I really appreciate your help.

                  Thanks Again.

                  Comment


                    #10
                    Not a problem, I'm glad to help. Please do not hesitate to ask clarification on anything at all.
                    MatthewNinjaTrader Product Management

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by rocketman7, Today, 02:12 AM
                    7 responses
                    28 views
                    0 likes
                    Last Post NinjaTrader_ChelseaB  
                    Started by guillembm, Yesterday, 11:25 AM
                    3 responses
                    16 views
                    0 likes
                    Last Post NinjaTrader_Jesse  
                    Started by junkone, 04-21-2024, 07:17 AM
                    10 responses
                    148 views
                    0 likes
                    Last Post NinjaTrader_BrandonH  
                    Started by tsantospinto, 04-12-2024, 07:04 PM
                    6 responses
                    101 views
                    0 likes
                    Last Post tsantospinto  
                    Started by trilliantrader, 04-18-2024, 08:16 AM
                    7 responses
                    28 views
                    0 likes
                    Last Post NinjaTrader_BrandonH  
                    Working...
                    X