//+------------------------------------------------------------------+
//| RsiArrows.mq4 |
//| Copyright 2015 |
//| |
//+------------------------------------------------------------------+
#property copyright "Copyright 2015"
#property link ""
#property version "1.00"
#property strict
#property indicator_chart_window
#property indicator_buffers 3
#property indicator_color1 clrGreen
#property indicator_color2 clrRed
double ArrowUp[];
double ArrowDn[];
double Rsi[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
IndicatorBuffers(3);
SetIndexBuffer(0,Rsi);
SetIndexBuffer(1,ArrowUp);
SetIndexBuffer(2,ArrowDn);
SetIndexStyle(0,DRAW_NONE,EMPTY);
SetIndexStyle(1,DRAW_ARROW,EMPTY);
SetIndexArrow(1,233);
SetIndexStyle(2,DRAW_ARROW,EMPTY);
SetIndexArrow(2,234);
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
const int prev_calculated,
const datetime &time[],
const double &open[],
const double &high[],
const double &low[],
const double &close[],
const long &tick_volume[],
const long &volume[],
const int &spread[])
{
int i, limit;
limit = rates_total - prev_calculated - 1;
if(rates_total < 1) return(0);
for(i=0;i<limit;i++)
{
Rsi[i] = iRSI(Symbol(),0,4,PRICE_CLOSE,i);
}
for(i=0;i<limit;i++)
{
if(Rsi[i+1] <= 10) ArrowUp[i+1] = low[i+1];
if(Rsi[i+1] >= 90) ArrowDn[i+1] = high[i+1];
}
return(rates_total);
}
//+------------------------------------------------------------------+