Exponential Average of Candle Value Intermittently Flat Lines
Forums › ProRealTime English forum › ProBuilder support › Exponential Average of Candle Value Intermittently Flat Lines
- This topic has 6 replies, 3 voices, and was last updated 4 years ago by
Nelson.
-
-
05/21/2021 at 2:48 AM #170079
I am trying to code a very simple exponential average (60) of a calculated candle value, it sometimes stops calculating and flatlines which is strange. There has to be an error in my code as the candle value still calculates. To see it better I have scaled the values up
Does anyone have any idea as to why this is happening I have tried a few things to no success.
Flow Oscillator123456789101112131415//Flow// Works out the candle value and to see result is scaled up by * 200//Zero LineDRAWHLINE(0)coloured(0,0,0)CandleValue = (close - open) / (high - low)CV = CandleValue * 200// Exponential average of scaled up Candle Value and this is scaled up * 50 to see resultMVC = Average[60,1](CV)MVC1 = MVC * 50Return MVC1 as "MVC", CandleValue as "CV", CV as "Scale Up CV", 0 as "0"05/21/2021 at 8:12 AM #170090It’s quite weird, I tested it on DAX, different TF’s, even replacing AVERAGE with EXPONENTIALAVERAGE, but it still plots flat lines almost everyday.
It occurs mainly on Indices (Dax, Ftse, Nikkei, Cac40, Russel, Nasdaq, S&P500 and Dow Jones ). As to FX pairs I experienced the same issue on NZD/CHF, GBP/CAD and GBP/CHF (I did only test it on about 15 pairs).
I have no idea why.
I suggest that you open a ticket for assistamce (press Ctrl+M from the platform).
05/21/2021 at 11:48 AM #17010705/21/2021 at 12:09 PM #170108You divide by (high-low) in line 8, which creates undefined values when high=low because of division by 0, and propagates the undefined through the averages. You can try to surround your line 8 by “if high<>low then … endif” and see if it achieves what you expect.
2 users thanked author for this post.
05/21/2021 at 3:00 PM #170123Well spotted Noobywan!
You can replace line 8 with this one:
1CandleValue = (close - open) / max(0.00001,(high - low))05/21/2021 at 3:05 PM #170124Maybe this a better solution, replace lines 8-9 with:
1234IF (high - low) >0 THENCandleValue = (close - open) / (high - low)CV = CandleValue * 200ENDIF1 user thanked author for this post.
05/22/2021 at 1:10 AM #170160 -
AuthorPosts
Find exclusive trading pro-tools on