Slow procedure
Forums › ProRealTime English forum › ProBuilder support › Slow procedure
- This topic has 8 replies, 4 voices, and was last updated 5 years ago by smf1.
-
-
08/31/2019 at 4:32 PM #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
08/31/2019 at 4:51 PM #106026Loops 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.
08/31/2019 at 5:33 PM #106030And/or use a limitation of bars for the calculation of the indicator by using CalculateOnLastBars instruction.
09/01/2019 at 10:00 PM #106152Thanks 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
09/01/2019 at 11:34 PM #106164The more a computer has to do, the slower it’ll be done.
You cannot tell exactly.
09/01/2019 at 11:49 PM #106167I 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?
09/02/2019 at 3:44 PM #106241Yes, 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?
09/02/2019 at 6:20 PM #106261Yes 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?
09/02/2019 at 11:43 PM #106291 -
AuthorPosts