Help with reducing variable to 1 and stopping loop
-
Hi All
Busy with this project shared/Zq5NSUzmb and cannot get the loop to work. There are essentially 3 variables that reduce by 1 each loop. When one of them equals 1 the project this should trigger the loop to stop but doing something wrong. Would really appreciate some help. The snippet below shows the problem blocks

-

Found this one but still not working
-
@xander Can you please share the latest version of the project?
-
Sure and sorry for forgetting the link shared/dVmcx8jTb
-
@xander Don't get me wrong but I see a bit messy project. Could you please reorder the tres according to their supposed order of execution? I also see some single blocks that I assume you know they are not executed.
-
Ok I wiped the other rules to try and clean this up. shared/psbUifl0b
Essentially the rules now are start 24 candles back, look for a 3 candle swing high, draw a line at the high. Regardless of whether there is a high reduce the old candle ID by 1 and repeat until it equals 1. (you can ignore the buy and sells was just using those to test where it stops working because the line is only drawn once).
Basically two problems:
- The line for the high does not draw each time and
- Run through all rules and reduce by 1 until it equals 1

-
@xander Can you please share the link for the latest version?
-
shared/qRJDXnzT
-
@xander said in Help with reducing variable to 1 and stopping loop:
shared/qRJDXnzT
Ok. That's much better. Here is what I see in my first look at it:
- That 'pass' block ID60 is redundant. You can remove it.
- What is the logic behind of your sell connected immediately after the 'buy now' block AND, at the same time, to all yellow outputs of those conditions necessary to open a buy? You are asking a sell to be open immediately after a buy is true!
-
Yeah don't worry about the buy and sell just trying to test where the system triggers and when. The ruleset is a massively simplified version of teh actual project. My concern is that the loop does not draw a line at each high for each loop, instead only one is drawn. Dont really care about the conditions just want the loop to run at 24 for example, reduce to 23 and repeat all conditions until the variable =1
-
@xander The problem is block 62. You are definning the initial values for all those variables and then you want to catch and compare high values from the three previous candles. Why are you initialitizing those variables with those values every new bar?
-
I don't think thats the problem, I run this on a 1h chart, so block 70 and 71 should only allow it to happen once a day, when I reset these to a certain value. The loop should then test for highs, reduce the variables by one and if they are still greater than one run block 63, which should not reset the variables? In effect if you set variable 1 to 24 it should repeat 23 times until the variable equals 1 and then stop.
shared/QXlN3HIPc
-
@xander In that case I'm agraid I cannot offer any additional suggestion. I simply don't undertand this project. Honestly I have no idea how the 'run block' block works so maybe that is my problem. I gess you are looking for a loop to find those hughs and lows. I strongly recommend you ask for roar's help. He's ours loops expert!
