Slow procedure

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #106022 quote
    smf1
    Participant
    Average

    I’m testing a WHILE loop within a code: it does its work but it takes about 40 seconds to run through 10.000 bars (5 minutes timeframe). Actually it does 600 cycles for each candle so it should be an acceptable time, but my question is: could such a long time affect the results when the code run live in the real time? If it takes 40 seconds to complete one single run does it mean that once the new candle start no action is done  (new conditions and consequent orders if conditions are met) until the run is completed?

    Thanks for any reply

    Stefano

    #106026 quote
    robertogozzi
    Moderator
    Master

    Loops are really time consuming and will affect performance when running.

    600 iterations for 10000 bars is a huge number, 6 million iterations!

    You are lucky you didn’t get any error message!

    You’d better use less iterations and possibly try to code indicators with as few looping structures as possible.

    #106030 quote
    Nicolas
    Keymaster
    Master

    And/or use a limitation of bars for the calculation of the indicator by using CalculateOnLastBars instruction.

    #106152 quote
    smf1
    Participant
    Average

    Thanks for your answers, I will try to reduce the number of iterations and the number of bars. I still have a doubt: if the code is long anyway, despite the optimization of loops, it takes a relative long time to complete a run at any new bar. How does this time affect the results?

    Thanks

    Stefano

    #106164 quote
    robertogozzi
    Moderator
    Master

    The more a computer has to do, the slower it’ll be done.

    You cannot tell exactly.

    #106167 quote
    Vonasi
    Moderator
    Master

    I think what smf1 is concerned about is that if you have an indicator that is really slow to calculate then if you want to open a trade at the opening of the next candle but the indicator takes 40 seconds to get a value that the strategy can make a decision with then how can you enter at the actual opening of the next candle?

    #106241 quote
    smf1
    Participant
    Average

    Yes, Vonasi…that is exactly the point. I still have to understand how the system work when it goes live. I guess the refresh of a code start at the opening of each new candle and whatever are the conditions met during the current candle if those conditions met imply an order, the actual entry (or exit) is done at the next candle. Is that correct?

    #106261 quote
    Vonasi
    Moderator
    Master

    Yes is code is read through at the close of a candle and any orders placed at the opening of the next candle. Why don’t you just run your strategy with a slow to calculate indicator in demo live and then check the orders to see how quickly it got on the market?

    #106291 quote
    smf1
    Participant
    Average

    Thanks Vonasi, I’ll do the demo live test and let you know.

    Stefano

Viewing 9 posts - 1 through 9 (of 9 total)
  • You must be logged in to reply to this topic.

Slow procedure


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
smf1 @smf1 Participant
Summary

This topic contains 8 replies,
has 4 voices, and was last updated by smf1
6 years, 6 months ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 08/31/2019
Status: Active
Attachments: No files
Logo Logo
Loading...