• 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

Find Max/Min of calendar week

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

    Find Max/Min of calendar week

    Hi Guys,
    I need to find the max and min of the current calendar week for my stop.
    I tried to find the max/min for the last 5 bars but because sometimes due to holidays the weeks only got 3 or 4 trading days and that messes up my results.
    Is there a more clever approach?

    And also as a second question is it possible to read the first trading day/date of the next week? If for example Monday is a Holiday i recieve the date of tuesday?

    Also is it possible to read the W: 2/2020 displayed on the screen attached? I think that would help me too!

    Thanks a lot!
    Attached Files
    Last edited by Branpo; 01-14-2020, 04:41 AM.

    #2
    Hello Branpo,

    Thanks for your post.

    You can access the SessionIterator which "Allows you to traverse through various trading hours data elements which apply to a segment of bars". Reference: https://ninjatrader.com/support/help...oniterator.htm

    If you are looking historically, here is an example you can refer to: https://ninjatraderecosystem.com/use...row-indicator/ Please note: The NinjaTrader Ecosystem website is for educational and informational purposes only and should not be considered a solicitation to buy or sell a futures contract or make any other type of investment decision. The add-ons listed on this website are not to be considered a recommendation and it is the reader's responsibility to evaluate any product, service, or company. NinjaTrader Ecosystem LLC is not responsible for the accuracy or content of any product, service or company linked to on this website.
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Hello Branpo,

      Just following up and re-reading your initial post and looking at your screenshot, I see now that you are using daily bars so the session iterator would not be of much use as it is mainly for intraday bars, so my apologies for not checking closer before replying.

      I would instead suggest checking for holidays or partial holidays through the trading hours side: https://ninjatrader.com/support/help...adinghours.htm

      To find the Min/Max, are you using the MIN() and MAX() methods and specifying 5 as the lookback? This would get the last 5 bars regardless of what day/week.
      References:
      https://ninjatrader.com/support/help...aximum_max.htm
      https://ninjatrader.com/support/help...inimum_min.htm

      You can check what day of the week by looking at Time[0].Day.



      Paul H.NinjaTrader Customer Service

      Comment


        #4
        Hi Paul,

        I think I found a workaround that suits for me.

        But now I got another problem using the Min/Max.
        If I use the following Code it works absolutely fine:

        if ((Tage_Countdown_Short == 1)
        && (Times[0][1].DayOfWeek == DayOfWeek.Friday || Times[0][1].DayOfWeek == DayOfWeek.Thursday) && (myEntryOrder == null))
        {
        var shortentry = MIN(Low, 3)[0]-TickSize;
        EnterShortStopMarket(0, true, DefaultQuantity, shortentry, @"EntryShort");
        Short_order_aktiv = true;
        }

        The order is getting placed and filled and the rest of my script is also working fine!

        But if i Change it to [1] to exclude the current Bars max/min like this

        if ((Tage_Countdown_Short == 1)
        && (Times[0][1].DayOfWeek == DayOfWeek.Friday || Times[0][1].DayOfWeek == DayOfWeek.Thursday) && (myEntryOrder == null))
        {
        var shortentry = MIN(Low, 3)[1]-TickSize;
        EnterShortStopMarket(0, true, DefaultQuantity, shortentry, @"EntryShort");
        Short_order_aktiv = true;
        }

        The order doesnt get placed?
        Do you have a clue what reasing that could have?

        heres the error msg i recieve:
        Strategy 'QQQ: A SellShort order placed at '22.01.2019 19:30:00' has been ignored since the stop price is greater than or equal to the close price of the current bar. This is an invalid order and subsequent orders may also be ignored. Please fix your strategy.
        The open of the bar is higher than the stop price so it normaly should enter the trade intraday to the stop price shouldnt it?
        Last edited by Branpo; 01-16-2020, 03:48 AM.

        Comment


          #5
          Hello Branpo,

          Thanks for your reply.

          You are setting the short entry to be 1 tick below the low of the the lowest of the past three bars but you do not know if the current live price is already less than that value. You would need to add a check to see if the calculated entry price is indeed less than the current price to prevent the error.
          Paul H.NinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Kelsoner, Today, 11:31 AM
          0 responses
          3 views
          0 likes
          Last Post Kelsoner  
          Started by srbdoc, Today, 10:48 AM
          2 responses
          5 views
          0 likes
          Last Post srbdoc
          by srbdoc
           
          Started by Mttzern, Today, 10:42 AM
          0 responses
          6 views
          0 likes
          Last Post Mttzern
          by Mttzern
           
          Started by markbb10, Today, 06:55 AM
          2 responses
          8 views
          0 likes
          Last Post markbb10  
          Started by sgordet, Today, 09:58 AM
          1 response
          8 views
          0 likes
          Last Post NinjaTrader_ShawnB  
          Working...
          X