Announcement

Collapse
No announcement yet.

Calculating current bar's price range

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

  • Calculating current bar's price range

    Hi, I want to write a simple script to display in the CursorLabel window the value of the current candle's range in pips.

    Would appreciate any help on which parameters to use for this.

    Thanks

  • #2
    Re: Calculating current bar's price range

    dk
    In your script return the High-Low of the bar and convert that to a string which will not plot on the chart but will display the value in the Cursor Window.
    An easy way to convert the value to a string is to use the formatPriceNumber() function ie
    formatPriceNumber(high(0)-low(0))
    The added benefit [over other methods of converting a number to a string] of using formatPriceNumber() is that it returns the values always in the same format as the symbol you are charting.
    Alex

    Originally posted by dk
    Hi, I want to write a simple script to display in the CursorLabel window the value of the current candle's range in pips.

    Would appreciate any help on which parameters to use for this.

    Thanks

    Comment


    • #3
      Alexis thanks for reply. Am struggling a bit with the efs syntax. Is there an example study you can point me to where I can understand the context of this code?

      Thanks

      Comment


      • #4
        dk
        There is really not that much to that line of code. It simply subtracts the Low of the current bar ie low(0) from the High of the current bar ie high(0). The equation is nested in the formatPriceNumber() function so that the values returned by the equation will be formatted in the same way as the symbol on the chart (for the description of the functions together with examples of their use see the links to the corresponding articles in the EFS KnowledgeBase)
        Just copy that line of code and place it in the return statement of an efs and you will see the range of the bar displayed in the Cursor Window
        Alex


        Originally posted by dk
        Alexis thanks for reply. Am struggling a bit with the efs syntax. Is there an example study you can point me to where I can understand the context of this code?

        Thanks

        Comment


        • #5
          ok I have managed to do this. How do I set the background colour for the CursorLabel window?

          Thanks

          Comment


          • #6
            dk
            You would do that using the setBarFgColor() or setDefaultBarFgColor() functions depending on your needs. For the description, syntax and examples see the link to the related article in the EFS KnowledgeBase
            Alex


            Originally posted by dk
            ok I have managed to do this. How do I set the background colour for the CursorLabel window?

            Thanks

            Comment


            • #7
              Thanks Alexis.

              A related question to this - if I want to paint just the bars on the chart with, for example, a stoch or RSI study based on my specified rules, can I specify 'just' these bars to be affected and leave all other bars on the chart as normal?

              At the moment every time I have tried to add a study like this, it paints all the bars with a default colour and then highlights the stoch/rsi bars in another colour. I just want to highlight those bars affected not all of them so that I can see the up bars and down bars as usual.

              Thanks for help.

              Comment


              • #8
                dk
                At this time when you paint the price bars [even if only some of them] you override the chart's default colors so if you want to see the other price bars colored as when using the chart's default colors you have to set all the necessary conditions and paint those price bars accordingly.
                Alex


                Originally posted by dk
                Thanks Alexis.

                A related question to this - if I want to paint just the bars on the chart with, for example, a stoch or RSI study based on my specified rules, can I specify 'just' these bars to be affected and leave all other bars on the chart as normal?

                At the moment every time I have tried to add a study like this, it paints all the bars with a default colour and then highlights the stoch/rsi bars in another colour. I just want to highlight those bars affected not all of them so that I can see the up bars and down bars as usual.

                Thanks for help.

                Comment

                Working...
                X