weekly box

 

I have a problem with the times on this chart.

It works with the one hour chart highlighting a box for the daily range

but on the Daily chart, I am trying to highlight a box for the last week and it doesn't highlight the correct number of days.


   double AlertsOn = 1;
   int periodmltp = 0;
   int h = 0;
   double RR = 2.5; //Risk reward

   if (Period() == PERIOD_H1) {period_no = 1440;}
   double hprice=iLow(Symbol(),period_no,1)+iATR(Symbol(),period_no,14,0);
   double lprice=iHigh(Symbol(),period_no,1)-iATR(Symbol(),period_no,14,0);
   double FullRange = hprice - lprice;
   double sd_1 = FullRange*0.682;
   double sd_buff_1 = (FullRange - sd_1)/2;
   double top1_sd = hprice-sd_buff_1;
   double bottom1_sd = lprice+sd_buff_1;
   double mid = hprice-(FullRange/2);

   if (Hour()==0) {h=1;} else {h=0;} //to account for the opening candle so we can actually see a rectangle appear
   if (Period() == 60) {periodmltp = 60;} else {periodmltp = 24*5;}

   //box
   ObjectCreate("box"+Symbol()+Day(),OBJ_RECTANGLE,0,TimeCurrent() - (TimeCurrent()%(period_no * periodmltp)),hprice,Time[h],lprice);
   ObjectSet("box"+Symbol()+Day(),OBJPROP_TIME1,TimeCurrent() - (TimeCurrent()%(period_no * periodmltp)));
   ObjectSet("box"+Symbol()+Day(),OBJPROP_TIME2,Time[h]);
   ObjectSet("box"+Symbol()+Day(),OBJPROP_PRICE1,hprice);
   ObjectSet("box"+Symbol()+Day(),OBJPROP_PRICE2,lprice);
   ObjectSet("box"+Symbol()+Day(), OBJPROP_STYLE, STYLE_DASHDOTDOT);
   ObjectSet("box"+Symbol()+Day(), OBJPROP_COLOR, SteelBlue);
   ObjectSet("box"+Symbol()+Day(), OBJPROP_WIDTH, 4);
 

What does this do ?

TimeCurrent()%(period_no * 60) for H1 ?

TimeCurrent()%(period_no * 120) for D1 ?

 
RaptorUK:

What does this do ?

TimeCurrent()%(period_no * 60) for H1 ?

TimeCurrent()%(period_no * 120) for D1 ?


The 60 works out the box for the 1hr chart based on a 24hr period.

So, for the 1hr charts it does 1440 * 60 and works out the time to start the rectangle from.


On the Daily charts, it should be highlighting a 5 day period but only Monday to Friday. SO, if the chart is currently Wednesday, it should highlight Monday, Tues, and Wednesday only.

When the Daily is selected the period_no will be 10080 for weekly.

 
Try again . . .
 

I did and no matter what I do, it will only highlight 5 days

10080/100

 
SanMiguel:

I did and no matter what I do, it will only highlight 5 days

10080/100

Because you don't understand your code . . .
 
yes, that's why I posted on a forum.