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

get the weekly high of the last three weeks

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

    get the weekly high of the last three weeks

    Good morning to everybody,
    My idea is to obtain the weekly high of the last three weeks and the weekly low of the last three weeks to average them.
    High medium = (High weekly (-1) + High weekly (-2) + High weekly (-3) / 3 and in the same way with the low
    I've read quite a bit on the matter, but haven't found a valid answer to what I need and that apparently shouldn't be too complicated, although it finally seems so.
    I have seen that there are several indicators, for example ana, but what I want is not to paint the signals, but I want is to obtain the values ​​to use them mathematically. I have tried to add a weekly data series, but including the strategy in the chart gives an error, which I am not able to solve, so I would like to know if there is a simpler way, which does not require adding additional data series .
    Thank you very much and Greetings

    #2
    Hello danakede,

    Thanks for your post.

    When adding a weekly type series to a strategy, your chart would have to "load" enough days to accommodate the look back period for the weekly bars. For example if you are only loading 10 days of data then you can only look back that far.

    If you are using intraday data (less than daily bars) you could (download and install) use an available indicator called PriorWeekOHLC which will provide as the name implies the prior weeks Open, High, Low, and Close values (based on the data on your chart without adding a data series) In this case you would only be looking for the High value. Again though you would need to load enough data to ensure you are collecting the appropriate information.

    This indicator is publicly available on our NinjaTrader Ecosystem website:Here is a basic guideline of how to Import NinjaScripts.

    To import NinjaScripts you will need the original .zip file.

    To Import
    1. Download the NinjaScripts to your desktop, keep them in the compressed .zip file.
    2. From the Control Center window select the menu Tools>Import>Ninjascript add-on..
    3. Select the downloaded .zip file
    4. NinjaTrader will then confirm if the import has been successful.
    Critical - Specifically for some NinjaScripts, it will prompt that you are running newer versions of @SMA, @EMA, etc. and ask if you want to replace, press 'No'

    Once installed, you may add the indicator to a chart by:
    • Right click your chart > indicators > Select the Indicator from the list on the left > New > OK
    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
      Hi Paul,
      What would you recommend, if you wanted to trade a strategy with this "live"?
      NT-Roland

      Comment


        #4
        Hello NT-Roland,

        Thanks for your post on this thread.

        Can you clarify the context of your question or specify your area of concern?
        Paul H.NinjaTrader Customer Service

        Comment


          #5
          Good morning,

          I have verified that when adding an additional data series to my strategy, it cannot be executed on every tick, it does not work with Resolution: "High", only an additional data series can be added to a strategy and it will have to run Resolution: "Standard".

          My strategy is designed to only work with Resolution: "High, tick, 1", so I cannot incorporate additional data series into my strategy.
          The indicator that you says is perfect for me, so my question is ... can I take the values ​​of the indicator to use it in my strategy?
          If possible, what is the method to call them from the strategy?
          Thank you

          Comment


            #6
            Hello danakede,

            Thanks for your reply.

            To use an indicator in your strategy, you would want to create it as a private instance, typically at the class level like: private PriorWeekOHLC mypw; // mypw will be the local instance of the indicator PriorWeekOHLC.

            You will need to initialize the local instance of the indicator in State.DataLoaded, like this: mypw = PriorWeekOHLC();

            To then access the local indicator in the OnBarUpdate, you would need to specify which of the 4 plots to use. You mentioned wanting the weekly high so we can use that. I would suggest using this print statement in OnBarUpdate() and check the New>Ninjascipt output window for the values it produces to help you see how this will work:

            if (Bars.IsFirstBarOfSession)
            {

            Print (Time[0]+" Prior week High = "+mypw.PriorWeekHigh[0].ToString());
            }


            For each session you should expect to see the same values until you get to a new week when the values would change and you can use that change to trigger some action such as saving the new value into a variable and saving the previous value into another variable until you have 3 variable representing the last 3 weeks. then you can start calculating your average.

            Paul H.NinjaTrader Customer Service

            Comment


              #7

              thank you very much for your help i have already achieved my purpose

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by mjairg, 07-20-2023, 11:57 PM
              3 responses
              213 views
              1 like
              Last Post PaulMohn  
              Started by TheWhiteDragon, 01-21-2019, 12:44 PM
              4 responses
              544 views
              0 likes
              Last Post PaulMohn  
              Started by GLFX005, Today, 03:23 AM
              0 responses
              3 views
              0 likes
              Last Post GLFX005
              by GLFX005
               
              Started by XXtrader, Yesterday, 11:30 PM
              2 responses
              12 views
              0 likes
              Last Post XXtrader  
              Started by Waxavi, Today, 02:10 AM
              0 responses
              7 views
              0 likes
              Last Post Waxavi
              by Waxavi
               
              Working...
              X