translate these mt4 indicators

If you need an Indicator or Signal developed or translated from other language, please post all Indicator development REQUESTS to this section here.

Moderator: admin

translate these mt4 indicators

Postby tulasi » Thu Sep 23, 2010 10:54 am

Code: Select all
//+------------------------------------------------------------------+
//|                             Open_Pivot_PlusLevels_Historical.mq4 |
//|    Based on AllPivots code by IgorAD - adapted & Modified by cja |
//+------------------------------------------------------------------+
#property copyright "Adapted by cja - 2010"

#property indicator_chart_window
//---- input parameters
extern int    CountDays       = 10;
extern int    GMT             = 0;
extern bool  Show_Open        = true;
extern color Open_Pivot_Color = Gold;
extern int   Open_Pivot_width = 2;
extern int Level_1            = 25;
extern int Level_2            = 75;
extern int Level_3            = 125;
extern color Upper_Color      = Lime;
extern color Lower_Color      = Red;
extern int Line_width         = 1;
extern int Line_style         = 2;

extern string Font            = "Tahoma Narrow";
extern int    Fontsize        = 9;

int magic;

//---- indicator buffers
double range[];
double timeshift[];
double low[];
double high[];
datetime time1;
datetime time2;
datetime start_time[];

int shift, num;
int ny_shift[];
datetime prevDay=0;
bool fTime;

   
double myPoint;
   double SetPoint()
   { double mPoint;
   if (Digits < 4)
   mPoint = 0.01;
   else mPoint = 0.0001;
   return(mPoint);
   }
     
// ----
void ObjDel()
{
   if (ObjectsTotal() > 0)
   for (num=0;num<=CountDays;num++)
   {
   ObjectDelete("OP["+num+"]"+magic);
   ObjectDelete("UP1["+num+"]"+magic);
   ObjectDelete("UP2["+num+"]"+magic);
   ObjectDelete("UP3["+num+"]"+magic);
   
   ObjectDelete("DN1["+num+"]"+magic);
   ObjectDelete("DN2["+num+"]"+magic);
   ObjectDelete("DN3["+num+"]"+magic);
     
   }
   
   ObjectDelete("textP"+magic);
   ObjectDelete("op"+magic);
   ObjectDelete("up1"+magic);
   ObjectDelete("up2"+magic);
   ObjectDelete("up3"+magic);
   
   ObjectDelete("dn1"+magic);
   ObjectDelete("dn2"+magic);
   ObjectDelete("dn3"+magic);
 
               
}
// ----
void PlotLine(string name,double value,double value1,double line_color,double style,double width)
{
   double valueN=NormalizeDouble(value,Digits);
   double valueN1=NormalizeDouble(value1,Digits);
   bool res = ObjectCreate(name,OBJ_TREND,0,time1,valueN,time2,valueN1);
   ObjectSet(name, OBJPROP_WIDTH, width);
   ObjectSet(name, OBJPROP_STYLE, style);
   ObjectSet(name, OBJPROP_RAY, false);
   ObjectSet(name, OBJPROP_BACK, true);
   ObjectSet(name, OBJPROP_COLOR, line_color);
}
//***********
void PlotPrice(string name, double value, double line_color)
{
    double valueN=NormalizeDouble(value,Digits);
    bool res = ObjectCreate(name, OBJ_ARROW, 0, time2,valueN);
    ObjectSet(name, OBJPROP_COLOR, line_color);
    ObjectSet(name, OBJPROP_WIDTH, 1);
    ObjectSet(name, OBJPROP_ARROWCODE, SYMBOL_RIGHTPRICE);
}


void Plottext(string name,string LabelText, int FontSize, string FontName, double value, double line_color)
{
    double valueN=NormalizeDouble(value,Digits);
    bool res = ObjectCreate(name, OBJ_TEXT, 0, time1,valueN);
    ObjectSetText(name, LabelText, FontSize, FontName, line_color);
   } 
 
 
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
{
   fTime = true;
   IndicatorBuffers(2);
   SetIndexBuffer(0,range);
   SetIndexBuffer(1,timeshift);
   myPoint = SetPoint();
   return(0);
}

