IRSI Indicator trouble

 

I'm having trouble with an indicator I made. It is really simple, only a few lines. What I want it to do is place indicator lines on the price chart which show when RSI is above 70 or less than 30. Can anyone see an obvious problem with the following code?

// RSI Alert Indicator, lower than 30, above 70.

#property copyright "Ryan"

#property link ""

#property indicator_chart_window

#property indicator_buffers 2

#property indicator_color1 Aqua

#property indicator_color2 Coral

double RSIUp[];

double RSIDown[];

//+------------------------------------------------------------------+

//| Custom indicator initialization function |

//+------------------------------------------------------------------+

int init()

{

SetIndexStyle(0, DRAW_LINE,STYLE_SOLID,2);

SetIndexLabel(0, "RSIUp");

SetIndexBuffer(0, RSIUp);

SetIndexStyle(1, DRAW_LINE,STYLE_SOLID,2);

SetIndexLabel(1, "RSIDown");

SetIndexBuffer(1, RSIDown);

return(0);

}

//+------------------------------------------------------------------+

//| Custom indicator iteration function |

//+------------------------------------------------------------------+

int start()

{

int limit;

int counted_bars=IndicatorCounted();

if(counted_bars<0) return(-1);

if(counted_bars>0) counted_bars--;

limit=Bars-counted_bars;

for(int i=0; i<limit; i++) {

if (iRSI(NULL,0,14,PRICE_CLOSE,0) < 30) RSIUp = Low - 0.5;

if (iRSI(NULL,0,14,PRICE_CLOSE,0) > 70) RSIDown = High + 0.5;

}

return(0);

}

 

iRSI(NULL,0,14,PRICE_CLOSE,i)

instead of

iRSI(NULL,0,14,PRICE_CLOSE,0)

 
asmdev:
iRSI(NULL,0,14,PRICE_CLOSE,i)

instead of

iRSI(NULL,0,14,PRICE_CLOSE,0)

Thanks, I'm sure that was a problem, but I'm still not getting anything on my charts, even when I can see it going below and above the thresholds on the RSI chart.

 

replace 0.5 with 5*Point

add to the init() function

SetIndexEmptyValue(0, 0);

SetIndexEmptyValue(1, 0)

and don't forget to see line on the chart you need 2 points, test it on small period such as 6

if you have rsi above level on only 1 bar i dont think mt4 displays line, you'll have to use DRAW_ARROW or DRAW_HISTOGRAM

 

Works great now. And thanks for the tips.

Reason: