Page 1 of 1

Calculate script run time millisecond difference

Posted: May 20 2014
by faraz
Hi,

I want to monitor my pc script calculation time to make sure my pc is running strategy on optimal level all the time.

So I need a code which can provide millisecond difference to see how much time script used for calculation.

(Time) minus (time) = millisecond

Awaiting

Re: Calculate script run time millisecond difference

Posted: May 20 2014
by TJ
Hi,
I want to monitor my pc script calculation time to make sure my pc is running strategy on optimal level all the time.
So I need a code which can provide millisecond difference to see how much time script used for calculation.
(Time) minus (time) = millisecond
Awaiting
What is your CPU speed?

Re: Calculate script run time millisecond difference

Posted: May 20 2014
by faraz
What is your CPU speed?
3.30ghz
8 core
8gb ram
120gb ssd
windows server 2012 r2

I had run time issues with batch file. I want to make sure Multicharts is not facing this script issues. I am doubtful because few days back Order & Position Tracker show 8 seconds delay in issuing trade order. Normally I get 0 seconds delay in issuing order. But to be on safe side and monitoring purposes I need this code.

Thanks

Re: Calculate script run time millisecond difference

Posted: May 20 2014
by Henry MultiСharts
Hello faraz,

You can find two sample codes in the following thread.

Re: Calculate script run time millisecond difference

Posted: May 20 2014
by faraz
Hello faraz,

You can find two sample codes in the following thread.

For the moment, I think I go with these 2 lines, to keep code low bit as well and will manually calculate difference.

Code: Select all

Print("Start"," ",DateTimeToString_Ms(DateTime));

// Put all my code here

Print("End"," ",DateTimeToString_Ms(DateTime));
Thanks

Re: Calculate script run time millisecond difference

Posted: May 20 2014
by faraz

For the moment, I think I go with these 2 lines, to keep code low bit as well and will manually calculate difference.

Code: Select all

Print("Start"," ",DateTimeToString_Ms(DateTime));

// Put all my code here

Print("End"," ",DateTimeToString_Ms(DateTime));
Thanks

This function is providing bar Closed millisecond. if bar is 10:30 then it gave 10:30:00.000 all the time even.

This is bit better but its not in milliseconds

Code: Select all

CurrentTime_s

Do we have any better deeper computer clock function which can provide Milliseconds?

Thanks

Re: Calculate script run time millisecond difference

Posted: May 20 2014
by MAtricks

Code: Select all

MillisecondsFromDateTime(DateTime)
should do what you want.

The Wiki is incorrect and needs to be edited.. https://www.multicharts.com/trading-sof ... omDateTime

Re: Calculate script run time millisecond difference

Posted: May 20 2014
by Henry MultiСharts
Do we have any better deeper computer clock function which can provide Milliseconds?
Please check the code I have provided in this post.
MillisecondsFromDateTime(DateTime) should do what you want.
The Wiki is incorrect and needs to be edited.. https://www.multicharts.com/trading-soft ... omDateTime
What is exactly incorrect in the description?

Re: Calculate script run time millisecond difference

Posted: May 20 2014
by MAtricks
Image

Re: Calculate script run time millisecond difference

Posted: May 20 2014
by Henry MultiСharts
Done. Easy fix :-) Thank you for reporting.

Re: Calculate script run time millisecond difference

Posted: May 20 2014
by faraz
Ok, I will check the millisecond link and code again.



But I found the issue. My strategy is using IOG and in IOG mode strategy don't recalculate at bar close. It only re-calculate if a TICK comes. If no tick at bar close then no re-calculation. Need to add RecalcLastBarAfter(1); to my code.


Thanks

Re: Calculate script run time millisecond difference

Posted: May 20 2014
by faraz

Code: Select all

MillisecondsFromDateTime(DateTime)
should do what you want.

The Wiki is incorrect and needs to be edited.. https://www.multicharts.com/trading-sof ... omDateTime

I think We need to REPLACE "DateTime" in the code.

Re: Calculate script run time millisecond difference

Posted: May 20 2014
by MAtricks
I use it in several filters and very much am thankful we have it now :) But this isn't with time based bars...

I've never used this with IOG on. Couldn't you IntrabarPersist it? Of course its not being calculated EVERY MS, but at every tick which is what executes every other function ie: orders, alerts, indicators...

Re: Calculate script run time millisecond difference  [SOLVED]

Posted: May 20 2014
by faraz
Solved by Andrew.......

Code: Select all

Print(DateTimeToString_Ms(computerdatetime));

Thank you Andrew

Re: Calculate script run time millisecond difference

Posted: May 21 2014
by faraz
I have added a final testing strategy on this below link which can provide Millisecond time stamp for;
a) Strategy calculation start time
b) Strategy calculation End time
c) Milli Second difference

http://www.multicharts.com/discussion/v ... 88#p104988


Thanks