MTF_AbsoluteStrength_sBar3





//+------------------------------------------------------------------+
//|                    MTF_     AbsoluteStrength_v1.1  Sidebar   mq4 |
//|       forex-tsd.com  Copyright © 2006, MetaQuotes Software Corp. |
//|                           Copyright © 2006, TrendLaboratory Ltd. |
//|            http://finance.groups.yahoo.com/group/TrendLaboratory |
//|                                       E-mail: igorad2004@list.ru |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2006, TrendLaboratory Ltd."
#property link      "http://finance.groups.yahoo.com/group/TrendLaboratory"

#property indicator_separate_window

#property indicator_buffers 6
#property indicator_color1 Blue
#property indicator_color2 DodgerBlue
#property indicator_color3 Tomato
#property indicator_color4 Red
#property indicator_color5 Yellow
#property indicator_color6 Gold
#property indicator_maximum 10
#property indicator_minimum 1

//---- input parameters
extern int TimeFrame =60;
extern int ASbarLevel = 5; // bar location in sep.windpw(from 1(min) to 77(max))
extern int       Mode   =  0; // 0-RSI method; 1-Stoch method; 2-ADX method
extern string note = "Level:1-77;Mode:RSI1;Stoch2;ADX3";
extern int       Length = 10; // Period
extern int       Smooth =  5; // Period of smoothing
extern int       Signal =  5; // Period of Signal Line
extern int       Price  =  0; // Price mode : 0-Close,1-Open,2-High,3-Low,4-Median,5-Typical,6-Weighted
extern int       ModeMA =  3; // Mode of Moving Average
extern string note1 = "Price(OCHLMTF)ModeMa(SMA0,EMA1,SmmMA2,LWMA3";

/*************************************************************************
PERIOD_M1   1
PERIOD_M5   5
PERIOD_M15  15
PERIOD_M30  30 
PERIOD_H1   60
PERIOD_H4   240
PERIOD_D1   1440
PERIOD_W1   10080
PERIOD_MN1  43200
You must use the numeric value of the timeframe that you want to use
when you set the TimeFrame' value with the indicator inputs.
---------------------------------------
MODE_SMA    0 Simple moving average, 
MODE_EMA    1 Exponential moving average, 
MODE_SMMA   2 Smoothed moving average, 
MODE_LWMA   3 Linear weighted moving average. 
You must use the numeric value of the MA Method that you want to use
when you set the 'ma_method' value with the indicator inputs.

**********************************************************/
//---- buffers
double TrendUpStrong[];
double TrendUp[];
double TrendDown[];
double TrendDownStrong[];
double NoDirection[];
double Volatile[];

double SmthBulls[];
double SmthBears[];
double SigBulls[];
double SigBears[];
double SigNoTrade[];

string TimeFrameStr;

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
  SetIndexStyle(0,DRAW_ARROW);
  SetIndexBuffer(0,TrendUpStrong);
  SetIndexArrow(0,110);
  SetIndexStyle(1,DRAW_ARROW);
  SetIndexBuffer(1,TrendUp);
  SetIndexArrow(1,110);
  SetIndexStyle(2,DRAW_ARROW);
  SetIndexBuffer(2,TrendDown);
  SetIndexArrow(2,110);   
  SetIndexStyle(3,DRAW_ARROW);
  SetIndexBuffer(3,TrendDownStrong);
  SetIndexArrow(3,110);   
  SetIndexStyle(4,DRAW_ARROW);
  SetIndexBuffer(4,NoDirection);
  SetIndexArrow(4,110);   
  SetIndexStyle(5,DRAW_ARROW);
  SetIndexBuffer(5,Volatile);
  SetIndexArrow(5,110);  

  //SetIndexLabel(0,"AS_Bulls("+TimeFrame+")");
  //SetIndexLabel(1,"AS_Bears("+TimeFrame+")");
  //SetIndexLabel(2,"AS_NoTrade("+TimeFrame+")");
  
