Maximum number of iterations in a loop?

Forums ProRealTime English forum ProBuilder support Maximum number of iterations in a loop?

  • This topic has 17 replies, 5 voices, and was last updated 5 years ago by avatarLeo.
Viewing 15 posts - 1 through 15 (of 18 total)
  • #90751

    I’m trying to code an indicator that simulates a strategy and calculates which values for three variables have been the most profitable recently. I then hope to CALL these values from a strategy and so create a sort of self optimizing strtaegy. To try to achieve this I have in the indicator a loop with two other loops within it to get all the possible combinations of the three variable values. When I try to run the indicator I get the following message:

    Screenshot_1-2

    If I reduce the quantity in each loop then I am able to get the indicator to run but then the total number of possible combinations is massively reduced. I want to test something like 320000 combinations but it will only let me test 480.

    If I know what the maximum quantity of loops is then maybe I can do repeats of the code and test different blocks of combinations each time and compare the output to the previous block tested. All a bit messy but possibly do-able.

    Does anyone know what the maximum quantity of loops is and why it is so low?

    The code is something like this:

     

    #90754

    200x200x200 = 8 million!!!

    Try 20x20x20, but it’s likely to be still too much!

    #90755

    Oooops – I was meant to type 20 for the first two loops! I’ll edit it in the post!

    #90757

    There is no real limitations, I have never been able to know how many iterations a loop could handle, I think that is it only a memory limitation of the ProBuilder engine. Since we don’t have data arrays, no dynamic variables are possible and we only have loops to recreate them on the fly..

    Nested loops are the worse!

    A good practice is to break the loop once you have found what you want, when it’s possible.

    #90758

    I tested the max by setting the first two loops with values from 1 to 1 and then slowly changed the third loops value until the indicator ran. Strangely at 695 it started to run but then crashed out with the error after a while. So I then decided to remove most of the indicator code and see what happened and I was able to get it to run with larger quantities of loops – up to 6650 loops. Clearly the number of loops is not a fixed number as my original indicator would not run with more than 480 loops but a simpler indicator would run with 6650.

    This is the test code I used:

     

    #90760

    I think we were typing at the same time Nicolas. My test seems to agree with what you have described.

    Unfortunately every combination needs to be examined and tested in my indicator to find the best performing combination and so using BREAK is not an option.

    It seems that loops are not going to necessarily work even if I break the combinations down in to smaller chunks. At just 480 iterations per loop I would need 667 chunks to cover 320000 combinations!

    #90761

    Why not to try to separate the loop into 2 separated ones?

    #90764

    I did try reducing the code down to just optimizing two variables just to see if it could cope…. and it couldn’t. I think the FOR NEXT loop facility in PRT is just not up to the job!

    #90766

    I have even started coding a strategy that stores 1600 simulated strategy results in my desperation to build a self optimizing strategy – but after completing just 80 strategy simulation coding blocks it felt like I was writing ‘War and Peace’ so I stopped. I think I need to revisit it to improve the way I use ‘find and replace’ to deal with the code so that I can create bigger blocks at a time.

    #90907

    improve the way I use ‘find and replace’ to deal with the code so that I can create bigger blocks at a time.

    I’m sure you’ve thought of it, but how about a 3rd party application / sw and then copy and paste back into PRT?

    http://findandreplace.sourceforge.net/

    #90909

    Thanks for that suggestion GraHal. I was thinking something similar myself earlier today when I did a find and replace that just went on for hours – right up to the point where I did a task manager stop of the platform and lost hours of work but at least I was able to get back and start doing it all again!

    Strangely since I’ve been messing with these massive strategies I’ve had PRT crash shut down quite a few times on me too. It is all making the end goal feel a very long way away but I will persevere!

    #90924

    Strangely since I’ve been messing with these massive strategies I’ve had PRT crash shut down quite a few times on me too.

    PRT hogging / not releasing RAM issues again I reckon?

    Since I got down to zero Systems stored in the backtest screen and also zero Systems stored  in the non-running auto-trading screen and also shutting down PRT after a heavy session I haven’t had a crash.

    I’ll probably get one now!!! 🙂

    #90935

    PRT hogging / not releasing RAM issues again I reckon?

    Very likely as this idea is giving the RAM a real bashing. At the moment I am running a back test on 10000 bars that basically runs 320000 simulated strategies at each bar close and then one real strategy!

    #91047
    Leo

    Hi Vonasi…

    I don’t want to disapoint you but this Problem of max Memory for the Loop of ProRealCode, seem to be something serious…

    In my neural Network the “descent Gradient” algorith take 10 values of data (Batch) makes som Magic (calculate Derivate, save some values average others, etc) and recalculate the 43 values of the neural Network-… and when I say recalculate is modify a Little bit the values for improve the neural Network ( the learning process)…

    The more time you repeated this process (epchos)… the more acurate the Network is…

    Do you know how many times I am able to repeat the “descent Gradient” adgorithm…

    5 times!!! only 5 times!!!! with a Loop of for i=1 to 6… i get the Infinitive Loop issue….

    What I have done… is to make 5 per bar… the next bar makes another 5 Loops and so on….

    … i am feeling very frustrated with ProRealCode lately.

     

    #91050
    Leo

    have even started coding a strategy that stores 1600 simulated strategy results in my desperation to build a self optimizing strategy

    I felt desperate too, so I change to Machine Learning…

    Maybe you can open a new Forum Topic… and I can help you…  but you Need to be more willing to share your codes…

    for example I will Need:

    –> Classifier: a code to look in the past and detects a succesful trade your are willing to achive

    —> variables: 5 variables ( I am working currently in a Network with 5 Inputs) that the Network evaluate to make the trade.

    Then the Network predict the best Setting of thos 5 variables to make a prediction.

    … Maybe is not what you are searching for… but we can having a try.

     

     

Viewing 15 posts - 1 through 15 (of 18 total)

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