This was posted in reply to Vonassi but didn’t look like it was posted. I am posting here. Apologies if it ended up being double posted.
I have a fairly simple question
How do I write a simple code that for example looks back at the last 100 bars and averages only positive values? For example I have an indicator that returns either a + value or – value for every bar. I want to lookback 100 bars and average only the + values (- values are skipped/ignored in average calculation)
thank you and regards.
Maybe a code that goes through the 100 bars and everytime that finds a positive value it stores it in a variable and once it finishes going through the 1oo bars and storing all the positive values it finds then a code to average all positive values found and stored. Perhaps an array variable that can store up to 96 values?? perhaps a much more simpler code?
We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.Ok