Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Median of different time period

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

    Median of different time period

    Merry Xmas Ninja Dev's

    I can't seem to find a way to the get the Median of a different time frame in a strategy. I know there is a way :P Can someone please point me in the right direction. Variable0 works by itself, its the Median of the other 2 time frames that I want to add.

    protected override void Initialize()
    {
    Add(PeriodType.Minute, 60); // ON CHART
    Add(PeriodType.Minute, 20); // ON CHART
    CalculateOnBarClose = true;
    }

    protected override void OnBarUpdate()
    {
    Variable0 = SMA(Median, 200)[0];
    Variable1 = SMA(BarsArray[1].Median, 200)[0];
    Variable2 = SMA(BarsArray[2].Median, 200)[0];
    }

    #2
    Originally posted by happypappy View Post
    Merry Xmas Ninja Dev's

    I can't seem to find a way to the get the Median of a different time frame in a strategy. I know there is a way :P Can someone please point me in the right direction. Variable0 works by itself, its the Median of the other 2 time frames that I want to add.

    protected override void Initialize()
    {
    Add(PeriodType.Minute, 60); // ON CHART
    Add(PeriodType.Minute, 20); // ON CHART
    CalculateOnBarClose = true;
    }

    protected override void OnBarUpdate()
    {
    Variable0 = SMA(Median, 200)[0];
    Variable1 = SMA(BarsArray[1].Median, 200)[0];
    Variable2 = SMA(BarsArray[2].Median, 200)[0];
    }
    Are you getting any errors? If so, what are they?

    Comment


      #3
      The code doesn't work, I can't actually compile using BarsArray[1].Median

      I can't seem to find a way to use Median with any form of BarsArray[1] etc. I've tried all sorts of combinations.

      Variable0 = SMA(Median, 200)[0]; works
      Variable0 = SMA(Median[1], 200)[0]; doesn't work
      Variable0 = SMA(BarsArray[1].Median, 200)[0]; doesn't work
      Variable0 = SMA(Median(1), 200)[0]; doesn't work

      Any other ideas?

      Comment


        #4
        Originally posted by happypappy View Post
        The code doesn't work, I can't actually compile using BarsArray[1].Median

        I can't seem to find a way to use Median with any form of BarsArray[1] etc. I've tried all sorts of combinations.

        Variable0 = SMA(Median, 200)[0]; works
        Variable0 = SMA(Median[1], 200)[0]; doesn't work
        Variable0 = SMA(BarsArray[1].Median, 200)[0]; doesn't work
        Variable0 = SMA(Median(1), 200)[0]; doesn't work

        Any other ideas?
        What is the error message when you try to compile?

        Comment


          #5
          Strategy\BreakOut.cs 'NinjaTrader.Data.Bars' does not contain a definition for 'Median' and no extension method 'Median' accepting a first argument of type 'NinjaTrader.Data.Bars' could be found (are you missing a using directive or an assembly reference?) CS1061 - click for info 50 36

          I've got the Median plotted on the charts as a 20min, my indicator works over 60 min, so I just want to determine the price position compared to the SMA median over 20 minutes.
          Last edited by happypappy; 12-29-2013, 01:07 AM.

          Comment


            #6
            Originally posted by happypappy View Post
            Strategy\BreakOut.cs 'NinjaTrader.Data.Bars' does not contain a definition for 'Median' and no extension method 'Median' accepting a first argument of type 'NinjaTrader.Data.Bars' could be found (are you missing a using directive or an assembly reference?) CS1061 - click for info 50 36

            I've got the Median plotted on the charts as a 20min, my indicator works over 60 min, so I just want to determine the price position compared to the SMA median over 20 minutes.
            Try
            Code:
            Variable0 = SMA(Median[COLOR=Red][B]s[/B][/COLOR][1], 200)[0];

            Comment


              #7
              Hi Happypappy,

              Thank you for posting and thank you Koganam for answering.

              Yes, using Medians should resolve the error message.
              Cal H.NinjaTrader Customer Service

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
              0 responses
              649 views
              0 likes
              Last Post Geovanny Suaza  
              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
              0 responses
              370 views
              1 like
              Last Post Geovanny Suaza  
              Started by Mindset, 02-09-2026, 11:44 AM
              0 responses
              109 views
              0 likes
              Last Post Mindset
              by Mindset
               
              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
              0 responses
              574 views
              1 like
              Last Post Geovanny Suaza  
              Started by RFrosty, 01-28-2026, 06:49 PM
              0 responses
              576 views
              1 like
              Last Post RFrosty
              by RFrosty
               
              Working...
              X