⬆⬇"Higher / Lower" for lines & fills ⬇⬆

Spin

Well-known member
Joined
May 22, 2019
Posts
477
Likes
191
Sundays equal coding-days, and sometimes also equal coding-questions 🤓

I am working on a new Study and I would like to hard-code the lines changing color between up / down or rising / falling:

697

I know how to change the thickness of a line already: you simply alter the standard 1.0f to 2.0f or higher:
Java:
grp.addRow(new PathDescriptor(EMA_2_Path, "Path", GREEN, 2.0f, null, true, false, false));


But what are the 'codes' for the other strokes ? How to make it dotted by default ? Or dot - striped ?
And what if I no longer want a 'solid' color policy, but a 'Higher/Lower' one ? What are the correct code entries then ?

I looked in the SDK-manual and in the SDK-overview, and found the 'color policy', but I have not yet figured out how to implement it.
(as a matter of fact, the 'higher/lower' only appears in 2 standard MW-studies, but is not related to lines or fills there: OpenInterest & Volume)

Also: is it possible to make a fill between two lines also change color when rising / falling ?
I would like it to become yellow (like the lines) when falling, so that the fill adapts to the lines.

698


Much obliged for all input :)
 
Last edited:

Spin

Well-known member
Joined
May 22, 2019
Posts
477
Likes
191
Thanks to @ScottyA I succeeded in programming a 'higher/lower' for the lines, as well as having it set to a form of 'dash' by default.
Thank you very much @ScottyA !! 👏

Coloring the fill seems impossible: I tried with a 'variable color' that changes whenever the lines rise or drop, but that does not work.
From my tests it seems that the Fill-color is set in "Initialize" and cannot be changed afterwards:

Java:
if (Ehigh0 > Ehigh1) {
        debug("higher");
        VARIABLE1 = new Color(0, 128, 0);
        Fill = new ShadeDescriptor(FILL_COLOR, get("Fill color"), new String[][]{{"EMA_H", "EMA_L"}}, VARIABLE1, true, true);
      }
      if (Ehigh0 < Ehigh1) {
        debug("lower");
        VARIABLE2 = new Color(255, 165, 0);
        Fill = new ShadeDescriptor(FILL_COLOR, get("Fill color"), new String[][]{{"EMA_H", "EMA_L"}}, VARIABLE2, true, true);
      }

The debug-statements get through, but the coloring of the fill is not changed.

Feel free to prove me wrong :)
 
Top