Calculate script run time millisecond difference  [SOLVED]

Questions about MultiCharts and user contributed studies.
User avatar
faraz
Posts: 221
Joined: Feb 25 2011
Location: 1stChoiceStrategy.com
Has thanked: 26 times
Been thanked: 71 times

May 20 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: 7775
Joined: Aug 29 2006
Location: Global Citizen
Has thanked: 1036 times
Been thanked: 2233 times

May 20 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?

User avatar
faraz
Posts: 221
Joined: Feb 25 2011
Location: 1stChoiceStrategy.com
Has thanked: 26 times
Been thanked: 71 times

May 20 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: Aug 25 2011
Has thanked: 1264 times
Been thanked: 2958 times

May 20 2014

Hello faraz,

You can find two sample codes in the following thread.

User avatar
faraz
Posts: 221
Joined: Feb 25 2011
Location: 1stChoiceStrategy.com
Has thanked: 26 times
Been thanked: 71 times

May 20 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

User avatar
faraz
Posts: 221
Joined: Feb 25 2011
Location: 1stChoiceStrategy.com
Has thanked: 26 times
Been thanked: 71 times

May 20 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: Apr 09 2012
Has thanked: 286 times
Been thanked: 288 times

May 20 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: Aug 25 2011
Has thanked: 1264 times
Been thanked: 2958 times

May 20 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: Apr 09 2012
Has thanked: 286 times
Been thanked: 288 times

May 20 2014

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

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

May 20 2014

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

User avatar
faraz
Posts: 221
Joined: Feb 25 2011
Location: 1stChoiceStrategy.com
Has thanked: 26 times
Been thanked: 71 times

May 20 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

User avatar
faraz
Posts: 221
Joined: Feb 25 2011
Location: 1stChoiceStrategy.com
Has thanked: 26 times
Been thanked: 71 times

May 20 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: Apr 09 2012
Has thanked: 286 times
Been thanked: 288 times

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

User avatar
faraz
Posts: 221
Joined: Feb 25 2011
Location: 1stChoiceStrategy.com
Has thanked: 26 times
Been thanked: 71 times

May 20 2014

Solved by Andrew.......

Code: Select all

Print(DateTimeToString_Ms(computerdatetime));

Thank you Andrew

User avatar
faraz
Posts: 221
Joined: Feb 25 2011
Location: 1stChoiceStrategy.com
Has thanked: 26 times
Been thanked: 71 times

May 21 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