Navigation:Home > Content >

Bid_View1.5.mq4

Time: 2012-01-22 | Download file:Bid_View1.5.mq4

//+------------------------------------------------------------------+
//|                                               BID_VIEW.mq4       |
//|                                      Copyright © 2008, "OTCFX"   |
//|                                             Revision 1.6         |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2008 OTCFX"
#property indicator_separate_window  

  
  extern bool   Bid_Colors = True; 
  extern string FontType=" Sans MS";
  extern color ColorHeading =  Gainsboro ;
  extern color ColorValue = CadetBlue ;  
  extern int  TimeFrame  = 1440;
  extern  int    Trend_Bars = 10;
  extern bool show.Trend = true ;
  extern int price.x.offset= 50;
  extern int price.y.offset= 10;     
  color  ColorPrice = CadetBlue; 
  int MAP =1;
  int Spread;
  int Local_Time;
  string   labelNames;
  string   shortName;
  int      corner;
  int      totalLabels;
  int      window;    
  int nDigits;
  int pZX;
  int PTL;
  double       O_P;
  double       O_P1;
  double       O_P2;
  int    F_Offset=0;

  
    
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+  
   
int init()
  {

   corner     = 0;
   shortName  = MakeUniqueName("BT ","");
   labelNames = shortName;
   IndicatorShortName(shortName);
    
   string S = Symbol();
     
   if(S=="GBPJPY" ||S=="EURJPY" || S=="USDJPY" || S=="GOLD" )nDigits = 2;   
   if(S=="GBPUSD" || S=="EURUSD" ||S=="NZDUSD" || S=="USDCHF"  ||
   S=="USDCAD" ||S=="AUDUSD" || S=="EURUSD" ||S=="EURCHF"  || S=="EURGBP"
   || S=="EURCAD" ||S=="EURAUD" || S=="AUDNZD")nDigits = 4;
      
  int result;

   if (TimeFrame == 0) 
      result = Period();   
   else
   {
  switch(TimeFrame) 
      {
         case 1    : result = PERIOD_M1;  break; 
         case 5    : result = PERIOD_M5;  break;
         case 15   : result = PERIOD_M15; break;
         case 30   : result = PERIOD_M30; break;
         case 60   : result = PERIOD_H1;  break;
         case 240  : result = PERIOD_H4;  break;
         case 1440 : result = PERIOD_D1;  break;
         case 7200 : result = PERIOD_W1;  break;
         case 28800: result = PERIOD_MN1; break;
         default  : result = Period(); break; 
      }
   }
   return(result);
}

int deinit() 
{ 
   while (totalLabels>0) { ObjectDelete(StringConcatenate(labelNames,totalLabels)); totalLabels--;}
   return(0);  
}  

        
 //+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+ 

