Navigation:Home > Content >

Spectrometr_Separate_Selective_Cycle_2.07.mq4

Time: 2013-06-17 | Download file:Spectrometr_Separate_Selective_Cycle_2.07.mq4

//+-----------------------------------------------------------------------------+
//|                                                        Spectr_Separate.mq4  |
//|                                                               Yuriy Tokman  |
//|                                                      yuriytokman@gmail.com  |
//|                                                                             |
//| Modifications by Pip - www.PriceMasterPro.Com                               |
//|                                                                             |
//| 1) Added ability to select cycles to display. 8/1/2011                      |
//| 2) Added ability to sum all or selective cycles into one composite 8/1/2011 |
//| 3) Removed 8th cycle and replaced by summed cycle in 2) above 8/1/2011      |
//| 4) Added boolean for display of cycle meter 9/23/2011                       |
//| 5) Changed bool logic for composite cycle drawing 10/24/2011
//|                                                                             |
//+-----------------------------------------------------------------------------+
#property copyright ""
#property link      ""

#property indicator_separate_window
#property indicator_buffers 8

#import "spectrometr.dll"
   double fourier(double& sourceArray[], double& A[], double& B[], double& R[], double& F[], int n, int m);
#import

//---- input parameters

extern int       iPeriod=240;
extern int       iStartFrom=1; 
extern string    AddToObjName="1";
extern color     HandlerColor=Gray;
extern color     TextColor=Black; 
extern bool      Cycle1 = true;
extern bool      Cycle2 = true;
extern bool      Cycle3 = true;
extern bool      Cycle4 = true;
extern bool      Cycle5 = true;
extern bool      Cycle6 = true;
extern bool      Cycle7 = true;
extern bool      CompositeCycle = false;
extern bool      CycleMeter = false;
extern string    UniqueID = "spectrometr1";
extern int       FutureLineStyle = STYLE_DOT;
extern color     Color1 = Red;
extern color     Color2 = Orange;
extern color     Color3 = Yellow;
extern color     Color4 = Lime;
extern color     Color5 = Blue;
extern color     Color6 = DodgerBlue;
extern color     Color7 = DarkViolet;
extern color     Color8 = DimGray;
 

string ShortName;

int LastTime;

//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];
double ExtMapBuffer4[];
double ExtMapBuffer5[];
double ExtMapBuffer6[];
double ExtMapBuffer7[];
double ExtMapBuffer8[];


int LastLeftBar;
int LastRightBar;
int LastLeftTime;
int LastRightTime;
int LastStartFrom;
int LastiStartFrom;
int LastiPeriod;

int window;

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init(){
   ShortName=UniqueID+UniqueID+"_"+AddToObjName;   
   UniqueID=UniqueID+"_"+AddToObjName+"_";  

    
   
   IndicatorDigits(5);
   IndicatorShortName(ShortName);

    SetIndexBuffer(0,ExtMapBuffer1);
    SetIndexBuffer(1,ExtMapBuffer2);
    SetIndexBuffer(2,ExtMapBuffer3);    
    SetIndexBuffer(3,ExtMapBuffer4); 
    SetIndexBuffer(4,ExtMapBuffer5);  
    SetIndexBuffer(5,ExtMapBuffer6); 
    SetIndexBuffer(6,ExtMapBuffer7);
    SetIndexBuffer(7,ExtMapBuffer8);
    
 if (!CompositeCycle)
 {
   SetIndexStyle(0,DRAW_LINE,DRAW_LINE,2);
   SetIndexStyle(1,DRAW_LINE,DRAW_LINE,2);
   SetIndexStyle(2,DRAW_LINE,DRAW_LINE,2);
   SetIndexStyle(3,DRAW_LINE,DRAW_LINE,2);
   SetIndexStyle(4,DRAW_LINE,DRAW_LINE,2);
   SetIndexStyle(5,DRAW_LINE,DRAW_LINE,2);
   SetIndexStyle(6,DRAW_LINE,DRAW_LINE,2);
   SetIndexStyle(7,DRAW_NONE);
}

else

  {
  
   SetIndexStyle(0,DRAW_NONE);
   SetIndexStyle(1,DRAW_NONE);
   SetIndexStyle(2,DRAW_NONE);
   SetIndexStyle(3,DRAW_NONE);
   SetIndexStyle(4,DRAW_NONE);
   SetIndexStyle(5,DRAW_NONE);
   SetIndexStyle(6,DRAW_NONE);
   SetIndexStyle(7,DRAW_LINE,DRAW_LINE,2);
   
   } 
   
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
{
   deleteFuture();
//----
   fObjDeleteByPrefix(UniqueID);
//----
   return(0);
  }
void deleteFuture()
{
   string searchFor    = UniqueID+":";
   int    searchLength = StringLen(searchFor);
   for (int i=ObjectsTotal()-1; i>=0; i--)
   {
      string name = ObjectName(i); if (StringSubstr(name,0,searchLength) == searchFor)
                                       ObjectDelete(name);
   }
}  
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+

double A[],B[],R[],F[];
int start(){

   window = WindowFind(ShortName);
      
      string ObjName=UniqueID+"Нулевая линия";
         
         if(window>-1 && ObjectFind(ObjName)!=WindowFind(ShortName)){
            LastStartFrom=iStartFrom;//
            LastLeftBar=iStartFrom+iPeriod-1;
            LastRightBar=iStartFrom;            
            LastLeftTime=Time[LastLeftBar];
            LastRightTime=Time[LastRightBar];         
            fObjTrendLine(ObjName,LastLeftTime,0,LastRightTime,0,false,HandlerColor,3,WindowFind(ShortName),0,true);
         }
         
      int NowLeftTime=ObjectGet(ObjName,OBJPROP_TIME1);
      int NowRightTime=ObjectGet(ObjName,OBJPROP_TIME2); 
      if(NowRightTime>Time[1])NowRightTime=Time[1];
      
      int NowLeftBar=iBarShift(NULL,0,NowLeftTime,false);
      int NowRightBar=iBarShift(NULL,0,NowRightTime,false);  
//      iPeriod=NowLeftBar-NowRightBar+1; 
      int LastStartFromTime=iBarShift(NULL,0,LastRightTime,false);  
//      iStartFrom=(NowRightBar-LastStartFromTime)+LastStartFrom; 
      
      LastStartFrom=iStartFrom;
      LastLeftBar=iStartFrom+iPeriod-1;
      LastRightBar=iStartFrom;            
      LastLeftTime=Time[LastLeftBar];
      LastRightTime=Time[LastRightBar];         
      
      ObjName=UniqueID+"iPeriod";
      fObjLabel(ObjName,100,5,"Period: "+iPeriod,3,TextColor,8,WindowFind(ShortName),"Arial Black",false);
      ObjName=UniqueID+"iStartFrom";      
      fObjLabel(ObjName,10,5," StartFrom: "+iStartFrom,3,TextColor,8,WindowFind(ShortName),"Arial Black",false);
      
      
   //=====================================================================================================    

      static int LastBars=0;

//      if(iStartFrom==LastiStartFrom && iPeriod==LastiPeriod)if(Bars=0;i--){
      if(StringFind(ObjectName(i),aPrefix,0)==0){
         ObjectDelete(ObjectName(i));
      }
   }
}

Recommend