start = 0 https://docs.mql4.com/dateandtime "A group of functions providing the working with data of the datetime type (integer representing the amount of seconds elapsed from midnight, 1 January, 1970)."
You need to give each of your lines a new name, unless you want to just move a single line across the screen.
You need to check that your values generated by your loop are greater than the datetime for bar Bars-1 . . . if they are then you can draw them, otherwise they are off chart.
void startLine(datetime startTime){ int all_objects = ObjectsTotal(); string name; for(int cn=0;cn < all_objects; cn++) name = "new_moon"+cn; ObjectCreate("start"+cn,OBJ_VLINE,0,startTime,0); ObjectSet("start"+cn,OBJPROP_COLOR,Maroon); WindowRedraw(); return(0); }
after that there are many lines with different names but all of them are in one place (time)
Hello, Can anybody help me with code?
I want to create an indicator, drawing vline since 1970.01.01 after every 1000000.54 seconds.
I wrote something like this but it doesn't work:
datetime nl = 1000000.54;
int start(){ datetime from = Time[Bars-1], to = Time[0]; for(double seconds=0; true; seconds += 1000000.54){ if (seconds < from) continue; if (seconds > to ) break; VLine("second"+seconds, seconds, Red); } } void VLine(string name, datetime T0, color clr){ #define WINDOW_MAIN 0 if (!Show.Objects) return; if (ObjectMove( name, 0, T0, 0 )){} else if (!ObjectCreate( name, OBJ_VLINE, WINDOW_MAIN, T0, 0 )) Alert("ObjectCreate(",name,",VLINE) failed: ", GetLastError() ); if (!ObjectSet(name, OBJPROP_COLOR, clr )) // Allow color change Alert("ObjectSet(", name, ",Color) [1] failed: ", GetLastError() ); if (!ObjectSetText(name, TimeToStr(T0, TIME_MINUTES), 10)) Alert("ObjectSetText(",name,") [1] failed: ", GetLastError()); }

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello, Can anybody help me with code?
I want to create an indicator, drawing vline since 1970.01.01 after every 1000000.54 seconds.
I wrote something like this but it doesn't work: