Slow procedure

  • This topic has 8 replies, 4 voices, and was last updated 4 years ago by avatarsmf1.
Viewing 9 posts - 1 through 9 (of 9 total)
  • #106022

    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

    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

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

    #106152

    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

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

    You cannot tell exactly.

    #106167

    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

    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

    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

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

    Stefano

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

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