//+------------------------------------------------------------------+
//| 4D - Range Switch.mq4 |
//| Copyright © 2009, Vic2008 |
//| |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2009, Vic2008"
#property link ""
#property indicator_chart_window
#property indicator_buffers 1
#property indicator_color1 Red
//---- buffers
double ExtMapBuffer1[];
double PREV=0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,ExtMapBuffer1);
PREV=0;
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int i;
for( i=Bars-5; i>=0; i-- ){
if( Close[i] > MathMax(MathMax(High[i+1],High[i+4]),MathMax(High[i+2],High[i+3])) ){ ExtMapBuffer1[i]=MathMin(MathMin(Low[i],Low[i+3]),MathMin(Low[i+1],Low[i+2])); }
else{
if( Close[i] < MathMin(MathMin(Low[i+1],Low[i+4]),MathMin(Low[i+2],Low[i+3])) ){ ExtMapBuffer1[i]=MathMax(MathMax(High[i],High[i+3]),MathMax(High[i+1],High[i+2])); }
else{ ExtMapBuffer1[i]=PREV; }
}
PREV=ExtMapBuffer1[i];
}
return(0);
}
//+------------------------------------------------------------------+
Comments