Series Chart Color Change
Author: pestocat2
Creation Date: 12/5/2020 7:26 PM
profile picture

pestocat2

#1
I have a chart series all with negative values and I want the color to change with the data. I find that the color always stays the same color.
CODE:
Please log in to see this code.

What am I doing wrong?
profile picture

Eugene

#2
The code is correct. Check your dblPctDrop series.
profile picture

pestocat2

#3
I tried the code example in F11 for rsi info and I see that this isn't exactly what I'm looking for. If my dblPctDrop[bar] > -7 then I want it green for those values, but if the dblPctDrop is less than -7 then I want the chart red for those values. The SetSeriesBarColor does something different. It looks as if a slope change can effect the color. Is there another way to do what I want to do?
Thank you and Take Care
profile picture

Eugene

#4
SetSeriesBarColor does exactly what you describe.
profile picture

pestocat2

#5
Is there another method to change the color of a chart series. I want to be able to change the chart color point by point, according to the value of the series point by point. It seems that SetBarColor or SetSeriesBarColor can't do this.
Thank you and Take Care,

profile picture

Eugene

#6
Look, don't get confused. It's SetSeriesBarColor.
profile picture

Cone

#7
Your code is correct and works. The only reason why it wouldn't appear to work is if your dblPctDrop series is not moving through -7 (minus 7).

Let's give your code some more context. Does this work for you?

CODE:
Please log in to see this code.


profile picture

pestocat2

#8
I think I know the issue. I am generating the DataSeries values in the for loop handling the buy/sell data. I'm plotting the DataSeries outside the for loop. The plot is correct, but I can't access the value information in order to change the colors. The DataSeries is defined outside the for loop and so assumed I had access to that information.
I'm confused!
profile picture

pestocat2

#9
Cone,
I didn't see your comment when added mine. Your code works, I have to figure out how you did it. You have used code that I have not used before. Thank you so much for your help.
Take Care,
profile picture

pestocat2

#10
I have several variables that are calculated in the for loop that I need in the display-area code. I see how to move a data series out of the for loop, but how about individual data items. Or better yet is there a way I don't have separate the display code with the for loop code. I have a very complicated for loop with several charts being generated and not sure how to handle all the declarations.
Thank You,
profile picture

superticker

#11
QUOTE:
several [DataSeries?] variables that are calculated in the for loop that I need in the display-area code.
I would not do that. Create/declare all the DataSeries variables with the "new" operator prior to entering the trading FOR loop. This is most efficient for execution.

QUOTE:
how about individual data items....
Well you can create temporary individual items if you're not plotting them on the Chart. I assume these are "temporary" local variables that only exist for one iteration of the trading FOR loop ... right?

If you must throw "individual items" on the Chart (Are you doing that? It will be slow.), be sure to declare all ChartPanes and Plots prior to entering the trading FOR loop. The example in Post# 7 practices all this guidance.
profile picture

pestocat2

#12
I want to report that I have Strategy working at least part way. I can now show the chart with both Green and Red chart lines according to the data. I followed Cone's assist. This was a struggle for me to understand how this works. I have attached a sample chart. The chart is the 3rd one down from the top. Thank you so much cone for the assist. One more question, I have a couple more series to return the the display area. I tried to add another DataSeries as per format, but system balks at this. How do I get more than one DataSeries back.
profile picture

Eugene

#13
If your issue directly related to the topic then you might want to show us some problem code?
profile picture

Eugene

#14
The topic is "series chart color change". Your posted code (with omissions) does not conform with your statement that it has relation to the topic. It's not true. You're trying to solve a different problem. This all only brings more confusion. I have moved the posts after #12 to a new topic to discuss your Heikin Ashi coding:

https://www.wealth-lab.com/Forum/Posts/Modifying-Heikin-Ashi-adding-stops-40508/
This website uses cookies to improve your experience. We'll assume you're ok with that, but you can opt-out if you wish (Read more).