Crosses under/over question

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #101950 quote
    CKW
    Participant
    Veteran

    hi,

    How do you code “close crosses over/under X” to handle X value will be changing from top to down or vice-versa?

    e.g.

    From chart, close price has never cross over/under old trend or new trend. But in coding, “close crosses under Trend” is executed as true. I want it to stay false.

    can you please help?

    br,

    CKW

    Capture.jpg Capture.jpg
    #101955 quote
    robertogozzi
    Moderator
    Master

    Cross Over is when then previous price was < “your_indicator” while now it’s above it.

    Cross Under is the other way round.

    IF close CROSSES OVER "your_indicator" THEN

    is the same as:

    IF close[1] < "your_indicator" and close > "your_indicator" THEN

    “your_indicator” can be any indicator, or price (On DAX it could be 12650) or a S/R level or whatever else you need to detect when it’s being crossed over.

    CLOSE is most commonly used, but you can replace it by HIGH, LOW, and so on… depending on what suits best your needs.

    #101958 quote
    CKW
    Participant
    Veteran

    Hi Robertozzi,

    Thanks for your reply. But it’s not my question.

    I know how to use cross under/over for typical case it but in certain case, it just do not work. From my first attached picture, close price has never cross these lines but when the trend line change from top – down, the “close crosses under trendline” will become true. In reality, it should false as no crosses never happen.

    Do you know how to solve it?

    br,

    CKW

    #101959 quote
    robertogozzi
    Moderator
    Master

    There’s been a CROSS UNDER.

    You can easily GRAPH those values, candle by candle, to detect it.

    x.jpg x.jpg
    #101961 quote
    Nicolas
    Keymaster
    Master

    I don’t know how you are defining the “new trend”, but just simply don’t test crosses over/under when a newtrend occur on the same bar/period.

    #101964 quote
    robertogozzi
    Moderator
    Master

    This is a SuperTrend CROSSOVER.

    x-1.jpg x-1.jpg
    #101966 quote
    CKW
    Participant
    Veteran

    Hi Nicholas,

    yes. I think that’s only the way, I have tried few solution but it does not work.

    thanks

    br,

    CKW

    #101975 quote
    Vonasi
    Moderator
    Master

    You could simply just check if the trend line is between any bars high and low. If it is then price has crossed within that bar. You may want to then check on the next bar that the close is still on the same expected side of the trend line.

Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.

Crosses under/over question


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
CKW @ckw Participant
Summary

This topic contains 7 replies,
has 4 voices, and was last updated by Vonasi
6 years, 8 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 07/04/2019
Status: Active
Attachments: 3 files
Logo Logo
Loading...