I need help connecting points using different colors on a MACD plot

a_edwall

Active member
Joined
May 22, 2019
Posts
28
Likes
7
I would appreciate help with figuring out how to use different colors (like green - or any selectable color - for an increasing MACD value and red - or any selectable color - for a decreasing MACD value) in drawing a MACD line. Instead of one color throughout the entire line, I want to see one color when the MACD line is rising and a different color when the MACD line is falling. I attach my current code. I have been experimenting for hours and I am getting nowhere. Thank you in advance.
 

Attachments

  • Rainbow_MACD.zip
    1.8 KB · Views: 5

Spin

Well-known member
Joined
May 22, 2019
Posts
480
Likes
192
I am guessing you haven't stumbled upon his thread yet ?

higher/lower coloring

You will notice that using only 2 colors is quite easy. You will need to add a little more effort if you want to go 'full rainbow' (perhaps calculate a slope percentage and use that to decide what color ?)

Ow, and let me add that you can 'hard-code' colors in your class 'definitions' (from line 35 onwards for instance, in your code):

1630736728603.png

You can then simply use those names whenever you need them:

Java:
 group.addRow(new IndicatorDescriptor(FILTER_IND, "Filter Ind", BrGreen, null, false, false, true));

Feel free to post screenshots of the result, we all might learn something :)
 
Last edited:

a_edwall

Active member
Joined
May 22, 2019
Posts
28
Likes
7
Feel free to post screenshots of the result, we all might learn something :)

Thank you for that link - I had not come across it. And thanks for the other info. I will start checking it all out. And no, I called it "rainbow" because I couldn't think of a better name. All I need is 2 colors.
 

a_edwall

Active member
Joined
May 22, 2019
Posts
28
Likes
7
My eyes must be bad because I am not seeing something clearly.

This line of code:

Code:
public final static Color Magenta = new Color(r: 255, g: 0, b: 255);

gives error message:

43: error: ')' expected [javac] public final static Color Magenta = new Color(r:255, g:0, b:255);
 

a_edwall

Active member
Joined
May 22, 2019
Posts
28
Likes
7
Sorry, Spin, that link doesn't help me as ScottyA DM'ed you something and it is not available to me.

"Sent you a DM with a snippet of code".
 

a_edwall

Active member
Joined
May 22, 2019
Posts
28
Likes
7
I needed to add this to my script:

Code:
import java.awt.Color;

and the definition code was:

Code:
public static final Color Magenta = new Color(255, 0, 255);
 

a_edwall

Active member
Joined
May 22, 2019
Posts
28
Likes
7
Sorry for all the questions. I see that all my efforts were pretty much a waste of time as the Color Policy settings apparently do what I need. I didn't know anything about those until this morning. Now I understand your graphic shown in the message you referred me to. But there seems to be nothing mentioned about this in the SDK manual. Maybe I am missing a resource or two.
 

Spin

Well-known member
Joined
May 22, 2019
Posts
480
Likes
192
Ah, yes, there is indeed a standard setting for 'rising / falling', so if you only need 2 colors, that might suffice.

And sorry about the confusion: those letters 'r,g,b' are added automatically by my SDE (I use intelliJ), for extra clarity. I should have removed them, since they are not part of the actual code.

I'm glad you've figured it out ! (y)

And exactly what part do you believe is missing from the SDK manual ? :unsure:
 

a_edwall

Active member
Joined
May 22, 2019
Posts
28
Likes
7
>> And exactly what part do you believe is missing from the SDK manual ?

I did a search on color policy and policy, etc. and there is no mention of what that does or means (for instance, exactly what does the "Price" selection do? Yes, I sort of see the results, but I'm not 100% sure if I grasp it or not. Still, it's my fault, as I am juggling dozens of things all at the same time). Also, in the Overview-Package-Class-Tree documentation, it would be very helpful if real-life examples were given. Yes, I know an experienced (Java/OOP) programmer figures things out quickly, perhaps, but Java is not my first language and therefore I do not grasp the info as easily of some others. Also, on some of my searches I see multiple entries in the dropdown, some of which look the same or nearly the same as others. I sometimes don't know which to pick and to what each applies. Also, I don't think I have ever seen any details about X11Colors or how to use them. I don't think I saw any text on "import java.awt.Color;" and when it is necessary. And it is possible that I am just ignorant with respect to how the Overview system is organized and how it works. I am very familiar with Visual Basic, but the Java stuff is not so easily grasped by me. More experience brings more knowledge. So I press forward a little at a time. Thank you for your help.
 

Spin

Well-known member
Joined
May 22, 2019
Posts
480
Likes
192
I agree with you when you say the SDK manual is too 'thin'. We all had/have problems taking the first steps.

And that's exactly why I feel we should help eachother out here on the forum. Together we will fill in the gaps :)

And another cliché: the steepest part of the learning curve is indeed located at the very begin. Once you have a few 'hours' on your MW-SDK-counter, it DOES get easier.

I learned a lot by 'reverse engineering' the Studies & Strategies that come in the MW 'SDK package'. I would advise you to start with the easier ones first, read them line by line until you know what every part does, then change a couple of lines and if everything works, move on to a more difficult one.

Keep up the good work ! (y)(y)
 

a_edwall

Active member
Joined
May 22, 2019
Posts
28
Likes
7
Yes, I have been doing as you suggest. It just takes time to absorb all the possibilities (in the new language). Repetition (a lot) is key.
 
Top