Biertago:
Do it in start() but not on every single tick . . . search the forum for "once per bar" then adapt the code/ideas you find to suit your needs.
I want to draw few lines each day at 6:45, 10:00, 14:30 and 16:00 so my code looks this way:
That's a good idea. Thanks :)
Don't even need once per bar, just code it like a normal indicator
Not compiled Not tested
#define HR2400 86400 // 24 * 3600 int TimeOfDay(datetime when){ return( when % HR2400 ); } datetime DateOfDay(datetime when){ return( when - TimeOfDay(when) ); } //datetime Today(){ return(DateOfDay( TimeCurrent() )); } //datetime Tomorrow(){ return(Today() + HR2400); } //datetime Yesterday(){ return( iTime(NULL, PERIOD_D1, 1) ); } #define HR0645 24300 #define HR1000 36000 #define HR1430 52200 #define HR1600 57600 int start() { static datetime lastDrawn; for (int j = iBarShift(NULL,0, lastDrawn) - 1; j >= 0; j--){ lastDrawn = Time[k]; int tod = TimeOfDay(lastDrawn); if(tod == HR0625) ObjectCreate("start1"+tod, OBJ_VLINE, 0, lastDrawn, 0); if(tod == HR1000) ObjectCreate( "end1"+tod, OBJ_VLINE, 0, lastDrawn, 0); if(tod == HR1430) ObjectCreate("start2"+tod, OBJ_VLINE, 0, lastDrawn, 0); if(tod == HR1600) ObjectCreate( "end2"+tod, OBJ_VLINE, 0, lastDrawn, 0); } }Not compiled Not tested
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
I want to draw few lines each day at 6:45, 10:00, 14:30 and 16:00 so my code looks this way: