Would it be possible to get a formula that would indicate a second consecutive decline in range? This would in effect be a 3 bar pattern. Bar one as the reference bar, bar two smaller range than one, bar three smaller range than bar two. Bar three would be the indicated bar. Perhaps the 3rd bar could be painted blue or indicated by a dot etc. Hope I have made this clear. Thanks.
Announcement
Collapse
No announcement yet.
3rd bar volatility alert
Collapse
X
-
HC III
If by range you mean High-Low with no other conditions then the enclosed efs should do what you asked. It will paint a bar in blue when the High-Low of the current bar is less than that of the preceeding two bars.
Alex
PHP Code:function preMain() {
setPriceStudy(true);
setStudyTitle("3bar range");
setShowCursorLabel(false);
setColorPriceBars(true);
setDefaultPriceBarColor(Color.black);
}
function main() {
if((high(0)-low(0))<(high(-1)-low(-1))&&(high(-1)-low(-1))<(high(-2)-low(-2)))
setPriceBarColor(Color.blue);
return;
}
-
Alexis- thanks for your help. Yes I meant range and that Bar2 < Bar1 and Bar 3 < Bar2 making the 3rd bar the smallest range bar which is painted as it is the second consecutive reduction in range. Forgive my lack of knowledge, but how do I get your work into a .efs to use on my charts? Thanks again.
Comment
-
HC III
The enclosed revision also includes the commands to color the other bars
Alex
PHP Code:function preMain() {
setPriceStudy(true);
setStudyTitle("3bar range");
setShowCursorLabel(false);
setColorPriceBars(true);
setDefaultPriceBarColor(Color.black);
}
function main() {
if((high(0)-low(0))<(high(-1)-low(-1))&&(high(-1)-low(-1))<(high(-2)-low(-2))){
setPriceBarColor(Color.blue);
}else if(close(0)>open(0)){
setPriceBarColor(Color.lime);
}else if(close(0)<open(0)){
setPriceBarColor(Color.red);
}
return;
}
Comment
-
HC III
The enclosed revision also colors outside bars in cyan.
Alex
PHP Code:function preMain() {
setPriceStudy(true);
setStudyTitle("3bar range");
setShowCursorLabel(false);
setColorPriceBars(true);
setDefaultPriceBarColor(Color.black);
}
function main() {
if((high(0)-low(0))<(high(-1)-low(-1))&&(high(-1)-low(-1))<(high(-2)-low(-2))){
setPriceBarColor(Color.blue);
}else if(high(0)>high(-1)&&low(0)<low(-1)){
setPriceBarColor(Color.cyan);
}else if(close(0)>open(0)){
setPriceBarColor(Color.lime);
}else if(close(0)<open(0)){
setPriceBarColor(Color.red);
}
return;
}
Comment
-
Alex- would it be possible to add another bar indication to the 3 bar range study? This would be 2 higher highs and closes with closes above their opens(green bars) followed by a lower high and a close below the previous 2 up closes. The 3rd bar would be the colored or indicated bar. Exactly the opposite for buys - 2 lower lows and closes followed by a higher low and close above the previous two down closes. This is basically a 3rd lower high or higher low 2 close reversal. Thanks again for your help. Henry
Comment
-
Henry
The enclosed revision should do what you asked. The thrd bar high is colored in magenta while the low is in green.
Alex
PHP Code:function preMain() {
setPriceStudy(true);
setStudyTitle("3bar range");
setShowCursorLabel(false);
setColorPriceBars(true);
setDefaultPriceBarColor(Color.black);
}
function main() {
if(close(-2)>open(-2)&&close(-2)>close(-3)&&high(-2)>high(-3)&&
close(-1)>open(-1)&&close(-1)>close(-2)&&high(-1)>high(-2)&&
close(0)<open(0)&&close(0)<close(-2)&&high(0)<high(-1)){
setPriceBarColor(Color.magenta);
}else if(close(-2)<open(-2)&&close(-2)<close(-3)&&low(-2)<low(-3)&&
close(-1)<open(-1)&&close(-1)<close(-2)&&low(-1)<low(-2)&&
close(0)>open(0)&&close(0)>close(-2)&&low(0)>low(-1)){
setPriceBarColor(Color.green);
}else if((high(0)-low(0))<(high(-1)-low(-1))&&(high(-1)-low(-1))<(high(-2)-low(-2))){
setPriceBarColor(Color.blue);
}else if(high(0)>high(-1)&&low(0)<low(-1)){
setPriceBarColor(Color.cyan);
}else if(close(0)>open(0)){
setPriceBarColor(Color.lime);
}else if(close(0)<open(0)){
setPriceBarColor(Color.red);
}
return;
}
Comment
Comment