help drawing this rectangle

 

Hi Everyone,


Please help me draw this. This is intended for my EA and not as an indicator. Not sure why it is not drawing.. I just want for there to be a box which starts at hour 1 of the day and ends at hour 5. LineA and LineB will be the high and low of the first 5 hours of the day.


Thanks in advance!


extern int StartHours = 6;

void start();
      {
         if(iVolume(NULL,PERIOD_H1,0)>1) return;
         if(Hour() == 0)LineA = 0;
         if(Hour() == 0)LineB = 500;
         if(Hour() <= StartHours && Hour() > 1 && iHigh(NULL, 0, 1) > LineA) LineA =iHigh(NULL, 0, 1);
         if(Hour() <= StartHours && Hour() > 1 && iLow(NULL, 0, 1) < LineB)LineB = iLow(NULL,0,1);
         if(Hour() == 1) {dtTimeBegin = TimeCurrent(); dtTimeObjEnd = TimeCurrent(); }
         if(Hour() <= StartHours && Hour() > 1)dtTimeObjEnd = TimeCurrent() ;

Draw();
      }

void Draw()
{

if(Hour() <=StartHours && Hour() != 0) return;
if(TimeCurrent() < dtTimeBegin)dtTimeBegin = TimeCurrent();
if(TimeCurrent() > dtTimeObjEnd)dtTimeObjEnd = TimeCurrent();

ObjectCreate(DayOfYear(), OBJ_RECTANGLE, 0, 0, 0, 0, 0);
ObjectSet(DayOfYear(), LineA , dtTimeBegin);
ObjectSet(DayOfYear(), LineB , dtTimeObjEnd);   
}
 
heyarn:

Hi Everyone,


Please help me draw this. This is intended for my EA and not as an indicator. Not sure why it is not drawing.. I just want for there to be a box which starts at hour 1 of the day and ends at hour 5. LineA and LineB will be the high and low of the first 5 hours of the day.


Thanks in advance!





Someone please help :)
 

try this

extern string ScanStartTime = "01:00";
extern string   ScanEndTime = "05:00";
extern color       BoxColor = Yellow;

#define BOX "heyarnBox"

void deinit() {
  ObjectDelete(BOX);
}

void start() {
  datetime t         = TimeCurrent(),
           tBoxLeft  = StrToTime(TimeToStr(t, TIME_DATE) + " " + ScanStartTime),
           tBoxRight = StrToTime(TimeToStr(t, TIME_DATE) + " " + ScanEndTime);
  if(tBoxRight < tBoxLeft) tBoxRight+=PERIOD_D1*60;
  int iBoxLeft  = iBarShift(NULL, 0, tBoxLeft,  true) + 1,
      iBoxRight = iBarShift(NULL, 0, tBoxRight, true);
  if(iBoxRight == -1) iBoxRight = iBarShift(NULL, 0, Time[0]);
  double dBoxTop = High[iHighest(NULL, 0, MODE_HIGH, iBoxLeft-iBoxRight, iBoxRight)],
         dBoxLow = Low [iLowest (NULL, 0, MODE_LOW , iBoxLeft-iBoxRight, iBoxRight)];

  ObjectDelete(BOX);
  if((t > tBoxLeft) && (t < tBoxRight)) {  
    ObjectCreate(BOX, OBJ_RECTANGLE, 0, tBoxLeft, dBoxTop, tBoxRight, dBoxLow);
    ObjectSet(BOX, OBJPROP_COLOR, BoxColor);
    ObjectSet(BOX, OBJPROP_BACK, false);
  }
}
 
sxTed:

try this


I really appreciate it sxTed! I'll try it when I get home.

Reason: