Calculate script run time millisecond difference  [SOLVED]

Questions about MultiCharts and user contributed studies.
faraz
Posts: 141
Joined: 25 Feb 2011
Has thanked: 26 times
Been thanked: 56 times

Calculate script run time millisecond difference

Postby faraz » 20 May 2014

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

User avatar
TJ
Posts: 7284
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 992 times
Been thanked: 2071 times

Re: Calculate script run time millisecond difference

Postby TJ » 20 May 2014

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?

faraz
Posts: 141
Joined: 25 Feb 2011
Has thanked: 26 times
Been thanked: 56 times

Re: Calculate script run time millisecond difference

Postby faraz » 20 May 2014

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

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2944 times

Re: Calculate script run time millisecond difference

Postby Henry MultiСharts » 20 May 2014

Hello faraz,

You can find two sample codes in the following thread.

faraz
Posts: 141
Joined: 25 Feb 2011
Has thanked: 26 times
Been thanked: 56 times

Re: Calculate script run time millisecond difference

Postby faraz » 20 May 2014

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

faraz
Posts: 141
Joined: 25 Feb 2011
Has thanked: 26 times
Been thanked: 56 times

Re: Calculate script run time millisecond difference

Postby faraz » 20 May 2014


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

User avatar
MAtricks
Posts: 789
Joined: 09 Apr 2012
Has thanked: 286 times
Been thanked: 279 times

Re: Calculate script run time millisecond difference

Postby MAtricks » 20 May 2014

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

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2944 times

Re: Calculate script run time millisecond difference

Postby Henry MultiСharts » 20 May 2014

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?

User avatar
MAtricks
Posts: 789
Joined: 09 Apr 2012
Has thanked: 286 times
Been thanked: 279 times

Re: Calculate script run time millisecond difference

Postby MAtricks » 20 May 2014

Image
Attachments
2014-05-20_0905.png
(15.55 KiB) Downloaded 1224 times

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2944 times

Re: Calculate script run time millisecond difference

Postby Henry MultiСharts » 20 May 2014

Done. Easy fix :-) Thank you for reporting.

faraz
Posts: 141
Joined: 25 Feb 2011
Has thanked: 26 times
Been thanked: 56 times

Re: Calculate script run time millisecond difference

Postby faraz » 20 May 2014

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

faraz
Posts: 141
Joined: 25 Feb 2011
Has thanked: 26 times
Been thanked: 56 times

Re: Calculate script run time millisecond difference

Postby faraz » 20 May 2014

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.

User avatar
MAtricks
Posts: 789
Joined: 09 Apr 2012
Has thanked: 286 times
Been thanked: 279 times

Re: Calculate script run time millisecond difference

Postby MAtricks » 20 May 2014

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...

faraz
Posts: 141
Joined: 25 Feb 2011
Has thanked: 26 times
Been thanked: 56 times

Re: Calculate script run time millisecond difference  [SOLVED]

Postby faraz » 20 May 2014

Solved by Andrew.......

Code: Select all

Print(DateTimeToString_Ms(computerdatetime));

Thank you Andrew

faraz
Posts: 141
Joined: 25 Feb 2011
Has thanked: 26 times
Been thanked: 56 times

Re: Calculate script run time millisecond difference

Postby faraz » 21 May 2014

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


Return to “MultiCharts”