CKWParticipant
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
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.
CKWParticipant
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
There’s been a CROSS UNDER.
You can easily GRAPH those values, candle by candle, to detect it.
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.
This is a SuperTrend CROSSOVER.
CKWParticipant
Veteran
Hi Nicholas,
yes. I think that’s only the way, I have tried few solution but it does not work.
thanks
br,
CKW
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.