Hi there,
Currently I am running a function to modify a time string:
The problem is, this is pretty slow if I run it "every" tick on backtesting.
Is
there a way to make it go faster?
Try this:
string timeDB(string timeIn) { // 01234567890123456789012 // timeIN: YYYY.MM.DD HH:MM:ss //timeOUT: YYYY-MM-DD HH:MM:ss.000 StringReplace(timeIn, ".", "-"); StringAdd(timeIn, ".000"); //Print(timeIn); return(timeIn); }
If timeIn format is always as written, it would be better to replace dot with dash using:
StringSetCharacter()
Other option is to handle formating at database.
Hi there,
Currently I am running a function to modify a time string:
The problem is, this is pretty slow if I run it "every" tick on backtesting.
Is
there a way to make it go faster?
If timeIn format is always as written, it would be better to replace dot with dash using:
Other option is to handle formating at database.
Thanks. I have opted for formatting at the Database side.
I did sort out my problem though: just very inefficient coding
on my behalf.
Is there a way to make it go faster?
#property strict string timeDB( const datetime timeIn ) { // 01234567890123456789012 // timeIN: YYYY.MM.DD HH:MM:ss //timeOUT: YYYY-MM-DD HH:MM:ss.000 string timeOut = (string)timeIn; StringSetCharacter(timeOut, 4, '-'); StringSetCharacter(timeOut, 7, '-'); return(timeOut + ".000"); } void OnStart() { Print(timeDB(TimeLocal())); }
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi there,
Currently I am running a function to modify a time string:
The problem is, this is pretty slow if I run it "every" tick on backtesting.
Is there a way to make it go faster?