Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Indicator High/Low bar "open" line plot- need programmer help

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

    Indicator High/Low bar "open" line plot- need programmer help

    It seems so simple on paper, but although I did try to create this indicator I just cannot seem to get my mind around all the coding required - I really did make a real attempt to learn this -but its just not getting in (for now).

    All I need to do is plot a line of the "Open" of a 5min bar (or any other interval, ie tick/volume/range/renko) which is bar that is also the daily high or low of that day -intraday only. So it will plot only the Open price with a line (with price # text on it) after it is determined that within the bars range it is the high or low of the day -obviously calculated on bars close. All prior bars that were once high or low of day-their "open "lines should then disappear as they lose new high/low status.

    Now - as a filter - to plot a valid "open" price indicator line - for high of day bar - the close must be greater than open, and for low of day bar - the close must be less than open.

    I am at the mercy of your help with this - I will be happy to take whatever anyone can begin to create and perhaps I can then learn to edit it and add and learn Ninjascript in the process.

    Thank you in advance. Rob
    Last edited by ea0680; 01-20-2013, 05:16 PM. Reason: further clarification

    #2
    Originally posted by ea0680 View Post
    It seems so simple on paper, but although I did try to create this indicator I just cannot seem to get my mind around all the coding required - I really did make a real attempt to learn this -but its just not getting in (for now).

    All I need to do is plot a line of the "Open" of a 5min bar (or any other interval, ie tick/volume/range/renko) which is bar that is also the daily high or low of that day -intraday only. So it will plot only the Open price with a line (with price # text on it) after it is determined that within the bars range it is the high or low of the day -obviously calculated on bars close. All prior bars that were once high or low of day-their "open "lines should then disappear as they lose new high/low status.

    Now - as a filter - to plot a valid "open" price indicator line - for high of day bar - the close must be greater than open, and for low of day bar - the close must be less than open.

    I am at the mercy of your help with this - I will be happy to take whatever anyone can begin to create and perhaps I can then learn to edit it and add and learn Ninjascript in the process.

    Thank you in advance. Rob
    Untested, annotated, quick-and-dirty code which should do as you describe. Let me know if there are any snafu's that are not what you have described here.

    Code:
    #region Variables
    private double HH;
    private double LL;
    #endregion
    Code:
    protected override void Initialize()
    {
    Add(new Plot(Color.FromKnownColor(KnownColor.Blue), PlotStyle.Square, "PlotHH"));
    Add(new Plot(Color.FromKnownColor(KnownColor.Purple), PlotStyle.Square, "PlotLL"));
     
    Plots[0].Pen = new Pen(Color.Blue, 3); //thicken the Plot so we can see it
    Plots[1].Pen = new Pen(Color.Purple, 3);
     
    Overlay = true; //draw on the chart panel
    }
    Code:
    protected override void OnBarUpdate()
    {
    if (CurrentBar < 1) return; //we are referencing one bar back, so we must escape processing on the first bar, bar0
     
    if (Time[1].Date != Time[0].AddSeconds(1).Date)
    {
    //It is a new day. we must start somewhere, so we set these unconditionally
    this.HH = High[0];
    this.LL = Low[0];
    this.PlotHH.Set(this.HH);
    this.PlotHH.Reset(1);
    this.PlotLL.Set(this.LL);
    this.PlotLL.Reset(1);
    return; //and leave because this is the first bar of the day, so we are done
    }
     
    if (Close[0] >= Open[0]) 
    {
    this.HH = Math.Max(this.HH, High[0]);
    this.PlotHH.Set(this.HH); //set the plot
    this.PlotHH.Reset(1); //delete the plot on previous bar
    }
    else
    {
    this.PlotHH.Set(this.PlotHH[1]); //filter not satisfied. Retain the Plot from previous value.
    this.PlotHH.Reset(1); //then delete that Plot value from the chart.
    }
     
    if (Close[0] <= Open[0])
    {
    this.LL = Math.Min(LL, Low[0]);
    this.PlotLL.Set(this.LL);
    this.PlotLL.Reset(1);
    }
    else
    {
    this.PlotLL.Set(this.PlotLL[1]);
    this.PlotLL.Reset(1);
    }
     
    }
    Code:
    #region Properties
    [Browsable(false)] // this line prevents the data series from being displayed in the indicator properties dialog, do not remove
    [XmlIgnore()] // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
    public DataSeries PlotHH
    {
    get { return Values[0]; }
    }
    [Browsable(false)] // this line prevents the data series from being displayed in the indicator properties dialog, do not remove
    [XmlIgnore()] // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
    public DataSeries PlotLL
    {
    get { return Values[1]; }
    }
    #endregion
    Last edited by koganam; 01-20-2013, 07:07 PM.

    Comment


      #3
      Thanks for the quick post Koganam. I have been trying to enter / copy paste the code just provided to the indicator I started today. I just am such a amateur that I am getting many lines of code errors when I go to compile .

      I seem to be lost with getting this indicator to work - I see kognanams code in front of me -and it seems to get to where I would like to plot the indicator line - but logistically I cant seem to copy/paste this code correctly, and I tried multple times, different ways and to no avail.

      I do appreciate the work done -the issue is most definetly on my end, as its clear I need to get my programming skills up to even a basic level.

      Comment


        #4
        Originally posted by ea0680 View Post
        Thanks for the quick post Koganam. I have been trying to enter / copy paste the code just provided to the indicator I started today. I just am such a amateur that I am getting many lines of code errors when I go to compile .

        I seem to be lost with getting this indicator to work - I see kognanams code in front of me -and it seems to get to where I would like to plot the indicator line - but logistically I cant seem to copy/paste this code correctly, and I tried multple times, different ways and to no avail.

        I do appreciate the work done -the issue is most definetly on my end, as its clear I need to get my programming skills up to even a basic level.
        The code is shown in sections that mimic exactly the sections of an indicator. You just have to copy the relevant code to each section.

        What are your errors?

        Comment


          #5
          I have since now brought down the number of errors to one - CS1513, which is letting me know that } bracket is expected on line 206. However, this line of code is

          "NinjaScript generated code. Neither change nor remove" which
          starts at line of code 94 and runs to 207 .


          When I try and enter the missing bracket on line 206, it does remove the error code - I then try to compile , and the error is then back, same line and automatically removed the bracket I just entered to fix it. Saving the file after I enter the bracket correction to line 206 after the error code is gone, when I start compiling, same result of the manually entered bracket gets removed and error is back. I tried looking for a unnessary bracket { out in the code as I can see when you click on a bracket, it highlights the closing bracket. I did not locate it - as any I thought I found, if I deleted it, it caused dozens of errors, so I just put back the bracket and those issues resolved.


          So not sure what to do - I feel like Im close, but for some reason cant get past this error code from automatically reappearing.


          Thanks for your time and help with this.
          Last edited by ea0680; 01-21-2013, 12:42 AM. Reason: typo

          Comment


            #6
            Originally posted by ea0680 View Post
            I have since now brought down the number of errors to one - CS1513, which is letting me know that } bracket is expected on line 206. However, this line of code is

            "NinjaScript generated code. Neither change nor remove" which
            starts at line of code 94 and runs to 207 .


            When I try and enter the missing bracket on line 206, it does remove the error code - I then try to compile , and the error is then back, same line and automatically removed the bracket I just entered to fix it. Saving the file after I enter the bracket correction to line 206 after the error code is gone, when I start compiling, same result of the manually entered bracket gets removed and error is back. I tried looking for a unnessary bracket { out in the code as I can see when you click on a bracket, it highlights the closing bracket. I did not locate it - as any I thought I found, if I deleted it, it caused dozens of errors, so I just put back the bracket and those issues resolved.


            So not sure what to do - I feel like Im close, but for some reason cant get past this error code from automatically reappearing.


            Thanks for your time and help with this.
            The bracketing must have gotten screwed up when you did your cut-and-paste job. It might be faster if you would start over. Use the wizard to create an unpopulated skeleton, and just carefully make sure that you copy all the sections and paste them in.

            After your report, I have done this myself, and the code compiles and displays with no errors. Unfortunately, you will have to do the copy-and-paste because, due to a singular display of ingrates on this board, I have, as a matter of principle decided that I shall never again supply a complete indicator to anyone on this board, even if by supplying all the code, I may be violating the spirit of that vow.

            Here is the saga of one such ingrate: http://www.ninjatrader.com/support/f...777#post240805

            It may make more sense to read the final post first: it is a rather long chain of posts.

            Comment


              #7
              I was able to finally compile the indicator (errors were due to my overly aggressive initial code deletions). I could not test it while the market was open today so will see it perform tommorrow. Thank you koganam for all your help.

              Comment


                #8
                UPDATE: After plotting this indicator on the chart, and looking at what lines are being created, I think something is off. The indicator should be checking to see if the bar has hit a high or low of the day , and if yes , then filter should be only ploting that HOD/LOD bar "Open" if and only when that new high of day bar open < close, and similarly plot the low of day bar "Open" when its bar open >close .

                I think from what I can see, the code has it plotting the "high" and "low" of the repective HOD/LOD bars.

                I included a quick chart of how I would think the lines should plot.
                Attached Files
                Last edited by ea0680; 01-21-2013, 02:37 PM. Reason: chart

                Comment


                  #9
                  Originally posted by ea0680 View Post
                  UPDATE: After plotting this indicator on the chart, and looking at what lines are being created, I think something is off. The indicator should be checking to see if the bar has hit a high or low of the day , and if yes , then filter should be only ploting that HOD/LOD bar "Open" if and only when that new high of day bar open < close, and similarly plot the low of day bar "Open" when its bar open >close .

                  I think from what I can see, the code has it plotting the "high" and "low" of the repective HOD/LOD bars.

                  I included a quick chart of how I would think the lines should plot.
                  This is what you requested in your original post: "All prior bars that were once high or low of day-their "open "lines should then disappear as they lose new high/low status. " That is what was coded,. It was a rather strange looking description to me then, but I wrote what you described, or at least that is the way that I read the English. If you want the line held until a new value, then that is what should have been said.

                  What you drew is a somewhat different kettle of fish, and a bit more involved. Hopefully you can use what you have as a basis for modification. You just need to write code to:
                  • Store the last start x-value of the line, and
                  • When the line value changes, to reset the line all the way back to that starting x-value,
                  • Start the new line, and
                  • Record the new starting x-value.
                  Wash, rinse, repeat.

                  Comment


                    #10
                    Ok I understand, thanks anyway .

                    Comment


                      #11
                      Originally posted by ea0680 View Post
                      Ok I understand, thanks anyway .
                      @ea0680, Did you ever get this indicator you were looking for worked out?
                      Just curious.

                      Trade well,

                      Comment


                        #12
                        Never did get it to to plot a line just for the "open" on both the high of day and low of day bars. I've just been manually plotting a line.

                        Comment


                          #13
                          Originally posted by ea0680 View Post
                          Never did get it to to plot a line just for the "open" on both the high of day and low of day bars. I've just been manually plotting a line.
                          Okay, I recently worked on a similar project [with positive results] and I have one question regarding your request:
                          What do you want done with the lines formed from the open of the Session's High bar and the Session's Low bar when the next Session's bars close beyond either of those levels?
                          I am planning on drawing a Ray, and then redrawing it as a Line that stops at the bar the exceeds the prior price level where the Ray was originally drawn.
                          Will that do what you want it to do or do you have another suggestion?

                          Comment


                            #14
                            That sounds great. What I manually do is that if , for example, a 5min bar opens, then it makes a new low , I plot a line at that bars open. That line is a indicator that also makes a sound when price tags that line. If then a new low ,forms, I then use that bars open , plotting that new line, removing the prior line. I do also look to make sure that, for the low of day bar, that the open is > than that bar close. Reverse for high of day bar, that the open < than the close of that bar.

                            Comment


                              #15
                              add attachment

                              To be clear;
                              See attached,
                              Attached Files
                              Last edited by TopGunNote; 10-23-2015, 01:39 PM.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Johnny90, Today, 04:19 AM
                              0 responses
                              1 view
                              0 likes
                              Last Post Johnny90  
                              Started by jeanne, Today, 03:43 AM
                              0 responses
                              7 views
                              0 likes
                              Last Post jeanne
                              by jeanne
                               
                              Started by brucejay27, Today, 02:58 AM
                              0 responses
                              4 views
                              0 likes
                              Last Post brucejay27  
                              Started by maxeintstine, Today, 02:46 AM
                              0 responses
                              5 views
                              0 likes
                              Last Post maxeintstine  
                              Started by constituyente, Today, 02:37 AM
                              0 responses
                              3 views
                              0 likes
                              Last Post constituyente  
                              Working...
                              X