Announcement

Collapse
No announcement yet.

Using drawlinerelative in formula

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

  • Using drawlinerelative in formula

    Can anyone let me know if it is possible to write a code to draw a line then use that line at a later date?

    i.e.

    I have drawn a fixed line using drawlinerelative() now I want to mark when the MA crosses that line but I don't know how to refer back to that line.

    Thanks in advance

    Min

  • #2
    Re: Using drawlinerelative in formula

    Min
    There isn't a way you can refer back to the line itself in as much as it does not store the intermediate values (only the endpoints). You need to determine the slope of that line and use that to calculate its value on every bar from the first bar on which the line is drawn.
    For example assume you that have a line that starts at 1 point and ends 10 bars later at 10 points. Its slope will be
    slope = (end point value - start point value) / number of bars elapsed = (10 - 1) / 10 = 0.9
    This means that the line rises by 0.9 points for every bar hence at the 4th bar from the start of the line it will be at
    start point value + (slope * number of bars elapsed) = 1 + (0.9 * 4) = 4.6
    and at the 10th bar it will be at 1 + (0.9 * 10) = 10
    Alex


    Originally posted by Min
    Can anyone let me know if it is possible to write a code to draw a line then use that line at a later date?

    i.e.

    I have drawn a fixed line using drawlinerelative() now I want to mark when the MA crosses that line but I don't know how to refer back to that line.

    Thanks in advance

    Min

    Comment

    Working...
    X