Identify if the price line is targeting a level from top or bottom

 

Hi, suppose to be in this scenario:

You have to test if the price has break an horizontal price line and you have to detect if the price/trend is coming from top or from bottom...

How can I do this ?

If I have to do it by watching the graph it is really simple but how can I code it ?

What can be the logic to determinate from where the price has arrived ?


Thanks to support

 
Dario T.If I have to do it by watching the graph it is really simple but how can I code it ?

Exactly as your brain does.

  1. The candle is on both side of your line - it is crossing.
  2. The previous candle is on one side of your line - trend direction.
  3. Show us your attempt (using the CODE button) and state the nature of your problem.
 

Thanks William,

Actually I'm not working with candles... 

Suppose to detect it using a line chart based on candle closing time...

What can be the logic ?

May be I have to check if before the breakout I had a maximum then, I'n coming from High, if instead I had a mininum value, I'm coming from bottom...

Can it work ?

Reason: