• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

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(Medians[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 epitoma, Today, 05:21 PM
              1 response
              11 views
              0 likes
              Last Post NinjaTrader_ShawnB  
              Started by BatBart, Today, 01:24 PM
              1 response
              22 views
              0 likes
              Last Post NinjaTrader_Melissa  
              Started by ezrakoper, Today, 03:05 PM
              1 response
              7 views
              0 likes
              Last Post NinjaTrader_ChelseaB  
              Started by asmmbillah, Today, 02:23 PM
              1 response
              17 views
              0 likes
              Last Post NinjaTrader_Jesse  
              Started by steveg, Today, 02:44 PM
              1 response
              9 views
              0 likes
              Last Post NinjaTrader_Heath  
              Working...
              X