Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Understanding medians X SMA

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

    Understanding medians X SMA

    What would be the difference between (Medians[0][0] > Medians[0][60])
    and
    Medians[0[0] >SMA (BarsArray[0],60)[0]))??

    What is the difference between Median and Medians???
    Can I use Median with instrument [1]??
    Last edited by dafonseca; 03-24-2013, 01:36 PM.

    #2
    Hello,
    Originally posted by dafonseca View Post
    What would be the difference between (Medians[0][0] > Medians[0][60])
    Checks the Median of the primary series of the current bar vs the value from 60 bars ago

    and
    Medians[0[0] >SMA (BarsArray[0],60)[0]))??
    Checks to see if the Median is > than an SMA using a 60 bar period on the primary series

    LanceNinjaTrader Customer Service

    Comment


      #3
      So, why I have different results from theses:

      (Medians[1][0] > Medians[1][RSICycle]))

      (Medians[1][0] > SMA (BarsArray[1],RSICycle)[0]) )

      Comment


        #4
        Because the first is the median value of 60 bars ago.

        The second uses the SMA value of the current bar based on 60bars of data.

        SMA and Median are not the same in the way they are calculated.

        to view the source of the SMA go to edit -> ninjascript -> indicator -> SMA

        Median is (High + Low) / 2 for a single bar.
        LanceNinjaTrader Customer Service

        Comment


          #5
          completely understood now..Thank you.

          Comment


            #6
            OnBarClose X instrument [1]

            How can I generate an order on instrument [0] given a condition on intrument [1] without wait for barOnClose in [0]?
            In order words: what CalculateOnBarClose = true (on Initialize()) means?
            Do I have to use false?

            Comment


              #7
              Originally posted by dafonseca View Post
              How can I generate an order on instrument [0] given a condition on intrument [1] without wait for barOnClose in [0]?
              I mean I just care for instrument [1] to generate this order.
              Hello,

              You can set the order to be sent during BIP == 1 and send it to instrument BIP == 0

              All the enter methods have an overload that takes in the barsinprogressindex


              For more on this please see the last section here: http://www.ninjatrader.com/support/h...nstruments.htm
              LanceNinjaTrader Customer Service

              Comment


                #8
                I understood your point:
                But my order condition only check instrument [1]..
                I mean , I do not need to use BIP==1 to check the condition, Do I??
                in case the condition is true, the order would be generate on BIP==0 by default, Am I correct?
                So, Why Do I need to manage BarInProgress? and how?
                Supposing the code below:
                Does EnterShort sell instrument [0]?
                how could I manage BIP there?

                protected override void Initialize()
                {
                Add("CL 04-11", PeriodType.Minute,1);
                CalculateOnBarClose = true;
                }
                protected override void OnBarUpdate()
                {
                if ((CrossAbove(Medians[1], Bollinger( BarsArray[1], NumberStdDev, Period).Lower, 1))
                {
                EnterShort(0,70, "FirstSeriesShort");
                }
                ....
                }
                Last edited by dafonseca; 03-24-2013, 02:43 PM.

                Comment


                  #9
                  You will likely want to add the BIP filtering.

                  In your example the EnterShort could be called from either series. This might be ok depending on your goals but adding a filter such as

                  Code:
                  if(BarsInProgress != 0)
                    return;
                  would allow you to prevent the enter short from being called more than once.

                  If you're looking to place an order to the primary series after a condition of the 2nd series is met you would need to do this when BIP == 1

                  Example:
                  Code:
                  if(BarsInProgress == 1 && MYLOGIC)
                    EnterShort(0,70, "FirstSeriesShort");
                  LanceNinjaTrader Customer Service

                  Comment


                    #10
                    Understood.
                    But what about OnBarClose .. should I leave it TRUE? (to generate the order as soon as condition on I[1] is set to TRUE)
                    protected override void Initialize()
                    {
                    CalculateOnBarClose = true;
                    }

                    Comment


                      #11
                      This depends on how you want the bars being referenced to be handled.

                      Fist I will point out that in backtesting CalculateOnBarClose always = true

                      When running multiple series with COBC = false each new tick all data series will be called.
                      When running with COBC = true, OnBarUpdate() is only called when one of the series closes a bar. If more than one call it at the same time then it will perform in order of series (primary, secondary, etc)

                      For a diagram explaining the differences please see How bar data is referenced: http://www.ninjatrader.com/support/h...nstruments.htm
                      LanceNinjaTrader Customer Service

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by argusthome, Yesterday, 10:06 AM
                      0 responses
                      22 views
                      0 likes
                      Last Post argusthome  
                      Started by NabilKhattabi, 03-06-2026, 11:18 AM
                      0 responses
                      19 views
                      0 likes
                      Last Post NabilKhattabi  
                      Started by Deep42, 03-06-2026, 12:28 AM
                      0 responses
                      14 views
                      0 likes
                      Last Post Deep42
                      by Deep42
                       
                      Started by TheRealMorford, 03-05-2026, 06:15 PM
                      0 responses
                      10 views
                      0 likes
                      Last Post TheRealMorford  
                      Started by Mindset, 02-28-2026, 06:16 AM
                      0 responses
                      41 views
                      0 likes
                      Last Post Mindset
                      by Mindset
                       
                      Working...
                      X