Average in indicator returns flat spots
Forums › ProRealTime English forum › ProRealTime platform support › Average in indicator returns flat spots
- This topic has 10 replies, 4 voices, and was last updated 4 years ago by robertogozzi.
-
-
03/24/2020 at 4:06 PM #123156
This simple indicator that just calculates an average of the closing position as a percentage of range returns flat spots on the indicator where the average is clearly not being calculated correctly and the value does not change over many candles.
The attached images are of DJI daily.
123456p = 3closeperc = ((close-low)/(high-low))*100avg = average[p,1](closeperc)return avg03/24/2020 at 4:41 PM #12316703/24/2020 at 5:10 PM #123171Vonasi, you’ll have to move it yourself to the correct support forum!
03/24/2020 at 5:37 PM #123180Congratulations for being able to successfully recode a stochastic from scratch!
I actually hadn’t twigged that it was the same calculation!
Interestingly if you put the two calculations on in the same indicator the stochastic one calculates just fine but my version doesn’t.
123456789p = 3closeperc = ((close-low)/(high-low))*100avg = average[p,1](closeperc)sto = Stochastic[1,1]avg2 = average[p,1](sto)return avg,avg2I actually think this is the right place for this topic as it is clearly a data or calculation error which is a platform issue.
03/24/2020 at 5:41 PM #123182I’ve done a little more testing and the variable closeperc calculates correctly. The issue is with the exponential average calculation. If I use a simple average then it calculates correctly.
1 user thanked author for this post.
03/24/2020 at 5:56 PM #12318403/24/2020 at 6:05 PM #123185Your code works fine for me, both lines overlap.
03/24/2020 at 7:06 PM #123189Your code works fine for me, both lines overlap.
Really? That is very odd. On the DJI daily?
I feel a switch it off and back on again happening if so.
03/24/2020 at 7:34 PM #12319203/24/2020 at 8:24 PM #12319603/24/2020 at 11:24 PM #123203DJI daily.
The one below is your original code.
The one above is this one (with modifications to avoid division by 0):
123456789p = 3x = max(pipsize,range)//closeperc = ((close-low)/(high-low))*100closeperc = ((close-low)/x)*100avg = average[p,1](closeperc)sto = Stochastic[1,1]avg2 = average[p,1](sto)return avg AS "Avg",avg2 AS "Stoch"Apart from a few candles, both blue and red lines overlap.
-
AuthorPosts
Find exclusive trading pro-tools on