Coding a Momentum Indicator
- This topic has 4 replies, 2 voices, and was last updated 5 years ago by .
Viewing 5 posts - 1 through 5 (of 5 total)
Viewing 5 posts - 1 through 5 (of 5 total)
Similar topics:
Forums › ProRealTime English forum › ProBuilder support › Coding a Momentum Indicator
I have created a simple program for a 4-bar momentum indicator but want it to look like the PRT momentum indicator (i.e. having it oscillate on either side of zero line with different colours). Can anyone tell me what I need to add into the program to achieve this? Thanks. My coding so far is this:
1 2 3 4 5 |
Variable1 = 0 MyOpen = Open[4] MyClose = Close[0] Result = ((MyClose-MyOpen)/MyOpen)*100 Return Result, Variable1 |
Welcome to the forums.
There are a few basic rules that you should try to follow when posting in the forums. You broke a couple of them with your first post.
To answer your question try this:
1 2 3 4 5 6 7 8 9 10 11 12 13 |
Variable1 = 0 MyOpen = Open[4] MyClose = Close[0] Result = ((MyClose-MyOpen)/MyOpen)*100 r = 128 g = 0 if result > 0 then r = 0 g = 128 endif Return Result coloured(r,g,0) style(line,1) as "Result", Variable1 as "0" |
Thank you so much for your coding help. Two things: (1) is there a way I can get the momentum line to be black; and (2) is there a way I can have the zero line label not show?
I may be a little confused by your request now! I thought that you wanted the line to change colour from green to red but did you really mean that you wanted the infill colour to change? If so then this can sort of be achieved by hard coding but it is far easier and gives a much better results if you just add a colour zone via the indicator settings and then save these settings as default for the indicator so that every time you apply the indicator it is the same. Your original code should produce a black line.
If you remove the zero bits of code and add a separate ‘Horizontal Line’ indicator via the indicator settings then you might get rid of the “0” label – not certain so you need to test.
Thanks so much for your help. I had wanted colour to either side of the 1% line, but the line itself to be black (which I’ve now got). If the line is coloured, the numbers/words come up in the data box as coloured text which is much harder to read on the screen than black.
Find exclusive trading pro-tools on