a box on the bar

 

hi....

am traying to make an indicator that plot a boxs or rectangles on each one of the  last 5 bar of the chart excludeing the recent bar(the box borders is from high to low of the bar).. i come across this code  but it will draw the box only on the bar befor the recent bar and continue to repaint the box and move it each time a new bar come.......... can any one help me to fix this code

#property copyright "Copyright © 2006, MetaQuotes Software Corp." #property link 
     "http://www.metaquotes.net"
 #property indicator_chart_window 
#define DFRAME "DAYFRAME" 
extern color HLcolour = Red; 
extern int D = 2; //How many bar back /0 = recent day/ 1 = last / 2= the bar befor 
extern int Frame = 1; 
//+------------------------------------------------------------------+ 
//| Define the Variables to use.....                                 | 
//+------------------------------------------------------------------+ 
int shift=0;   //+------------------------------------------------------------------+ 
//| Custor indicator deinitialization function                      
 | //+------------------------------------------------------------------+ 
int deinit()   {    ObjectsDeleteAll();   //----    return(0);    } 
//+------------------------------------------------------------------+
 //| Custom indicator iteration function                              |
 //+------------------------------------------------------------------+ 
int start()  
{ 
CreateHL(); } 
void CreateObj(string objName2, double start, double end, color clr)  
 { 
   ObjectCreate(objName2, OBJ_RECTANGLE, 0, iTime(NULL,0,D), start, Time[0], end);
   ObjectSet(objName2, OBJPROP_BACK, false);   
  ObjectSet(objName2, OBJPROP_COLOR, clr); 
    }    
void DeleteObjects()    
{
    ObjectDelete(DFRAME);
    }    
void CreateHL()    
{
    DeleteObjects();       
double HiDAILY = iMA(Symbol(),PERIOD_M5,1,0,MODE_HIGH,PRICE_HIGH,D);   
double LoDAILY = iMA(Symbol(),PERIOD_M5,1,0,MODE_LOW,PRICE_LOW,D);      
CreateObj(DFRAME, HiDAILY, LoDAILY, HLcolour);    
 }
 return(0);     
 

so when you have 5 previous bars with a box, what do you want the indicator to do when a new bar forms, ?

 

hi... thanks for for u  SDC and  sorry for late replay...bad internet connection.

it's seem that because am new to mql4 programming...i didnt think about that......so it's butter to draw the rectangles on all hiistory bars

or the last 50 bars......which choice is easier to be programmed.

 
abdI:

hi... thanks for for u SDC and sorry for late replay...bad internet connection.

it's seem that because am new to mql4 programming...i didnt think about that......so it's butter to draw the rectangles on all hiistory bars

or the last 50 bars......which choice is easier to be programmed.

hi,

please see my attachment. is that what you mean?

Files:
candlebox.mq4  2 kb
 
nbf28:

hi,

please see my attachment. is that what you mean?


hi

thanks for u my frind ..

sorry for my late reply.........

ur attached code will help me very much 

thanks for u agine

Reason: