Announcement

Collapse
No announcement yet.

Slope Difference...

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

  • Slope Difference...

    I was hoping someone could show me how to make the following text label calculate and print the difference between the current bar's indicator value, and the prior bar's indicator value. As it is written, it prints the value of the current bar's indicator only. The indicator I am plotting is called vSignal.

    Thanks,
    Steve


    //== draw text labels
    if ( isLastBarOnChart() ) {
    drawTextRelative( 2, vSignal, vSignal.toFixed(2) + " = Volume", Color.black, null, Text.VCENTER | Text.BOLD, null, 18, "OO-2" );
    }

  • #2
    Re: Slope Difference...

    Steve
    How to do that will depend on what type of variable vSignal is. If it is a series then you can retrieve its prior values using the .getValue() method (see the link for the description and syntax).
    If instead it is a single value then you will need to retrieve its historical values in one of the ways mentioned in this thread.
    If the formula is the same as the one you posted in this thread then you already have the prior value available to you in the variable vSignal_1 in which case just use vSignal-vSignal_1 to calculate the difference between the current and prior values. You can input that directly in the drawTextRelative() command or you can first create a variable and then input that variable in the drawTextRelative() command
    Alex


    Originally posted by jones24621
    I was hoping someone could show me how to make the following text label calculate and print the difference between the current bar's indicator value, and the prior bar's indicator value. As it is written, it prints the value of the current bar's indicator only. The indicator I am plotting is called vSignal.

    Thanks,
    Steve


    //== draw text labels
    if ( isLastBarOnChart() ) {
    drawTextRelative( 2, vSignal, vSignal.toFixed(2) + " = Volume", Color.black, null, Text.VCENTER | Text.BOLD, null, 18, "OO-2" );
    }

    Comment

    Working...
    X