Reduce Processor Waste running indicator

Forums ProRealTime English forum ProBuilder support Reduce Processor Waste running indicator

Viewing 10 posts - 1 through 10 (of 10 total)
  • #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.

    #200092
    JS

    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)

     

    #200093

    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.

    #200096
    JS

    Okay, maybe you can make the complex calculations less complex in a smart way…

    For example, I use the standard deviation in my calculations and have found a way to calculate this standard deviation much faster…

    #200097

    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.

     

     

     

    #200098
    JS

    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…

    https://youtu.be/9EgRztlWQH4

    #200100
    JS

    I would not know any other solution for this.

    (Normally, using “CalculateOnLastBars” should significantly reduce your CPU usage)

    1 user thanked author for this post.
    #200190

    You can use a simple conditions based on time in conjunction with islastbarupdate:

    In this example, I’m making a new calculation every X seconds:

     

    #200577

    You can use a simple conditions based on time in conjunction with islastbarupdate:

    In this example, I’m making a new calculation every X seconds:

    Thanks a lot.

    #200579

    Link to Nicolas code added as Log 334 here …

    Snippet Link Library

Viewing 10 posts - 1 through 10 (of 10 total)

Create your free account now and post your request to benefit from the help of the community
Register or Login