Navigation´╝ÜHome > Content >

4HR_Weekly_GJ_Ron_V01a.mq4

Time: 2010-03-13 | Download file:4HR_Weekly_GJ_Ron_V01a.mq4

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

#property copyright "Ron Thompson"
#property link      "http://www.ForexMT4.com/"

// This INDICATOR is NEVER TO BE SOLD individually 
// This INDICATOR is NEVER TO BE INCLUDED as part of a collection that is SOLD

//User Input
extern int HiLoBufferAdd   =   20;


// Bar handling
datetime      bartime=0;                            // used to determine when a bar has moved

// Objects
int     uniq=0;
string Object_ID = "DIBS";

//Point
double myPoint;


#property indicator_chart_window
#property indicator_buffers 8


#property indicator_color1 White
#property indicator_width1 3

#property indicator_color2 Red
#property indicator_width2 3

#property indicator_color3 MediumSeaGreen
#property indicator_width3 1

#property indicator_color4 MediumSeaGreen
#property indicator_width4 1

#property indicator_color5 MediumSeaGreen
#property indicator_width5 1

#property indicator_color6 White
#property indicator_width6 3

#property indicator_color7 LimeGreen
#property indicator_width7 3

#property indicator_color8 Red
#property indicator_width8 3



//---- buffers
int       mybars=10000;
double    i0[];
double    i1[];
double    i2[];
double    i3[];
double    i4[];
double    i5[];
double    i6[];
double    i7[];


//+----------------+
//| Custom init    |
//+----------------+
int init()
  {
   // 233 up arrow
   // 234 down arrow
   // 159 big dot
   // 158 little dot
   // 168 open square
   // 120 box with X
     
   IndicatorBuffers(8);
   
   SetIndexStyle(0,DRAW_ARROW); //i0
   SetIndexArrow(0,120);
   SetIndexBuffer(0,i0);
   
   SetIndexStyle(1,DRAW_ARROW); //i1
   SetIndexArrow(1,120);
   SetIndexBuffer(1,i1);

   SetIndexStyle(2,DRAW_LINE); //i2
   //SetIndexArrow(2,158);
   SetIndexBuffer(2,i2);

   SetIndexStyle(3,DRAW_LINE); //i3
   //SetIndexArrow(3,158);
   SetIndexBuffer(3,i3);

   SetIndexStyle(4,DRAW_LINE); //i4
   //SetIndexArrow(4,168);
   SetIndexBuffer(4,i4);

   SetIndexStyle(5,DRAW_ARROW); //i5
   SetIndexArrow(5,168);
   SetIndexBuffer(5,i5);

   SetIndexStyle(6,DRAW_ARROW); //i6
   SetIndexArrow(6,168);
   SetIndexBuffer(6,i6);

   SetIndexStyle(7,DRAW_ARROW); //i7
   SetIndexArrow(7,168);
   SetIndexBuffer(7,i7);

   ObjectsDeleteAll();

   myPoint = SetPoint();

  }

  
//+----------------+
//| Custom DE-init |
//+----------------+
int deinit()
  {
   ObjectsDeleteAll();

   Print("DE-Init happened ",CurTime());
   Comment(" ");
  }

  
//+------+
//| Main |
//+------+
int start()
  {   
   
   int i;
   double h;
   double l;
   datetime t;
   double o;
   double pl;
   int b;
   
   if(bartime==iTime(Symbol(), 0, 0) ) return(0);
   bartime=iTime(Symbol(), 0, 0) ;

   myObjectsDeleteAll();
   
   for (i=Bars; i>=0; i--) 
     { 
      //offset
      o=(HiLoBufferAdd*myPoint)+(Ask-Bid);
      //time 
      t=iTime(Symbol(),0,i);
      //high 
      h=iHigh(Symbol(),0,i)+o;
      //low
      l= iLow(Symbol(),0,i)-o;
      //profit loss lines
      pl=h-l;   
      
      //calculate remaining bars 
      if(i>24)
        {
         b=24;
        }
       else
        {
         b=i;
        }
        
      if( TimeHour(t)==0 && TimeDayOfWeek(t)==1 )
        {
         DrawLine( Object_ID + "H"  + DoubleToStr(t, 0), t, iTime(Symbol(),0,i-b), h,        h,        White, STYLE_SOLID );
         DrawLine( Object_ID + "H1" + DoubleToStr(t, 0), t, iTime(Symbol(),0,i-b), h+(pl*1), h+(pl*1), Lime, STYLE_SOLID );
         DrawLine( Object_ID + "H2" + DoubleToStr(t, 0), t, iTime(Symbol(),0,i-b), h+(pl*2), h+(pl*2), Lime, STYLE_SOLID );
         DrawLine( Object_ID + "H3" + DoubleToStr(t, 0), t, iTime(Symbol(),0,i-b), h+(pl*3), h+(pl*3), Lime, STYLE_SOLID );
        
         DrawLine( Object_ID + "L"  + DoubleToStr(t, 0), t, iTime(Symbol(),0,i-b), l,        l,          Red, STYLE_SOLID );
         DrawLine( Object_ID + "L1" + DoubleToStr(t, 0), t, iTime(Symbol(),0,i-b), l-(pl*1), l-(pl*1),   Lime, STYLE_SOLID );
         DrawLine( Object_ID + "L2" + DoubleToStr(t, 0), t, iTime(Symbol(),0,i-b), l-(pl*2), l-(pl*2),   Lime, STYLE_SOLID );
         DrawLine( Object_ID + "L3" + DoubleToStr(t, 0), t, iTime(Symbol(),0,i-b), l-(pl*3), l-(pl*3),   Lime, STYLE_SOLID );

         DrawRisk( t, l+((h-l)/2), (h-l)/myPoint   ) ;
        }

     }//for
 
  }//start
  


void DrawLine(string lbl, datetime x1, datetime x2, double y1, double y2, color lineColor, double style)
  {
   ObjectDelete(lbl);
   ObjectCreate(lbl, OBJ_TREND, 0, x1, y1, x2, y2, 0, 0);
   ObjectSet(lbl, OBJPROP_RAY, 0);
   ObjectSet(lbl, OBJPROP_COLOR, lineColor);
   ObjectSet(lbl, OBJPROP_STYLE, style);
   ObjectSet(lbl, OBJPROP_WIDTH, 3);
  }

void DrawRisk( datetime x1, double y1, double risk )
  {
   string labelr = "DIBSR" + DoubleToStr(x1, 0);
   ObjectCreate (labelr, OBJ_TEXT, 0, x1, y1 );
   ObjectSetText(labelr, DoubleToStr(risk, 0),16,"Arial",Aqua);
  }



double SetPoint()
  {
   double mPoint;
   
   if (Digits < 4)
      mPoint = 0.01;
   else
      mPoint = 0.0001;
   
   return(mPoint);
  }



void myObjectsDeleteAll()
{
   int obj = ObjectsTotal(OBJ_TEXT);
   int i, limit;
   string objName;
   
   if (obj > 0)
   {
      for (i = obj; i >= 0;i--)
      {
         objName = ObjectName(i);
         if (StringFind(objName,Object_ID, 0) >= 0) ObjectDelete(objName);
      }
 
   }
   
}

Recommend