- Don't attach a image, insert the image
- You are created objects with the name whatever+barNumber. After the first run you will be trying to create another with the same name. Don't use barnumber, either Bars-barNumber or Time[barnumber] are unique.
Why not just get the values from the M15 time-frame?
{if(Period()==PERIOD_M5) { for(int y=1; y<=96; y++) { double top=iHigh(NULL,PERIOD_M15,y); double bot=iLow(NULL,PERIOD_M15,y); double bar_open=iOpen(NULL,PERIOD_M15,y); double bar_close=iClose(NULL,PERIOD_M15,y); datetime begin_time=iTime(NULL,PERIOD_M15,y); datetime end_time=iTime(NULL,PERIOD_M15,y-1)-1; string rectanglename=StringConcatenate("M15 tracker ",begin_time); if(bar_close>=bar_open) //Previous bull on M15 { bool draw=ObjectCreate(rectanglename,OBJ_RECTANGLE,0,begin_time,bot,end_time,top); bool colorin=ObjectSet(rectanglename,OBJPROP_COLOR,clrSlateGray); bool linew=ObjectSet(rectanglename,OBJPROP_WIDTH,1); bool lines=ObjectSet(rectanglename,OBJPROP_STYLE,STYLE_SOLID); } if(bar_close<=bar_open) //Previous bear on M15 { bool draw=ObjectCreate(rectanglename,OBJ_RECTANGLE,0,begin_time,bot,end_time,top); bool colorin=ObjectSet(rectanglename,OBJPROP_COLOR,clrWhite); bool linew=ObjectSet(rectanglename,OBJPROP_WIDTH,1); bool lines=ObjectSet(rectanglename,OBJPROP_STYLE,STYLE_SOLID); } } }
You could also use CopyRates() to get the data for M15.
Note that if the open is equal to the close, both if conditions will return true.
GumRai:
Ah, amazing! Didn't even think of that. Thank you!
Why not just get the values from the M15 time-frame?
You could also use CopyRates() to get the data for M15.
Note that if the open is equal to the close, both if conditions will return true.
WHRoeder:
- Don't attach a image, insert the image
- You are created objects with the name whatever+barNumber. After the first run you will be trying to create another with the same name. Don't use barnumber, either Bars-barNumber or Time[barnumber] are unique.
Noted for next time.
Thanks

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hey guys,
Just need some help please. I would like to draw rectangles on the M5 chart. Each rectangle will represent M15. I basically want to show the previous days worth of M15 on M5. When I drop the script on the chart it only draws the attached picture, with the Highs and Lows incorrect? Below is my code.
Any help is appreciated!