Hello,
I am looking for a way to reduce the CPU usage of the pc by writing an optimized code of an indicator.
I know that PRT runs an indicator for every tick arriving on the instrument and, within this, it executes the indicator for every bar on the worktable.
That is, if I have 1000 bars in the work plan, for every incoming tick PRT executes the indicator 1000 times.
My indicatorit already uses calculateonlastbars = 20 so for every tick it run 20 times, one for last 20 bars, and draws objects with DRAW commands only if islastbarupdate. But the use of CPU is very high due to complex calculation.
because object drawing are very static (starting from a certain date in the past), it would be sufficient to activate drawing not for each tick,
but:
– at each new opening bar or every 10 seconds
– in any case when the market is closed (because no new tick arriving to force draw).
in other words, there is a way to recognize if we are at a closed market period, and therefore if ticks do not arrive?
I can always draw, or I am at an open market and therefore I can count on the fact that the ticks arrive and then use
currentsecond to make the indicator work every 10 seconds?
Or its’ possible to know the my pc Time and date at indicator execution? I found only reference to closing bar time/date/timestamp.
Hi @robocop
If I understand your problem correctly and you only want to have your indicator updated 1 time every 10 seconds, you can use:
TimeFrame(10 seconds, UpdateOnClose)
Your suggestion is not applicable because MultiTimeFrame require that the timeframe of the chart is below Timeframe coded (eg. chart TF 5 second).
MyIndicators runs in Timeframe 1h and above (2h, 4h, Day, Week, etc) and i want to update not at every tick on market open (e.g. 10 second, at close/open bar, etrc) and always at market close.
Okay, maybe you can make the complex calculations less complex in a smart way…
In my opinion the right way is dont make any calculation if we know is redundant, not make a light, but redundant, calculation.
Anyway, i will think about it. Meanwhile if you know the answer to my original question, i appreciate it.
I’m not talking about redundant calculations, but sometimes you can manipulate the equations/calculations in such a way that they work much faster.
Calculating the standard deviation in this way is much faster than with the standard method…
The information collected on this form is stored in a computer file by ProRealCode to create and access your ProRealCode profile. This data is kept in a secure database for the duration of the member's membership. They will be kept as long as you use our services and will be automatically deleted after 3 years of inactivity. Your personal data is used to create your private profile on ProRealCode. This data is maintained by SAS ProRealCode, 407 rue Freycinet, 59151 Arleux, France. If you subscribe to our newsletters, your email address is provided to our service provider "MailChimp" located in the United States, with whom we have signed a confidentiality agreement. This company is also compliant with the EU/Swiss Privacy Shield, and the GDPR.
For any request for correction or deletion concerning your data, you can directly contact the ProRealCode team by email at privacy@prorealcode.com
If you would like to lodge a complaint regarding the use of your personal data, you can contact your data protection supervisory authority.
Get Assistance
Assistance Type
Your Need
Proposed Solutions
Do you like cookies? 🍪 We use cookies to ensure you get the best experience on our website.
(Learn more)