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

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, 05: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:



      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, 04: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 jeronymite, 04-12-2024, 04:26 PM
          3 responses
          40 views
          0 likes
          Last Post jeronymite  
          Started by bill2023, Today, 08:51 AM
          2 responses
          16 views
          0 likes
          Last Post bill2023  
          Started by sidlercom80, 10-28-2023, 08:49 AM
          167 responses
          2,260 views
          0 likes
          Last Post jeronymite  
          Started by warreng86, 11-10-2020, 02:04 PM
          7 responses
          1,362 views
          0 likes
          Last Post NinjaTrader_Manfred  
          Started by Perr0Grande, Today, 08:16 PM
          0 responses
          5 views
          0 likes
          Last Post Perr0Grande  
          Working...
          X