Announcement

Collapse
No announcement yet.

Opening Range background colour

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Opening Range background colour

    I would appreciate very much if anyone could help me to modify this efs code in a way that the background color for the Opening Range would fill the entire OR range from top to bottom, starting from the first OR bar. If the whole Opening Range high is 1.5 and low 1.2, the background color should be changed between these numbers starting from the first bar. Currently the OR vertical expansion takes into account only the last/current bar.

    Thanks
    Attached Files

  • #2
    Re: Opening Range background colour

    marteck
    You need to return at least one plot to be able to apply the background color so as a first step you will need to change the return statement.
    Once you have done that the script will color the opening range as is without any modifications. If you instead want to color the opening range throughout the day just move the following line of code
    setBarBgColor(Color.white, 0, vLow, vHigh);
    out of the conditional statement and place it just above the return statement
    Alex


    Originally posted by marteck
    I would appreciate very much if anyone could help me to modify this efs code in a way that the background color for the Opening Range would fill the entire OR range from top to bottom, starting from the first OR bar. If the whole Opening Range high is 1.5 and low 1.2, the background color should be changed between these numbers starting from the first bar. Currently the OR vertical expansion takes into account only the last/current bar.

    Thanks

    Comment


    • #3
      Alex, please look at the image. I am trying to change the code in a way that it would fill with white color all the area within blue rectangles.

      PS! The blue outline is just for explanation, no need to write it into efs.

      Mart.
      Attached Files
      Last edited by marteck; 10-27-2008, 07:04 PM.

      Comment


      • #4
        Mart
        The script calcuates the opening range going forward from the first bar of the defined period to the last bar of the period. As such it has no knowledge of what will happen in subsequent bars. (see the enclosed screenshot that illustrates how it determines the OR)
        It does not "back adjust" the range on the previous bars within the period. To do that you would need to run a for loop that cycles through the bars included in the period up to the starting time and adjusts the High and Low values of the range using setBar() (see the EFS KnowledgeBase for the description and syntax of these functions). If you run a search in the forum for the keyword for loop you will find many examples on how to create this routine.
        However you will not be able to retroactively adjust the background color of the previous bars to the upper and lower values of the range as the setBar() function does not currently take the yMin and yMax parameters that are required to do that
        Alex




        Originally posted by marteck
        Alex, please look at the image. I am trying to change the code in a way that it would fill with white color all the area within blue rectangles.

        PS! The blue outline is just for explanation, no need to write it into efs.

        Mart.

        Comment


        • #5
          Thanks Alex, it was a great help. I am quite new in this efs programming, so it is best to ask someone before trying to program something that might not be possible at all.

          But what if the efs takes the last OR bar (when the whole OR is formed) and depending on the active timeframe (15 min for example, 1h/4bars) adjusts the background color some predetermined number of bars backwards (with no reference to the OR starting bar).

          Can someone suggest any practical javascript reading material (books)? So far I have found D. Flanagan’s “Javascript: The Definitive Guide” to be very useful.
          Last edited by marteck; 10-29-2008, 04:04 AM.

          Comment


          • #6
            Mart

            But what if the efs takes the last OR bar (when the whole OR is formed) and depending on the active timeframe (15 min for example, 1h/4bars) adjusts the background color some predetermined number of bars backwards (with no reference to the OR starting bar).
            As I explained in my previous reply you will not be able to retroactively adjust the background color of the previous bars to the upper and lower values of the range as the setBar() function does not currently take the yMin and yMax parameters that are required to do that
            Alex


            Originally posted by marteck
            Thanks Alex, it was a great help. I am quite new in this efs programming, so it is best to ask someone before trying to program something that might not be possible at all.

            But what if the efs takes the last OR bar (when the whole OR is formed) and depending on the active timeframe (15 min for example, 1h/4bars) adjusts the background color some predetermined number of bars backwards (with no reference to the OR starting bar).

            Can someone suggest any practical javascript reading material (books)? So far I have found D. Flanagan’s “Javascript: The Definitive Guide” to be very useful.

            Comment


            • #7
              setBarBgColor() function has series option. Isn’t it possible to use the series offset to change previous bars bg.color?

              Comment


              • #8
                Mart
                setBarBgColor() is used only on the bar being currently processed and the series parameter is to assign the background color to a specific element of the return statement. To change the properties of prior bars one needs to use setBar() and as I already explained this does not currently take the yMin and yMax parameters
                Alex


                Originally posted by marteck
                setBarBgColor() function has series option. Isn’t it possible to use the series offset to change previous bars bg.color?

                Comment


                • #9
                  What about drawLine function? Adding a white line behind every bar in the OR gives the same effect as changing the bg.color.
                  Mart

                  Comment


                  • #10
                    Mart
                    Yes you can use the drawLine...() function inside a for loop to draw the lines on each of those bars.
                    Alex


                    Originally posted by marteck
                    What about drawLine function? Adding a white line behind every bar in the OR gives the same effect as changing the bg.color.
                    Mart

                    Comment

                    Working...
                    X