Reduce Processor Waste running indicator
Forums › ProRealTime English forum › ProBuilder support › Reduce Processor Waste running indicator
- This topic has 9 replies, 4 voices, and was last updated 2 years ago by GraHal.
Tagged: deviation, Faster Standard Deviation, processor, processor waste, standard, std, waste
-
-
09/03/2022 at 5:39 PM #200087
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.
thank you.
09/03/2022 at 8:08 PM #20009209/03/2022 at 8:22 PM #200093Hi @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.09/03/2022 at 8:41 PM #20009609/03/2022 at 9:02 PM #200097Okay, 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.
09/03/2022 at 9:17 PM #200098I’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…
Standard Deviation Fast123456789Mu = Average[n](Close)MuSquared = Square(Mu)XiSquared = Square(Close)StdRS = SQRT(1/n * Summation[n](XiSquared) - MuSquared)Return StdRS[n]09/03/2022 at 9:32 PM #20010009/05/2022 at 4:16 PM #200190You can use a simple conditions based on time in conjunction with islastbarupdate:
In this example, I’m making a new calculation every X seconds:
1234567891011X = 6if islastbarupdate and timestamp-lastcalc>=X then//do some calculationsindi = closelastcalc=timestampendifreturn indi09/11/2022 at 9:33 PM #200577You can use a simple conditions based on time in conjunction with islastbarupdate:
In this example, I’m making a new calculation every X seconds:
1234567891011X = 6if islastbarupdate and timestamp–lastcalc>=X then//do some calculationsindi= closelastcalc=timestampendifreturn indiThanks a lot.
09/11/2022 at 10:06 PM #200579Link to Nicolas code added as Log 334 here …
-
AuthorPosts
Find exclusive trading pro-tools on