Wrong Percentage Calculation
Forums › ProRealTime English forum › ProBuilder support › Wrong Percentage Calculation
- This topic has 12 replies, 5 voices, and was last updated 7 years ago by robertogozzi.
-
-
10/21/2017 at 8:36 PM #501531234567891011121314151617181920BodyPerc = ((ABS(close - open))/(High-Low))*100IF BodyPerc <= 25 THENR = 255G = 0B = 0ELSEIF BodyPerc > 25 and BodyPerc < 75 THENR = 0G = 0B = 255ELSER = 0G = 255B = 0ENDIFENDIFReturn BodyPerc coloured (R,G,B) Style(Histogram,2) as "Body Percentage"
I wrote a simple indicator to show what percentage the body of a candle is compared to the total range but I’m getting some rogue percentages as the data for some candle is showing their range to be smaller than the candle body – which is impossible. Why is this?
10/21/2017 at 9:11 PM #5015910/21/2017 at 9:32 PM #50160Try replacing line 8 with:
IF BodyPerc < 75 THEN
Sorry for not being able to insert PRT code from My smartphone.
10/21/2017 at 9:57 PM #50162Despair – No this was a live account – I gave up on demo account data a long time ago!
RobertoGozzi – Line 8 is just about colour choice and nothing to do with the calculation.
The screenshot shows the fault in the high low close and open values that lead to the bad calculation. There are several of these over the years. Makes coding a strategy a little difficult if the data stream is rubbish!
10/21/2017 at 10:47 PM #5017010/21/2017 at 11:04 PM #50171Thanks for the suggestion AVT but a high will always be higher than a low so the result will always be a positive from (high-low). The fault is in the data supplied from IG/PRT as if you check the numbers in the cursor details panel shown in the image the range is smaller than the body of the candle, which is impossible.
1 user thanked author for this post.
10/21/2017 at 11:07 PM #50172High-Low cannot be negative, so using ABS() would not affect the outcome.
1 user thanked author for this post.
10/21/2017 at 11:12 PM #5017410/21/2017 at 11:16 PM #50175Are the wrong ones you found only sundays like the one in your attached graph? If yes, at least it would be contained to the usual sunday night data issue, rather than affecting normal week days… If no it might be worth graphing the day close in smaller timeframe and check for the instrument you look at where actual day close is relative to midnight, problem being with 24h dataflow that open and close might not be sctritly “on the same day” and generate weird stuff if high and low are on the same day…
10/22/2017 at 8:23 AM #50183No they are not all Sundays. Screenshot attached of a particularly bad period in 2003. Not sure how that data could be used for making decisions on when to trade if you can’t trust the basic data of high, low and open,close to be correct.
10/22/2017 at 9:39 AM #5019410/22/2017 at 1:35 PM #5021010/22/2017 at 7:51 PM #50254I run it on DAX 1-hour TF and everything worked fine, but not as fine when I run it on a Daily and 4-hour TF, so I think the problem is the one Noobywan talked about, that is candles across the end of the day.
-
AuthorPosts
Find exclusive trading pro-tools on