//+------------------------------------------------------------------+ //| RSI.mq4 | //| Copyright © 2004, MetaQuotes Software Corp. | //| http://www.metaquotes.net/ | //| by Hartono Setiono | //+------------------------------------------------------------------+ #property copyright "Copyright © 2004, MetaQuotes Software Corp." #property link "http://www.metaquotes.net/" #property indicator_separate_window #property indicator_minimum 0 #property indicator_maximum 100 #property indicator_buffers 1 #property indicator_color1 DodgerBlue //---- input parameters extern int RSIPeriod=3; extern int RSITimeFrame=1440; //---- buffers double RSIBuffer[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { string short_name; IndicatorBuffers(1); //---- indicator line SetIndexStyle(0,DRAW_LINE); SetIndexBuffer(0,RSIBuffer); //---- name for DataWindow and indicator subwindow label short_name="RSI("+RSIPeriod+")"; IndicatorShortName(short_name); SetIndexLabel(0,short_name); //---- SetIndexDrawBegin(0,RSIPeriod); //---- return(0); } //+------------------------------------------------------------------+ //| Relative Strength Index | //+------------------------------------------------------------------+ int start() { int i,x,counted_bars=IndicatorCounted(); double rel,negative,positive; //---- if(RSITimeFrame==0) RSITimeFrame = Period(); if(RSITimeFrame==Period()) x=1; else x=0; if(Bars<=RSIPeriod) return(0); if(Period()=RSIPeriod) i=Bars-counted_bars-1; while(i>=0) { RSIBuffer[i]=iRSI(NULL,RSITimeFrame,RSIPeriod,PRICE_CLOSE,MathFloor(i*Period()/RSITimeFrame)+x); i--; } //---- return(0); } //+------------------------------------------------------------------+