Last RSI 50 level cross

 

Hello everybody,

I've been around the forex TSD forum for a while and have read a lot of threads and also downloaded some indicators and I want to thank everybody for that, especially the members who help with fixing and modifying indicators.

I'm trying to write an indicator that shows me the last RSI 50 level cross up and cross down.

I have attached the indicator.

The cross up vertical line(blue) works but the cross down line(red) does not.

The red line only works when the RSI value of the current bar is also <50.

I'm still learning and have no programming background, just started with mql4, but I'm able to code some indicators and EA's now.

But with this one I'm a bit stuck.

Here is what I'm trying to achieve:

I want to count back from bar 0 and look for 2 bars; one below the 50 RSI and one above.

Since I'm counting back the cross will be reversed and once it is detected, the previous bar is the bar that crossed RSI 50.

Once I've detected the cross up or down, I want to know the time of that bar to use it to draw the vertical line.

It's not really about the line but I want to know the last bars that crossed up and down, but bar numbers change so I need time.

As I was saying, the cross up works, but the dross down doesn't, can somebody help me fix this please?

Thanks!

Ben

Files:
 

Whoops, attached the wrong file, changed now.. sorry..

 
Bennic:
Hello everybody,

I've been around the forex TSD forum for a while and have read a lot of threads and also downloaded some indicators and I want to thank everybody for that, especially the members who help with fixing and modifying indicators.

I'm trying to write an indicator that shows me the last RSI 50 level cross up and cross down.

I have attached the indicator.

The cross up vertical line(blue) works but the cross down line(red) does not.

The red line only works when the RSI value of the current bar is also <50.

I'm still learning and have no programming background, just started with mql4, but I'm able to code some indicators and EA's now.

But with this one I'm a bit stuck.

Here is what I'm trying to achieve:

I want to count back from bar 0 and look for 2 bars; one below the 50 RSI and one above.

Since I'm counting back the cross will be reversed and once it is detected, the previous bar is the bar that crossed RSI 50.

Once I've detected the cross up or down, I want to know the time of that bar to use it to draw the vertical line.

It's not really about the line but I want to know the last bars that crossed up and down, but bar numbers change so I need time.

As I was saying, the cross up works, but the dross down doesn't, can somebody help me fix this please?

Thanks!

Ben

Ben

Try it out now : rsi_level_cross_1.mq4

Files:
rsi.png  123 kb
 

Thanks mladen!

So I have to count from bar 1.

Can you please also explain why?

Ben

 

When the RSI is <50 the blue line stays at bar 0, it's not working correct.

Only when RSI>50, both the blue and the red lines are at the crosses.

Reason: