Directional Movement Change
Forums › ProRealTime English forum › ProBuilder support › Directional Movement Change
- This topic has 5 replies, 2 voices, and was last updated 7 years ago by Johan.
-
-
01/06/2017 at 12:37 PM #20034
I want to make a indicator that calculates the change of Directional Movement (DI) in current bar, compared to last bar.
Say the last bar has a value of 20 and the current bar has a value of 10. The change would then be = 100%.
Say the last bar has a value of -10 and the current bar has a value of 30. The change would then be = 400%.
Say the last bar has a value of 15 and the current bar has a value of -15. The change would then be = 200%.
This is some what easy to do. But the problem i face is when a bar has a value that starts with 0. Or when there’s a negative value on either side.
My code
12volaDI = di[14](close)volaDIchange = ((volaDI - volaDI[1]) / volaDI[1]) * 10001/06/2017 at 1:34 PM #2003501/06/2017 at 4:14 PM #20062Hey Johan, you are reinventing the wheel. You can use the Rate Of Change (ROC) to compare the change between the current value and one of the past. In your case, you only want to compare the actual one to the previous one, so the ROC period should be set to 1 and your code should now look like this:
12345volaDI = di[14](close)//volaDIchange = ((volaDI - volaDI[1]) / volaDI[1]) * 100volaDIchange = abs(ROC[1](volaDI)-volaDI[1])return volaDIchangePlease tell me if I’m totally wrong, it’s Friday coding 🙂
01/06/2017 at 5:05 PM #20075Thanks Nicolas. Looks like this is the way to go. But still, get’s huge spikes when there’s a zero value involved. This becomes nasty noise when there’s a small rate of change in price action but the DI value flips side. See my attached image. If you look to the right, the ROC of the last green and the first red bar should have the spike. Does this make any sense? 🙂
01/06/2017 at 6:07 PM #20083Made some changes to get rid of the zero value.
12345678910volaDI = di[14](close)volaDIround = round(volaDI)if (volaDIround = 0) thenvolaDIround = sgn(volaDIround)endifvolaDIroc = abs(roc[1](volaDIround))return volaDIrocBut what i don’t understand is how the ROC work. If i draw two rulers between the values of the one that i can see has the most ROC (distance) and the one where the indicator spikes. You can clearly see the it don’t correspond to the distance of the DI move. See image…
01/06/2017 at 6:19 PM #20086 -
AuthorPosts
Find exclusive trading pro-tools on