Navigation´╝ÜHome > Content >

Corridor_SSA_normalized_end-pointed_mtf_floating_zero.mq4

Time: 2010-06-24 | Download file:Corridor_SSA_normalized_end-pointed_mtf_floating_zero.mq4

//+--------------------------------------------------------------------------------------+
//|                                                                                      |
//+--------------------------------------------------------------------------------------+
#property copyright "www.forex-tsd.com"
#property link      "www.forex-tsd.com"

#property indicator_separate_window
#property indicator_buffers 4
#property indicator_color1 Yellow
#property indicator_color2 LimeGreen
#property indicator_color3 Orange
#property indicator_color4 DarkGray
#property indicator_width2 2
#property indicator_width3 2
#property indicator_style4 STYLE_DOT

#import "libSSA.dll"
   void fastSingular(double& sourceArray[],int arraySize, int lag, int numberOfComputationLoops, double& destinationArray[]);
#import

//
//
//
//
//

extern string TimeFrame               = "Current time frame";
extern int    SSAPrice                =  PRICE_CLOSE;
extern int    SSALag                  = 25;
extern int    SSANumberOfComputations =  2;
extern int    SSAPeriodNormalization  = 25;
extern int    SSANumberOfBars         = 300;
extern int    FirstBar                = 400; 
extern double HighLowStep             = 0.005;
extern int    MinMaxPeriod            = 50;

//
//
//
//
//

double in[];
double no[];
double ssaIn[];
double ssaOut[];
double max[];
double min[];
double zero[];

int    timeFrame;
string indicatorFileName;
bool   returnBars;
bool   calculateValue;

//+--------------------------------------------------------------------------------------+
//|                                                                                      |
//+--------------------------------------------------------------------------------------+
//
//
//
//
//

int init()
{
   IndicatorBuffers(5);
      SetIndexBuffer(0,in);
      SetIndexBuffer(1,max);
      SetIndexBuffer(2,min);
      SetIndexBuffer(3,zero);
      SetIndexBuffer(4,no);
         indicatorFileName = WindowExpertName();
         calculateValue    = (TimeFrame=="calculateValue"); if (calculateValue) return(0);
         returnBars        = (TimeFrame=="returnBars");     if (returnBars)     return(0);
         timeFrame         = stringToTimeFrame(TimeFrame);
   IndicatorShortName(timeFrameToString(timeFrame)+" Corridor SSA normalized end-pointed");
   return(0);
}
int deinit(){return(0);}

//+--------------------------------------------------------------------------------------+
//|                                                                                      |
//+--------------------------------------------------------------------------------------+
//
//
//
//
//

int start()
{
   int counted_bars = IndicatorCounted();
      if(counted_bars < 0) return(-1);
      if(counted_bars > 0) counted_bars--;
         int limit = MathMin(Bars-counted_bars,Bars-1);
         if (returnBars) { in[0] = limit+1; return(0); }

   //
   //
   //
   //
   //
      
   if (calculateValue || timeFrame==Period())
   {
      for(int i=limit; i>=0; i--)
      {
         double ma    = iMA(NULL,0,SSAPeriodNormalization,0,MODE_SMA,SSAPrice,i);
         double dev   = 3.0*iStdDev(NULL,0,SSAPeriodNormalization,0,MODE_SMA,SSAPrice,i);
         double price = iMA(NULL,0,1,0,MODE_SMA,SSAPrice,i);
               if (dev == 0) dev = 0.000001;
                no[i] = (price-ma)/dev;
                in[i] = 0;
                min[i] = 0;
                max[i] = 0;
            
            //
            //
            //
            //
            //
            
            if (i<=FirstBar)
            {
               int ssaBars = MathMin(Bars-i,SSANumberOfBars);
               if (ssaBars=0; i--) 
   {
      int y = iBarShift(NULL,timeFrame,Time[i]);
         in[i]   = iCustom(NULL,timeFrame,indicatorFileName,"calculateValue",SSAPrice,SSALag,SSANumberOfComputations,SSAPeriodNormalization,SSANumberOfBars,FirstBar,HighLowStep,MinMaxPeriod,0,y);
         max[i]  = iCustom(NULL,timeFrame,indicatorFileName,"calculateValue",SSAPrice,SSALag,SSANumberOfComputations,SSAPeriodNormalization,SSANumberOfBars,FirstBar,HighLowStep,MinMaxPeriod,1,y);
         min[i]  = iCustom(NULL,timeFrame,indicatorFileName,"calculateValue",SSAPrice,SSALag,SSANumberOfComputations,SSAPeriodNormalization,SSANumberOfBars,FirstBar,HighLowStep,MinMaxPeriod,2,y);
         zero[i] = iCustom(NULL,timeFrame,indicatorFileName,"calculateValue",SSAPrice,SSALag,SSANumberOfComputations,SSAPeriodNormalization,SSANumberOfBars,FirstBar,HighLowStep,MinMaxPeriod,3,y);
   }
   SetIndexDrawBegin(0,Bars-FirstBar*timeFrame/Period());
   SetIndexDrawBegin(1,Bars-FirstBar*timeFrame/Period());
   SetIndexDrawBegin(2,Bars-FirstBar*timeFrame/Period());
   return(0);
}

//-------------------------------------------------------------------
//
//-------------------------------------------------------------------
//
//
//
//
//

string sTfTable[] = {"M1","M5","M15","M30","H1","H4","D1","W1","MN"};
int    iTfTable[] = {1,5,15,30,60,240,1440,10080,43200};

//
//
//
//
//

int stringToTimeFrame(string tfs)
{
   tfs = stringUpperCase(tfs);
   for (int i=ArraySize(iTfTable)-1; i>=0; i--)
         if (tfs==sTfTable[i] || tfs==""+iTfTable[i]) return(MathMax(iTfTable[i],Period()));
                                                      return(Period());
}
string timeFrameToString(int tf)
{
   for (int i=ArraySize(iTfTable)-1; i>=0; i--) 
         if (tf==iTfTable[i]) return(sTfTable[i]);
                              return("");
}

//
//
//
//
//

string stringUpperCase(string str)
{
   string   s = str;

   for (int length=StringLen(str)-1; length>=0; length--)
   {
      int char1 = StringGetChar(s, length);
         if((char1 > 96 && char1 < 123) || (char1 > 223 && char1 < 256))
                     s = StringSetChar(s, length, char1 - 32);
         else if(char1 > -33 && char1 < 0)
                     s = StringSetChar(s, length, char1 + 224);
   }
   return(s);
}

Recommend