switch(TimeFrame)
   {
      case 1 : TimeFrameStr="Period_M1"; break;
      case 5 : TimeFrameStr="Period_M5"; break;
      case 15 : TimeFrameStr="Period_M15"; break;
      case 30 : TimeFrameStr="Period_M30"; break;
      case 60 : TimeFrameStr="Period_H1"; break;
      case 240 : TimeFrameStr="Period_H4"; break;
      case 1440 : TimeFrameStr="Period_D1"; break;
      case 10080 : TimeFrameStr="Period_W1"; break;
      case 43200 : TimeFrameStr="Period_MN1"; break;
      default : TimeFrameStr="Current TimeFrame"; TimeFrame=0;
   }
   IndicatorShortName("MTF_ASsb("+TimeFrameStr+")["+Length+"]");  
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   datetime TimeArray[];
   int    i,limit,y=0,counted_bars=IndicatorCounted();
 
// Plot defined time frame on to current time frame
   ArrayCopySeries(TimeArray,MODE_TIME,Symbol(),TimeFrame); 
   
   limit=Bars-counted_bars+TimeFrame/Period();
   for(i=0,y=0;i<limit;i++)
   {
   if (Time[i]<TimeArray[y]) y++;
 
      TrendUpStrong[i]=EMPTY_VALUE;
      TrendUp[i]=EMPTY_VALUE;
      TrendDown[i]=EMPTY_VALUE;
      TrendDownStrong[i]=EMPTY_VALUE;
      NoDirection[i]=EMPTY_VALUE;
      Volatile[i]=EMPTY_VALUE;
   
   double SmthBulls   =iCustom(NULL,0,"AbsoluteStrength_v1.1",  Mode, Length,Smooth, Signal, Price, ModeMA,0,0,0,y);
   double SmthBears   =iCustom(NULL,0,"AbsoluteStrength_v1.1",  Mode, Length,Smooth, Signal, Price, ModeMA,0,0,1,y);
   double SigBulls    =iCustom(NULL,0,"AbsoluteStrength_v1.1",  Mode, Length,Smooth, Signal, Price, ModeMA,0,0,2,y);
   double SigBears    =iCustom(NULL,0,"AbsoluteStrength_v1.1",  Mode, Length,Smooth, Signal, Price, ModeMA,0,0,3,y);
   
   if(SmthBulls>SigBulls && SmthBears<=SigBears) TrendUpStrong[i]=ASbarLevel;
   if(SmthBulls>SigBulls && SmthBears>SigBears && ((SmthBulls-SigBulls)>(SmthBears-SigBears))) TrendUp[i]=ASbarLevel;
   if(SmthBulls>SigBulls && SmthBears>SigBears && ((SmthBulls-SigBulls)<(SmthBears-SigBears))) TrendDown[i]=ASbarLevel;
   if(SmthBulls<=SigBulls && SmthBears>SigBears) TrendDownStrong[i]=ASbarLevel;
   if(SmthBulls<=SigBulls && SmthBears<=SigBears) NoDirection[i]=ASbarLevel;
   if(SmthBulls>SigBulls && SmthBears>SigBears && ((SmthBulls-SigBulls)==(SmthBears-SigBears))) Volatile[i]=ASbarLevel;

}
   //----  Refresh buffers ++++++++++++++++++++ upgrade by Raff  
     int TimeFrame;   if (TimeFrame>Period()) {
     int PerINT=TimeFrame/Period()+1;
     datetime TimeArr[]; ArrayResize(TimeArr,PerINT);
     ArrayCopySeries(TimeArr,MODE_TIME,Symbol(),Period()); 
     for(i=0;i<PerINT+1;i++) {if (TimeArr[i]>=TimeArray[0]) {
 /********************************************************  
    Refresh buffers:         buffer[i] = buffer[0];
 ********************************************************/  

      TrendUpStrong[i] = TrendUpStrong[0];
      TrendUp[i] = TrendUp[0];
      TrendDown[i] = TrendDown[0];
      TrendDownStrong[i] = TrendDownStrong[0];
      NoDirection[i] = NoDirection[0];
      Volatile[i] = Volatile[0];




//--
   } } }
//+++++++++++++++++++++++++++++++++++++++++++++++++++  Raff  
   return(0);
  }
//+-------------------------------------------------------+



Sample





Analysis



Market Information Used:

Series array that contains open time of each bar


Indicator Curves created:

Implements a curve of type DRAW_ARROW


Indicators Used:




Custom Indicators Used:
AbsoluteStrength_v1.1

Order Management characteristics:

Other Features: