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

Indicator that show horizontal line at the highest and lowest on specific time range.

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

    Indicator that show horizontal line at the highest and lowest on specific time range.

    Dear,

    I have to create an indicator that show multiple horizontal lines on the highest and lowest point of a specific time ranges. I have created it, but it is not working properly. Please check the attached indicator.

    My requirements:
    RED HORIZONTAL LINE -OVERNIGHT LOW between 6pm and 930am EST
    DARK BLUE HORIZONTAL LINE -OVERNIGHT HIGH between 6pm and 930am EST

    LIGHT BLUE HORIZONTAL LINE -PREVIOUS DAY HIGH Set between 930am and 415pm EST
    ORANGE HORIZONTAL LINE -PREVIOUS DAY LOW Set between 930am and 415pm EST

    GREEN HORIZONTAL LINE -PREVIOUS DAY CLOSE set at 415pm EST

    PINK HORIZONTAL LINE -LAST WEEKS LOW from prior week’s low
    GRAY HORIZONTAL LINE -LAST WEEKS HIGH from prior week’s high

    Please help me to achieve it.
    Attached Files

    #2
    Hello tech123,

    Thanks for your post and welcome to the NinjaTrader forums!

    For last weeks high and low, it would be easier to use an already existing indicator (PriorWeekOHLC) which can be downloaded from the file sharing area here: http://ninjatrader.com/support/forum...hp?&linkid=540

    For the prior day values you could modify an existing (in your Ninjatrader) indicator called PriorDayOHLC. add a time modification in each so that they only plot as you wish. For example, in the indicator PriorDayOHLC you can add (in Blue):

    Code:
    else // The current day is the same day
    			{
    				[COLOR="Blue"]if (ToTime(Time[0]) > ToTime (16, 15,00)) return;
    				if (ToTime(Time[0]) > ToTime (00,00,00) && ToTime(Time[0]) < ToTime(09, 30,00)) return;[/COLOR]
    				// Set the current day OHLC values
    				currentHigh 	= 	Math.Max(currentHigh, High[0]);
    				currentLow		= 	Math.Min(currentLow, Low[0]);
    				currentClose	=	Close[0];
    For the red and blue lines you could again modify the PriorDayOHLC indicator and add the two additional plots and set code so it only plots during the times specified.
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Hello,

      Thanks for your response. But it didnt solve my problem. Did you check my attached file ?
      Please have a look at that.

      Comment


        #4
        Hello tech123,

        Thanks for your reply.

        To be clear NinjaTrader does not provide code writing or debugging services. If your code is not executing as you expect it to then you will want to use Print statements in the code so you can see when the lines are being drawn and at what price. Print statements send their output to the output window (Tools>Output window).

        Here are other tips to assist with debugging: http://ninjatrader.com/support/forum...ead.php?t=3418
        Paul H.NinjaTrader Customer Service

        Comment


          #5
          Paul,
          I was looking for the same solution as tech 123 and thought I found it. I copied the code for PriodayOHLC and added the blue text as you suggested then saved as a .cs file but NT won't import the script.

          Comment


            #6
            Hello Meeksworth,

            Thanks for your post and welcome to the forums!

            Did you have any compile errors?
            Paul H.NinjaTrader Customer Service

            Comment


              #7
              I didn't use the NT editor. It wouldn't allow me to edit PriorOHLC because it's a stock indicator. I copied and pasted the code into a text document, added the code you suggested, saved as a .cs file, zipped the file, then tried to import into NT.

              I attached an image of the error that I'm seeing.

              Comment


                #8
                Hello Meeksworth,

                Thanks for your reply.

                Regrettably the picture does not show.

                The process you describe could introduce other issues. What I suggest is to open the PriorDayOHLC in the ninjascript editor via Tools>Edit Ninjascript>indicator and choose the PriorDayOHLC indicator. Once the indicator has opened right mouse click in the code section and select "save as" to give it a different name. You can then edit the new file directly and effect the changes and then compile.
                Paul H.NinjaTrader Customer Service

                Comment


                  #9
                  Thanks! That worked. I successfully compiled with no errors. HOWEVER, when I go to my chart to add the indicator it's not in the list of available indicators. Do I need to restart for that to happen?

                  Thanks again!

                  Comment


                    #10
                    Hello Meeksworth,

                    Thanks for your reply.

                    What did you name the new indicator?
                    If you go to Documents>Ninjatrader7>bin>custom>Indicators do you see the file?

                    If you can find the source file but you do not see it in the indicators panel then the issue may be the name of the indicator. Please send the source file into PlatformSupport[at]NinjaTrader[dot]com. In the subject line put: Atten Paul and a link to this thread.
                    Paul H.NinjaTrader Customer Service

                    Comment


                      #11
                      It's working now, I don't know what the problem was. The only other little thing is that I would like the line draw on the chart to go from 00:00 to 24:00. Currently it's drawn only on the period that it fetches the data from which is 8:30 to 16:00. Is there an easy way to make that happen? I'm going to attach the indicator file. Perhaps this can be uploaded for others to use as well.
                      Attached Files

                      Comment


                        #12
                        Hello Meeksworth,

                        Thanks for your post.

                        If you feel that you indicator should be shared with the community you are welcome to add it to the file sharing area. Here is a link: http://ninjatrader.com/support/forum...ks.php?catid=4 In the red bar at the top look for "add entry" to begin the process.
                        Paul H.NinjaTrader Customer Service

                        Comment


                          #13
                          The only other little thing is that I would like the line draw on the chart to go from 00:00 to 24:00. Currently it's drawn only on the period that it fetches the data from which is 8:30 to 16:00. Is there an easy way to make that happen?

                          Comment


                            #14
                            Hello Meeksworth,

                            The purpose of the modifications you made were to exclude plotting at certain times (as member tech123 only want to see data at certain times) so your request to now plot 24 hours conflicts with the modifications.

                            You might try using the original indicator and changing the session times (session template) of the dataseries to something like 24x5 or 24x7.
                            Paul H.NinjaTrader Customer Service

                            Comment

                            Latest Posts

                            Collapse

                            Topics Statistics Last Post
                            Started by bortz, 11-06-2023, 08:04 AM
                            47 responses
                            1,602 views
                            0 likes
                            Last Post aligator  
                            Started by jaybedreamin, Today, 05:56 PM
                            0 responses
                            8 views
                            0 likes
                            Last Post jaybedreamin  
                            Started by DJ888, 04-16-2024, 06:09 PM
                            6 responses
                            18 views
                            0 likes
                            Last Post DJ888
                            by DJ888
                             
                            Started by Jon17, Today, 04:33 PM
                            0 responses
                            4 views
                            0 likes
                            Last Post Jon17
                            by Jon17
                             
                            Started by Javierw.ok, Today, 04:12 PM
                            0 responses
                            12 views
                            0 likes
                            Last Post Javierw.ok  
                            Working...
                            X