Is there a generic few lines of code I could add to any indicator plot statements that would change the color of the plot of the line when the line was going up and when it was going down?
Announcement
Collapse
No announcement yet.
Color Change
Collapse
X
-
momentum
Here below is an example
Alex
PHP Code:
var vEMA10 = new MAStudy(10, 0, "Close", MAStudy.EXPONENTIAL);
var vLastAlert = -1;
function preMain() {
setPriceStudy(true);
setStudyTitle("");
setCursorLabelName("10ema", 0);
setDefaultBarStyle(PS_SOLID, 0);
setDefaultBarFgColor(Color.red, 0);
setDefaultBarThickness(2, 0);
setPlotType(PLOTTYPE_LINE, 0);
}
function main() {
if (
vEMA10.getValue(MAStudy.MA) > vEMA10.getValue(MAStudy.MA, -1)
) onAction1()
else if (
vEMA10.getValue(MAStudy.MA) < vEMA10.getValue(MAStudy.MA, -1)
) onAction2();
return vEMA10.getValue(MAStudy.MA);
}
function onAction1() {
setBarFgColor(Color.RGB(0,0,255));
vLastAlert = 1;
}
function onAction2() {
setBarFgColor(Color.RGB(255,0,0));
vLastAlert = 2;
}
Comment