How do you display a condition, say price above or under an MA or a cross, in the form of a BAR or HISTO?
Announcement
Collapse
No announcement yet.
Bar or Histo display?
Collapse
X
-
Re: Bar or Histo display?
Angus F
In the image you posted that band looks like a separate indicator pane in which the formula is only painting the background
To replicate that effect just set your conditions and paint the background accordingly using setBarBgColor()
Alex
Originally posted by Angus F
How do you display a condition, say price above or under an MA or a cross, in the form of a BAR or HISTO?
-
Re: Re: Bar or Histo display?
Alexis,
That was perfect.
Thank you so much.
Angus.
Originally posted by Alexis C. Montenegro
Angus F
In the image you posted that band looks like a separate indicator pane in which the formula is only painting the background
To replicate that effect just set your conditions and paint the background accordingly using setBarBgColor()
Alex
Comment
-
Code
Alexis,
I actually ended up doing it slightly differently, but thanks again for putting me on the right track.
PHP Code:/**********************************
EMA Cross diplayed in histo-bar form
***********************************/
function preMain() {
setPriceStudy(false);
setStudyTitle("EMA Cross-Histo");
setCursorLabelName("ema-histo");
setColorPriceBars(false);
var fp1 = new FunctionParameter("fInputLength", FunctionParameter.NUMBER);
fp1.setName("Fast-Length");
fp1.setLowerLimit(1);
fp1.setDefault(5);
var fp2 = new FunctionParameter("sInputLength", FunctionParameter.NUMBER);
fp2.setName("Slow-Length");
fp2.setLowerLimit(1);
fp2.setDefault(10);
}
function main(fInputLength, sInputLength) {
var nMA1 = ema(fInputLength, 0);
var nMA2 = ema(sInputLength, 0);
if(nMA1 == null || nMA2 == null) return;
if(nMA1 <= nMA2) {
//setBarFgColor(Color.red);
//setBarBgColor(Color.red);
drawShapeRelative(0, 5, Shape.DIAMOND, null, Color.red, Shape.RELATIVETOBOTTOM);
} else if(nMA1 > nMA2) {
//setBarFgColor(Color.lime);
//setBarBgColor(Color.lime);
drawShapeRelative(0, 5, Shape.DIAMOND, null, Color.lime, Shape.RELATIVETOBOTTOM);
}
return;// nMA1; return nMA2;
}
Comment
Comment