I have tried to change the plot colour based on the indicator value is rising or falling, however it doesn't quite working during the turning point.
Attached the screen shot.
The code is like:
if (hmaSeries[0]>=hmaSeries[1]) {
hmaPlot.Set(0, hmaSeries[0], Color.LightGreen);
} else {
hmaPlot.Set(0, hmaSeries[0], Color.Red);
}
The code to initialize the plot:
hmaPlot = AddPlot(new PlotAttributes("HMA", EPlotShapes.Line, Color.White, Color.Empty, 0, 0, true));
The problem is the plot will still using the previous colour at the 1st bar after turning happened.
The indicator value on the screen from left to right are:
23617
23594
23727
23878
You will see on the screen shot, the line between 2nd and 3rd bar are still in red colour which is wrong. It should be in green colour instead. Any clue about this?
Changing plot colour on the fly problem [SOLVED]
- JoshM
- Posts: 2196
- Joined: May 20 2011
- Location: The Netherlands
- Has thanked: 1544 times
- Been thanked: 1565 times
- Contact:
I suspect that this is expected behaviour; if I recall correctly there were also topics about this with the regular MultiCharts edition, although I cannot find them now.
Anyway, try displacing the plot. I think that would give the behaviour you're after (if I understand you correctly). So change the code to:
(The difference is in the 1 in the `Set()` method as opposed to a 0).
Anyway, try displacing the plot. I think that would give the behaviour you're after (if I understand you correctly). So change the code to:
Code: Select all
if (hmaSeries[0]>=hmaSeries[1]) {
hmaPlot.Set(1, hmaSeries[0], Color.LightGreen);
} else {
hmaPlot.Set(1, hmaSeries[0], Color.Red);
}
Thanks for your advice, however displacement will distort the chart...the value has to calculate & show using current bar, if I move it the left by one bar then the future value will be displayed on current bar which doesn't sound right to me...I suspect that this is expected behaviour; if I recall correctly there were also topics about this with the regular MultiCharts edition, although I cannot find them now.
Anyway, try displacing the plot. I think that would give the behaviour you're after (if I understand you correctly). So change the code to:
(The difference is in the 1 in the `Set()` method as opposed to a 0).Code: Select all
if (hmaSeries[0]>=hmaSeries[1]) {
hmaPlot.Set(1, hmaSeries[0], Color.LightGreen);
} else {
hmaPlot.Set(1, hmaSeries[0], Color.Red);
}
- Henry MultiСharts
- Posts: 9165
- Joined: Aug 25 2011
- Has thanked: 1264 times
- Been thanked: 2958 times
Hello Sylpha,
If you want us to check this case please attach the complete code of the study and the workspace you are using.
If you want us to check this case please attach the complete code of the study and the workspace you are using.
Hi Henry,
Attached the workspace and the indicator.
Attached the workspace and the indicator.
- Attachments
-
- export.zip
- (32.33 KiB) Downloaded 313 times
- Henry MultiСharts
- Posts: 9165
- Joined: Aug 25 2011
- Has thanked: 1264 times
- Been thanked: 2958 times
Hello Sylpha,
The color between the bars is the one from the last calculation. There is no way to change the plot color between the bars as there is no study calculation there. On the next bar will be another calculation and another color will be plotted after it.
The color between the bars is the one from the last calculation. There is no way to change the plot color between the bars as there is no study calculation there. On the next bar will be another calculation and another color will be plotted after it.