MoR_MTF_Test





//+------------------------------------------------------------------+
//|                                                      2MA_RSI.mq4 |
//+------------------------------------------------------------------+
#property copyright "Wolfe"
#property link "xxxxwolfe@gmail.com"

#property indicator_separate_window
#property indicator_level1  100
#property indicator_level2  80
#property indicator_level3  50
#property indicator_level4  20
#property indicator_buffers 4
#property indicator_color1 Black    //RSI
#property indicator_color2 Blue     //MA1
#property indicator_color3 Red      //MA2
#property indicator_color4 Green    //Ratio

int  RSI_Timeframe=0;//0=current chart,1=m1,5=m5,15=m15,30=m30,60=h1,240=h4,etc...
int  RSI_Period = 10;
int  RSI_Applied_Price = 0;//0=close, 1=open, 2=high, 3=low, 4=(high+low)/2, 5=(high+low+close)/3, 6=(high+low+close+close)/4
int  MA1_Period = 10;
int  MA1_Method = 1;// 0=SMA, 1=EMA, 2=SMMA, 3=LWMA
int  MA2_Period = 30;
int  MA2_Method = 1;// 0=SMA, 1=EMA, 2=SMMA, 3=LWMA

double RSI[],MA1_Array[],MA2_Array[],MR_Ratio[];
double _RSI[],_MA1_Array[],_MA2_Array[],_MR_Ratio[];
string ShortName="MoR";

//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators setting
///*
SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,1); //RSI
SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,1); //EMA10
SetIndexStyle(2,DRAW_LINE,STYLE_SOLID,1); //EMA30
SetIndexStyle(3,DRAW_LINE,STYLE_SOLID,2); //Ratio

SetIndexBuffer(0,RSI);
SetIndexLabel(0,"RSI");

SetIndexBuffer(1,MA1_Array);
SetIndexLabel(1,"MA1");

SetIndexBuffer(2,MA2_Array);
SetIndexLabel(2,"MA2");

SetIndexBuffer(3,MR_Ratio);
SetIndexLabel(3,"Ratio");
//*/

SetIndexBuffer(0,EMPTY_VALUE);
SetIndexBuffer(1,EMPTY_VALUE);
SetIndexBuffer(2,EMPTY_VALUE);
SetIndexBuffer(3,EMPTY_VALUE);

IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS));
IndicatorShortName(ShortName);

return(0);
}

int start()
{
   /*
   IndicatorBuffers(4);
   SetIndexBuffer(0,RSI);
   SetIndexBuffer(1,MA1_Array);
   SetIndexBuffer(2,MA2_Array);
   SetIndexBuffer(3,MR_Ratio);
   SetIndexBuffer(0,RSI);
   SetIndexBuffer(1,MA1_Array);
   SetIndexBuffer(2,MA2_Array);
   SetIndexBuffer(3,MR_Ratio);
   */
   int i,idx=-1,limit = Bars - IndicatorCounted() - 1;
   for(i=limit; i>=0; i--){
      RSI[i]= iRSI(NULL,60,RSI_Period,RSI_Applied_Price,i);
   }
   for(i=limit; i>=0; i--){ 
      MA1_Array[i] = iMAOnArray(RSI,0,MA1_Period,0,MA1_Method,i);
      MA2_Array[i] = iMAOnArray(RSI,0,MA2_Period,0,MA2_Method,i);
   }
   for (i=0; i<=limit; i++){
      if (MA2_Array[i]!=0){
         MR_Ratio[i] = MA1_Array[i] / MA2_Array[i] * 100;
         if (idx==-1)idx=i;
      }
   }
   double tmp1=MR_Ratio[idx];
   SetText("Label1",DoubleToStr(tmp1,1),Black,55,20);
   
   //+------------------------------------------------------------------+
   //| Trying to set new buffers                                        |
   //+------------------------------------------------------------------+
   /*
   IndicatorBuffers(4);
   IndicatorBuffers(EMPTY_VALUE);
   SetIndexBuffer(0,EMPTY);
   SetIndexBuffer(1,EMPTY);
   SetIndexBuffer(2,EMPTY);
   SetIndexBuffer(3,EMPTY);
   SetIndexBuffer(0,_RSI);
   SetIndexBuffer(1,_MA1_Array);
   SetIndexBuffer(2,_MA2_Array);
   SetIndexBuffer(3,_MR_Ratio);
   */
   for(i=limit; i>=0; i--){
      RSI[i]=EMPTY_VALUE;
   }
   for(i=limit; i>=0; i--){ 
      MA1_Array[i] = EMPTY_VALUE;
      MA2_Array[i] = EMPTY_VALUE;
   }
   for (i=0; i<=limit; i++){
         MR_Ratio[i] = EMPTY_VALUE;
   }
   
   idx=-1;
   for(i=limit; i>=0; i--){
      //_RSI[i]= iRSI(NULL,240,RSI_Period,RSI_Applied_Price,i);
      //RSI[i]=EMPTY_VALUE;
      RSI[i]= iRSI(NULL,240,RSI_Period,RSI_Applied_Price,i);
   }
   for(i=limit; i>=0; i--){
      //_MA1_Array[i] = iMAOnArray(_RSI,0,MA1_Period,0,MA1_Method,i);
      //MA1_Array[i]=EMPTY_VALUE;
      MA1_Array[i] = iMAOnArray(RSI,0,MA1_Period,0,MA1_Method,i);
      //_MA2_Array[i] = iMAOnArray(_RSI,0,MA2_Period,0,MA2_Method,i);
      //MA2_Array[i]=EMPTY_VALUE;
      MA2_Array[i] = iMAOnArray(RSI,0,MA2_Period,0,MA2_Method,i);
   }
   for (i=0; i<=limit; i++){
     //if (_MA2_Array[i]!=0){
     if (MA2_Array[i]!=0){
         //_MR_Ratio[i] = _MA1_Array[i] / _MA2_Array[i] * 100;
         //MR_Ratio[i]=EMPTY_VALUE;
         MR_Ratio[i] = MA1_Array[i] / MA2_Array[i] * 100;
         if (idx==-1)idx=i;
     }
   }
   //double tmp2=_MR_Ratio[idx];
   double tmp2=MR_Ratio[idx];
   SetText("Label2",DoubleToStr(tmp2,1),Black,95,20);
   //----
   return(0);
}

void SetText(string ObjName,string ObjText,color clr,int xpos,int ypos){
   ObjectCreate(ObjName,OBJ_LABEL,WindowFind(ShortName),0,0);
   ObjectSetText(ObjName,ObjText,9,"Arial Bold",clr);
   ObjectSet(ObjName,OBJPROP_CORNER,0);
   ObjectSet(ObjName,OBJPROP_XDISTANCE,xpos);
   ObjectSet(ObjName,OBJPROP_YDISTANCE,ypos);
}





Sample





Analysis



Market Information Used:



Indicator Curves created:

Implements a curve of type DRAW_LINE


Indicators Used:

Relative strength index
Moving average indicator


Custom Indicators Used:

Order Management characteristics:

Other Features: