I am trying to return something that should be simple, but can't seem to get the language correct in my formula. I would like to color the bars on a 1 minute chart based on two conditions being met on a 3 minute chart: the close of the 3 min bar over an sma and the osc over 0. The bars on the 1 min chart or either delayed by 3 or 4 (3Min) bars or color prematurely before both conditions are met.
Here is what I have so far:
function preMain() {
setPriceStudy(true);
setStudyTitle ("3M");
setCursorLabelName(3M");
setColorPriceBars(true);
setDefaultPriceBarColor(Color.black);
}
function main() {
var vMA = sma(20,inv(3));
var vOsc3 = osc(10,21,false,inv(3));
var vCl3 = close(0,inv(3));
(vMA == null ll vOsc3 == null ll vCl3 == null);
if(getBarStateInterval(3) == BARSTATE_NEWBAR) {
//nInterval = getInterval(3);
//return;
//}
if ((vOsc3 > 0) && (vCl3 > vMA)) {
setPriceBarColor(Color.green);
}
I've read the posts on intervals and getBarStateIntervals but I'm not grasping something. Any help would be so appreciated.
Here is what I have so far:
function preMain() {
setPriceStudy(true);
setStudyTitle ("3M");
setCursorLabelName(3M");
setColorPriceBars(true);
setDefaultPriceBarColor(Color.black);
}
function main() {
var vMA = sma(20,inv(3));
var vOsc3 = osc(10,21,false,inv(3));
var vCl3 = close(0,inv(3));
(vMA == null ll vOsc3 == null ll vCl3 == null);
if(getBarStateInterval(3) == BARSTATE_NEWBAR) {
//nInterval = getInterval(3);
//return;
//}
if ((vOsc3 > 0) && (vCl3 > vMA)) {
setPriceBarColor(Color.green);
}
I've read the posts on intervals and getBarStateIntervals but I'm not grasping something. Any help would be so appreciated.
Comment