Crosses over/under a line drawn by drawline or drawray

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #202915 quote
    LucasBest
    Participant
    Average

    Hello all,

    • Is there a way to know if an indicator/price crosses over/under a line drawn by drawline or drawray ?
    • Is there an other instruction than crosses over/under to test if an indicator/price close “next to” or on the line drawn by drawline or drawray ?

    Thanks

    #202923 quote
    robertogozzi
    Moderator
    Master
    No, there’s no instruction to detect a crossover with lines. You have to compute the price level on which the line is sitting candle by candle. Firstly, compute the price difference between the leftmost and the rightmost candle:
    StartBar   = barindex[20]
    EndBar     = barindex
    Bars       = EndBar -StartBar
    EndPrice   = Close
    Difference = (EndPrice - Close[20]) / Bars

    then add that difference each candle to know the current price level where the line is plotted. Next candle compute the new price level where the line is supposed to sit:

    EndPrice   = EndPrice   + Difference
    Now you can compare the current price vs the supposed price to detect any crossover:
    If close crosses over EndPrice then
       // do whatever you want when a crossover is detected
    Endif
    if the difference is negative the direction continues downwards, otherwise it will continue upwards. Repeat the last process each bar. When you need to draw a new line elsewhere, repeat the whole process from start.
    LucasBest thanked this post
    #202924 quote
    LucasBest
    Participant
    Average
    Thanks a lot for your answer Roberto. That’s what i though… The aim of this is to look for third of fourth contact on RSI divergences. To keep in an array the RSI Divergences and test other occurences, and delete divergences from the array as sson as there is a cross over…
    Capture-decran-2022-10-22-152054.png Capture-decran-2022-10-22-152054.png
    #202926 quote
    LucasBest
    Participant
    Average
    In this case, there is 2 bearish divergences with 3 points
    Capture-decran-2022-10-22-155525.png Capture-decran-2022-10-22-155525.png
    #202930 quote
    robertogozzi
    Moderator
    Master
    That’s fine, you can replace CLOSE with anything else, be it HIGH, LOW, RSI or MACD etc…
    LucasBest thanked this post
Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.

Crosses over/under a line drawn by drawline or drawray


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
LucasBest @lucasbest Participant
Summary

This topic contains 4 replies,
has 2 voices, and was last updated by robertogozzi
3 years, 4 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 10/22/2022
Status: Active
Attachments: 2 files
Logo Logo
Loading...