int start()
  {
   
 window = WindowFind(shortName);   
  ObjectsDeleteAll( window, 21);
  ObjectsDeleteAll( window, 22);
  ObjectsDeleteAll( window, 23);
   
  int i=0;
  int R77=0,CD=0,AM=0;
  double HD,DL,BTX1,BTX1_1,BTX2,BTX2_2,BTX3,BTX3_3,BTX4,BTX4_4,BTX5,BTX5_5;
  double BTX6,BTX6_6,BTX7,BTX7_7,BTX8,BTX8_8,BTX9,BTX9_9,BTX10,BTX10_10,DC,DO;
  double PercentUp,Perc,Per;
  string FX_T="Verdana Bold";
  string T= TimeFrame;
  if (TimeFrame==0) TimeFrame=Period();
  int yPos = 24, xPos = 10;
  int xSpacer = 140;
  string SpacerText1 = "__________________________";
  string SpacerText2 = "__________________________________________________________________________________________________________";
  if(F_Offset>0) F_Offset=0;
  if(Trend_Bars>15) Trend_Bars=15;
  if(price.y.offset<10) price.y.offset=10;   
  if(price.y.offset>20) price.y.offset=20; 
  string S = Symbol();
   
  if(S=="GBPJPY" ||S=="EURJPY" || S=="USDJPY" || S=="GOLD" || S=="ES"|| S=="FGBL") {pZX = 100000;} else{pZX = 1000;} 
  if(S=="FTSE" ||S=="FDAX" || S=="FESX" || S=="YM"){PTL = 1;} else {PTL = 100;}
    
   R77 =(iClose(NULL,PERIOD_D1,0)-iOpen(NULL,PERIOD_D1,0))/Point;     
   DO  =  iOpen(NULL,PERIOD_D1,0);
   DC =iClose(NULL,PERIOD_D1,0);
   HD = iHigh(NULL,PERIOD_D1,0);
   DL = iLow(NULL,PERIOD_D1,0);
   //open0  =  iOpen(NULL,PERIOD_D1,0);
   PercentUp = ((R77)/(DC))/100;    
   Per = PercentUp*pZX; 
   Perc  = Per/1000;
   Spread=NormalizeDouble((Ask-Bid)/Point,0);   
   if(Spread<0) Spread=0;
    
   if (Bid_Colors == True)
   {
    if (Close[i] > O_P) ColorPrice = DodgerBlue;
    if (Close[i] < O_P) ColorPrice = LightGray;
    O_P = Close[i];
   }   
   color ColorCT709;
   if( Close[i]  < O_P2 ) { ColorCT709 =Red;} 
   O_P2 = Close[i];
    
   color ColorCT708;
   if( Close[i]  > O_P1  ) { ColorCT708 =Lime;} 
   O_P1 = Close[i]; 
     
   string Market_Price = DoubleToStr(Close[i], Digits);
   
   color ColorCH704 ;  
   if(R77 >= 0 ) { ColorCH704 =LimeGreen ; } 
    color ColorCH705 ;  
   if(R77 < 0 ) { ColorCH705 =Red ; }
   
 
 
///////ARROWS>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
  
   setObject(next(),"^",115+price.x.offset, 2+price.y.offset,ColorCT708 ,"Arial Bold",20+F_Offset,0);
   setObject(next(),"^",127+price.x.offset, 32+price.y.offset,ColorCT709 ,"Arial Bold",20+F_Offset,180);
   setObject(next(),"^",227+price.x.offset, 2+price.y.offset,ColorCH704 ,"Arial Bold",18+F_Offset,0);//
   setObject(next(),"^",240+price.x.offset, 32+price.y.offset,ColorCH705 ,"Arial Bold",18+F_Offset,180);//
   
//////// Value inputs>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
  
   setObject(next(),Market_Price ,140+price.x.offset, 5+price.y.offset,ColorPrice ,FX_T,16+F_Offset);  
   setObject(next(),StringSubstr(Symbol(),0),22+price.x.offset, 5+price.y.offset,ColorValue ,FX_T,13+F_Offset);
   setObject(next(),DoubleToStr(DO ,Digits),383+price.x.offset, 5+price.y.offset,ColorValue ,FX_T,13+F_Offset);
   setObject(next(),DoubleToStr(HD ,Digits),472+price.x.offset, 5+price.y.offset,ColorValue ,FX_T,13+F_Offset);
   setObject(next(),DoubleToStr(DL ,Digits),555+price.x.offset, 5+price.y.offset,ColorValue ,FX_T,13+F_Offset);
   setObject(next(),DoubleToStr(R77 ,0),247+price.x.offset, 5+price.y.offset,ColorValue ,FX_T,13+F_Offset);
   setObject(next(),TimeToStr(CurTime(),TIME_SECONDS),777+price.x.offset, 5+price.y.offset,ColorValue ,FX_T,13+F_Offset);
   setObject(next(),TimeToStr(LocalTime(),TIME_MINUTES),880+price.x.offset, 5+price.y.offset,ColorValue ,FX_T,13+F_Offset);
   setObject(next(),DoubleToStr(Spread ,Digits-3),970+price.x.offset, 5+price.y.offset,ColorValue ,FX_T,13+F_Offset);
   setObject(next(),DoubleToStr(Perc ,nDigits),300+price.x.offset, 5+price.y.offset,ColorValue ,FX_T,13+F_Offset);
   
   
///>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>   
      
   //HEADINGS>>>>>
   
  setObject(next(),"Name",45+price.x.offset, -10+price.y.offset,ColorHeading ,FX_T,9+F_Offset);
  setObject(next(),"Last",157+price.x.offset, -10+price.y.offset,ColorHeading ,FX_T,9+F_Offset);
  setObject(next(),"Change",237+price.x.offset, -10+price.y.offset,ColorHeading ,FX_T,9+F_Offset);  
  setObject(next(),"%CH",317+price.x.offset, -10+price.y.offset,ColorHeading ,FX_T,9+F_Offset);  
  setObject(next(),"Open",398+price.x.offset, -10+price.y.offset,ColorHeading ,FX_T,9+F_Offset);  
  setObject(next(),"High",484+price.x.offset, -10+price.y.offset,ColorHeading ,FX_T,9+F_Offset);  
  setObject(next(),"Low",571+price.x.offset, -10+price.y.offset,ColorHeading ,FX_T,9+F_Offset);
  setObject(next(),"BidTime",795+price.x.offset, -10+price.y.offset,ColorHeading ,FX_T,9+F_Offset);
  setObject(next(),"LocalTime",880+price.x.offset, -10+price.y.offset,ColorHeading ,FX_T,9+F_Offset);
  setObject(next(),"Spread",970+price.x.offset, -10+price.y.offset,ColorHeading ,FX_T,9+F_Offset);
  setObject(next(),"1",630+price.x.offset, -10+price.y.offset,ColorHeading ,"Verdana",8+F_Offset);
  setObject(next(),DoubleToStr(Trend_Bars ,0),755+price.x.offset, -10+price.y.offset,ColorHeading ,"Verdana",8+F_Offset);
  
  setObject(next(),"Trend",695+price.x.offset, -10+price.y.offset,ColorHeading ,FX_T,9+F_Offset);
  setObject(next(),StringSubstr((T),0),655+price.x.offset, -10+price.y.offset,ColorHeading ,FX_T,9+F_Offset);
  
/////BORDERS>>>>>>>>>>>>>>>>>>>>

  setObject(next(),SpacerText1,88+price.x.offset, 30+price.y.offset,DarkGray ,FX_T,17+F_Offset,90);  
  setObject(next(),SpacerText1,199+price.x.offset, 30+price.y.offset,DarkGray ,FX_T,17+F_Offset,90);
  setObject(next(),SpacerText1,270+price.x.offset, 30+price.y.offset,DarkGray ,FX_T,17+F_Offset,90);
  setObject(next(),SpacerText1,350+price.x.offset, 30+price.y.offset,DarkGray ,FX_T,17+F_Offset,90);
  setObject(next(),SpacerText1,430+price.x.offset, 30+price.y.offset,DarkGray ,FX_T,17+F_Offset,90);
  setObject(next(),SpacerText1,520+price.x.offset, 30+price.y.offset,DarkGray ,FX_T,17+F_Offset,90);
  setObject(next(),SpacerText1,600+price.x.offset, 30+price.y.offset,DarkGray ,FX_T,17+F_Offset,90);
  setObject(next(),SpacerText1,745+price.x.offset, 30+price.y.offset,DarkGray ,FX_T,17+F_Offset,90);
  setObject(next(),SpacerText1,840+price.x.offset, 30+price.y.offset,DarkGray ,FX_T,17+F_Offset,90);
  setObject(next(),SpacerText1,930+price.x.offset, 30+price.y.offset,DarkGray ,FX_T,17+F_Offset,90);
  setObject(next(),SpacerText1,1002+price.x.offset, 30+price.y.offset,DarkGray ,FX_T,17+F_Offset,90);
  setObject(next(),SpacerText1,-25+price.x.offset, 30+price.y.offset,DarkGray ,FX_T,17+F_Offset,90);
  
 /////////LINES>>>>>>>>>>>>>>>> 
  
  setObject(next(),SpacerText2,0+price.x.offset,   -5+price.y.offset,  DarkGray ,FX_T,6+F_Offset);
  setObject(next(),SpacerText2,250+price.x.offset, -5+price.y.offset,DarkGray ,FX_T,6+F_Offset);
  setObject(next(),SpacerText2,450+price.x.offset, -5+price.y.offset,DarkGray ,FX_T,6+F_Offset);
  setObject(next(),SpacerText2,650+price.x.offset, -5+price.y.offset,DarkGray ,FX_T,6+F_Offset);
  
  setObject(next(),SpacerText2,650+price.x.offset, 21+price.y.offset,DarkGray ,FX_T,6+F_Offset);
  setObject(next(),SpacerText2,380+price.x.offset, 21+price.y.offset,DarkGray ,FX_T,6+F_Offset);
  setObject(next(),SpacerText2,100+price.x.offset, 21+price.y.offset,DarkGray ,FX_T,6+F_Offset);
  setObject(next(),SpacerText1,0+price.x.offset, 21+price.y.offset,DarkGray ,FX_T,6+F_Offset);
  
 ////BIDTREND>>>>>>>>>>>>>>>>>>>>>>>>>
 
   //if(show.Trend){
   color LabelColor;     
   int SpX = 615, SpX2=7;
   for(i=0;i<=Trend_Bars;i++)
   {
      BTX1 =iMA(S, TimeFrame,MAP,0,1,1,i);
      BTX1_1 =iMA(S, TimeFrame,MAP,0,0,0,i);       
       
      LabelColor =Red;
      if(BTX1_1 > BTX1) LabelColor =Lime;
      SpX = SpX+ SpX2;
      if(show.Trend){
      setObject(next(),"-",SpX+price.x.offset, 25+price.y.offset,LabelColor ,FX_T,30,90);}
   }   
      
   
  return(0);
  }


string next() { totalLabels++; return(totalLabels); }  

string MakeUniqueName(string first, string rest)
{
   string result = first+(MathRand()%1001)+rest;

   while (WindowFind(result)> 0)
          result = first+(MathRand()%1001)+rest;
   return(result);
}

void setObject(string name,string text,int x,int y,color theColor, string font = "Arial",int size=10,int angle=0)
{
   string labelName = StringConcatenate(labelNames,name);

      if (ObjectFind(labelName) == -1)
          {
             ObjectCreate(labelName,OBJ_LABEL,window,0,0);
             ObjectSet(labelName,OBJPROP_CORNER,corner);
             if (angle != 0)
                  ObjectSet(labelName,OBJPROP_ANGLE,angle);
          }               
       ObjectSet(labelName,OBJPROP_XDISTANCE,x);
       ObjectSet(labelName,OBJPROP_YDISTANCE,y);
       ObjectSetText(labelName,text,size,font,theColor);

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

Recommend