//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+   
int deinit()
{
   ObjDel();
   Comment("");
   return(0);
}
//+------------------------------------------------------------------+
//| LNX_Pivots_v3.1                                                  |
//+------------------------------------------------------------------+
int start()
{
   magic=234+GMT+Show_Open;
   int i;
   double P,R1,R2,R3,R4,S1,S2,S3,S4;
 
   datetime cDay = iTime(NULL,PERIOD_D1,0) + (GMT-Period()/60.0)*3600;
   if (cDay != prevDay || fTime) 
   {
   ObjDel();
   ArrayResize(start_time,CountDays);
   ArrayResize(ny_shift,CountDays);
   ArrayResize(high,CountDays);
   ArrayResize(low,CountDays);
   ArrayResize(range,CountDays);   
      for (shift=0;shift<=CountDays;shift++)
      {
      start_time[shift]  = iTime(NULL,PERIOD_D1,shift) + (GMT-Period()/60.0)*3600;
      ny_shift[shift] = iBarShift(NULL,0,start_time[shift]);
      timeshift[shift] = iClose(NULL,0,ny_shift[shift]);
       
      }
     
      for (shift=0;shift<=CountDays-1;shift++)
      {
      int length = ny_shift[shift+1]-ny_shift[shift];
   
      high[shift] = High[iHighest(NULL,0,MODE_HIGH,length,ny_shift[shift])];
      low[shift]  = Low[iLowest(NULL,0,MODE_LOW,length,ny_shift[shift])];
      range[shift] = high[shift] - low[shift];
      }
 
      for (shift=0;shift<=CountDays-1;shift++)
      {
 
      if(DayOfWeek()==0){ P  = (timeshift[shift+1]+high[shift+1]+low[shift+1])/3;}else{     
      P  = (timeshift[shift]+high[shift]+low[shift])/3;}

      if(Show_Open){
      P=timeshift[shift];
      }else{P  = (timeshift[shift]+high[shift]+low[shift])/3;}
     
           
      double UP = P+ Level_1*myPoint;
      double DN = P- Level_1*myPoint;
      double UP1 = P+ Level_2*myPoint;
      double DN1 = P- Level_2*myPoint;
      double UP2 = P+ Level_3*myPoint;
      double DN2 = P- Level_3*myPoint; 
 
      time1 = start_time[shift]+Period()*60;   
         
         if (shift==0)
         {
         time2 = start_time[shift] + 24*3600+Period()*60 ;
       
         if(Show_Open){
         Plottext("textP"+magic,"        Open",Fontsize,Font,P,Open_Pivot_Color);
         }else{Plottext("textP"+magic,"        Pivot",Fontsize,Font,P,Open_Pivot_Color);}
       
         PlotPrice("op"+magic,P,Open_Pivot_Color);
         PlotPrice("up1"+magic,UP,Upper_Color);
         PlotPrice("up2"+magic,UP1,Upper_Color);
         PlotPrice("up3"+magic,UP2,Upper_Color);
         PlotPrice("dn1"+magic,DN,Lower_Color);
         PlotPrice("dn2"+magic,DN1,Lower_Color);
         PlotPrice("dn3"+magic,DN2,Lower_Color);
                     
         }
         else
         time2 = start_time[shift-1]+Period()*60;
   
   PlotLine("OP["+shift+"]"+magic,P,P,Open_Pivot_Color,0,Open_Pivot_width);
   
   PlotLine("UP1["+shift+"]"+magic,UP,UP,Upper_Color,Line_style,0);
   PlotLine("UP2["+shift+"]"+magic,UP1,UP1,Upper_Color,Line_style,0);
   PlotLine("UP3["+shift+"]"+magic,UP2,UP2,Upper_Color,Line_style,0);
   
   PlotLine("DN1["+shift+"]"+magic,DN,DN,Lower_Color,Line_style,0);
   PlotLine("DN2["+shift+"]"+magic,DN1,DN1,Lower_Color,Line_style,0);
   PlotLine("DN3["+shift+"]"+magic,DN2,DN2,Lower_Color,Line_style,0);
 
}
   fTime = false;
   prevDay = cDay;
   }     
       
   return(0);
}
//+------------------------------------------------------------------+[quote][/quote

one more indicator that i need
Code: Select all
//+------------------------------------------------------------------+
//|                                                 SessionHours.mq4 |
//|                                  Copyright © 2009, Cristian Dima |
//|                                  *translated in english - Scrat  |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2009, Cristian Dima"
#property link      ""

#property indicator_chart_window
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+

extern string ore="--GMT Session hours--";
//Opening and closing hours of London session. For closing time, use previous bar: if London closes @ 19.00, then use 18.
extern string a="--London hours--";
extern int loh=10; //
extern int lch=18; //

/*same instructions for NY */
extern string d="--New York hours--";
extern int nyoh=15;
extern int nych=23;

/*same instructions for Tokyo */
extern string c="--Tokyo hours--";
extern int tkoh=3;
extern int tkch=11;


extern string b="--------London-------";
extern bool  ShowLondon = true;
extern int   LondonSessionsNumber=2;
extern bool  ShowLondonOpen = true;
extern bool  ShowLondonClose = true;
extern bool  ShowLondonVerticalLines=false;
extern int   LondonWidth = 1;
extern color LondonColor = Blue;






extern string b2="--------New York-------";
extern bool  ShowNY = true;
extern int   NYsessionsNumber=2;
extern bool  ShowNYOpen = true;
extern bool  ShowNYClose = true;
extern bool  ShowNYverticalLines=true;
extern int   NYWidth = 1;
extern color NYColor = DarkViolet;





extern string b3="--------Tokio-------";
extern bool  ShowTK = true;
extern int   TKsessionsNumber=2;
extern bool  ShowTKOpen = true;
extern bool  ShowTKClose = true;
extern bool  ShowTKverticalLines=false;
extern int   TKWidth = 1;
extern color TKColor = Green;



 
int init()
  {
//---- indicators


//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   refresh();
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
 
if(NewBar()==true)
   refresh(); 
 
 
 
 
   int    counted_bars=IndicatorCounted();
   int    k,t,l,lshift,ny,nyshift,tk,tkshift;
   datetime nytime2;
//----
   int i=Bars;
   int p=0;
   
   l=0;
   lshift=0;
   ny=0;
   nyshift=0;
   tk=0;
   tkshift=0;
   p=0;
   
   while(p<Bars)
   {
      if(TimeHour(Time[p])==loh && TimeMinute(Time[p])<1)
            l++;
          if(l==LondonSessionsNumber)
                  {
                  lshift=p;
                  break;
                  }
                  lshift=p;                         
   p++;
   }
   
   p=0;
      while(p<Bars)
      {                 
             if(TimeHour(Time[p])==nyoh && TimeMinute(Time[p])<1)
               ny++;   
                 if(ny==NYsessionsNumber)
                 {
                  nyshift=p;
                  break;
                  }
                  nyshift=p;
      p++;
      }   
                 
   p=0;
               while(p<Bars)
               {
                  if(TimeHour(Time[p])==tkoh && TimeMinute(Time[p])<1)
                     tk++;   
                     if(tk==TKsessionsNumber)
                        {
                        tkshift=p;       
                        break;
                        }
                        tkshift=p;
                   p++;     
               }   

   
   
   if(Period()>=60)
         k=1;
      else if(Period()==30)
            k=2;
         else if(Period()==15)     
               k=4;
            else if(Period()==5)
                  k=12;
               else if(Period()==1)
                     k=60;
                     
if(Period()>60)
   { 
      refresh();
      return(0);
   }                     
                     


   int h=MathAbs(lch-loh)*k;

   int h2=MathAbs(nych-nyoh)*k;

   int h3=MathAbs(tkch-tkoh)*k;
   
   int f=k-1;
   
   while(lshift>=0)
   {
   
      if(ShowLondon)
      {   

         if(TimeHour(Time[lshift])==loh && TimeMinute(Time[lshift])<1)
         {
            if(ShowLondonOpen)
            {
            if(ShowLondonVerticalLines)
               { 
            string name="Lopen"+DoubleToStr(lshift,2);
            ObjectCreate(name, OBJ_VLINE, 0,Time[lshift],0);
            ObjectSet(name,6,LondonColor);
            ObjectSet(name,7,STYLE_DOT);
               }
     
            string name3="Lopenp"+DoubleToStr(lshift,4);
            if(lshift-24*k<0)
            datetime ltime=Time[0];
            else ltime=Time[lshift-24*k];
            ObjectCreate(name3, OBJ_TREND, 0,Time[lshift],Open[lshift],ltime,Open[lshift]);
            ObjectSet(name3,6,LondonColor);
            ObjectSet(name3,7,STYLE_SOLID);
            ObjectSet(name3,10,false);
            ObjectSet(name3,8,LondonWidth);
            }
               if(ShowLondonClose)
               {
                  if(ShowLondonVerticalLines)
                  {     
               string name2="Lclose"+DoubleToStr(lshift,2);
               ObjectCreate(name2, OBJ_VLINE, 0,Time[lshift-h-f],0);
               ObjectSet(name2,6,LondonColor);
               ObjectSet(name2,7,STYLE_DOT);
                  }
               }     
      }
         

if(ShowLondonClose)
 {     
   if(TimeHour(Time[lshift])==lch+1 && TimeMinute(Time[lshift])<1)
      { 
      string name10="Lclosep"+DoubleToStr(lshift,4);
      if(lshift+1-24*k<0)
      datetime ltime2=Time[0];
      else ltime2=Time[lshift+1-24*k];
      ObjectCreate(name10, OBJ_TREND, 0,Time[lshift+1],Close[lshift+1],ltime2,Close[lshift+1]);
      ObjectSet(name10,6,LondonColor);
      ObjectSet(name10,7,STYLE_SOLID);
      ObjectSet(name10,10,false);
      ObjectSet(name10,8,LondonWidth);
     
      }
 }
}
lshift--;     
}   
   
   
while(nyshift>=0)
{     
if(ShowNY)
{     
   if(TimeHour(Time[nyshift])==nyoh && TimeMinute(Time[nyshift])<1)
     {
      if(ShowNYOpen)
         {
            if(ShowNYverticalLines)
            {
      string name4="NYopen"+DoubleToStr(nyshift,2);
      ObjectCreate(name4, OBJ_VLINE, 0,Time[nyshift],0);
      ObjectSet(name4,6,NYColor);
      ObjectSet(name4,7,STYLE_DOT);
            }
      string name6="NYopenp"+DoubleToStr(nyshift,4);
      if(nyshift-24*k<0)
      datetime nytime=Time[0];
      else nytime=Time[nyshift-24*k];
      ObjectCreate(name6, OBJ_TREND, 0,Time[nyshift],Open[nyshift],nytime,Open[nyshift]);
      ObjectSet(name6,6,NYColor);
      ObjectSet(name6,7,STYLE_SOLID);
      ObjectSet(name6,10,false);
      ObjectSet(name6,8,NYWidth);     
         }
     
      if(ShowNYClose)
      {
         if(ShowNYverticalLines)
         {
      string name5="NYclose"+DoubleToStr(nyshift,2);
      ObjectCreate(name5, OBJ_VLINE, 0,Time[nyshift-h2-f],0);
      ObjectSet(name5,6,NYColor);
      ObjectSet(name5,7,STYLE_DOT);
         }
      }
     }   
      if(ShowNYClose)
    {
   if(TimeHour(Time[nyshift])==nych+1 && TimeMinute(Time[nyshift])<1)
      {   
      string name11="NYclosep"+DoubleToStr(nyshift,4);
      if(nyshift-24*k<0)
      nytime2=Time[0];
      else nytime2=Time[nyshift-24*k];
      ObjectCreate(name11, OBJ_TREND, 0,Time[nyshift+1],Close[nyshift+1],nytime2,Close[nyshift+1]);
      ObjectSet(name11,6,NYColor);
      ObjectSet(name11,7,STYLE_SOLID);
      ObjectSet(name11,10,false);
      ObjectSet(name11,8,NYWidth);
         
      }
   }
}
nyshift--;
}



while(tkshift>=0)
{
if(ShowLondon==false || ShowLondonOpen==false || lch!=tkoh)
      t=0;
     else t=1;
if(ShowTK)
{         
   if(TimeHour(Time[tkshift])==tkoh && TimeMinute(Time[tkshift])<1)
     {
      if(ShowTKOpen)
         {
            if(ShowTKverticalLines)
            {
      string name7="TKopen"+DoubleToStr(tkshift,2);
      ObjectCreate(name7, OBJ_VLINE, 0,Time[tkshift],0);
      ObjectSet(name7,6,TKColor);
      ObjectSet(name7,7,STYLE_DOT);
            }
      string name9="TKopenp"+DoubleToStr(tkshift,4);
      if(tkshift-24*k<0)
      datetime tktime=Time[0];
      else tktime=Time[tkshift-24*k];
      ObjectCreate(name9, OBJ_TREND, 0,Time[tkshift],Open[tkshift],tktime,Open[tkshift]);
      ObjectSet(name9,6,TKColor);
      ObjectSet(name9,7,STYLE_SOLID);
      ObjectSet(name9,10,false);
      ObjectSet(name9,8,TKWidth);     
         }
     
      if(ShowTKClose)
         {
            if(ShowTKverticalLines)
            {
      string name8="TKclose"+DoubleToStr(tkshift,2);
      ObjectCreate(name8, OBJ_VLINE, 0,Time[tkshift-h3-t-f],0);
      ObjectSet(name8,6,TKColor);
      ObjectSet(name8,7,STYLE_DOT);
            }
         }
     }   
     
      if(ShowTKClose)
      {   
   if(TimeHour(Time[tkshift])==tkch+1 && TimeMinute(Time[tkshift])<1)
         {   
      string name12="TKclosep"+DoubleToStr(tkshift,4);
      if(tkshift+1-24*k<0)
      datetime tktime2=Time[0];
      else tktime2=Time[tkshift+1-24*k];
      ObjectCreate(name12, OBJ_TREND, 0,Time[tkshift+1],Close[tkshift+1],tktime2,Close[tkshift+1]);
      ObjectSet(name12,6,TKColor);
      ObjectSet(name12,7,STYLE_SOLID);
      ObjectSet(name12,10,false);
      ObjectSet(name12,8,TKWidth);     
         
         }
      }
}
tkshift--;     
}   
   
   
   
   
     

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


int refresh()
  {
//----


   int i=Bars;
   
      while(i>=0)
   {
   if(TimeHour(Time[i])==loh)
      {
      string name="Lopen"+DoubleToStr(i,2);
      string name2="Lclose"+DoubleToStr(i,2);
      string name3="Lopenp"+DoubleToStr(i,4);
      ObjectDelete(name2);
      ObjectDelete(name);
      ObjectDelete(name3);
     
     

      }
   if(TimeHour(Time[i])==nyoh)
      {
     
      string name4="NYopen"+DoubleToStr(i,2);
      string name5="NYclose"+DoubleToStr(i,2);
      string name6="NYopenp"+DoubleToStr(i,4);
      ObjectDelete(name4);
      ObjectDelete(name5);
      ObjectDelete(name6);
     
      }
     
   if(TimeHour(Time[i])==tkoh)
      {
     
      string name7="TKopen"+DoubleToStr(i,2);
      string name8="TKclose"+DoubleToStr(i,2);
      string name9="TKopenp"+DoubleToStr(i,4);
      ObjectDelete(name7);
      ObjectDelete(name8);
      ObjectDelete(name9);
     
      }   
   if(TimeHour(Time[i])==lch+1)
      {     
            string name10="Lclosep"+DoubleToStr(i,4);
            ObjectDelete(name10);
            }
   if(TimeHour(Time[i])==nych+1)
      { 
             string name11="NYclosep"+DoubleToStr(i,4);
             ObjectDelete(name11);
             }           
   if(TimeHour(Time[i])==tkch+1)
      {
      string name12="TKclosep"+DoubleToStr(i,4);
      ObjectDelete(name12);
      }       
      i--;
      }
//----

  }
 
bool NewBar()
   {   
      static datetime lastbar = 0;
      datetime curbar = Time[0];   
         if(lastbar!=curbar)   
            {     
               lastbar=curbar;     
               return (true);   
                  }   
               else   
                     {     
                      return(false);   
                        }
               }



pls help me .thank you
tulasi
 
Posts: 5
Joined: Thu Sep 23, 2010 10:39 am



Return to Indicator and Signal Requests

Who is online

Users browsing this forum: Google [Bot] and 19 guests