goodmornig, i need help with EFS
in this program i need to know at which xBar ([0], [1], [2],
etc...) it finds the first condition (vHighs[i] > vHighs[i+1] so
that the next loop start not from j=1
but from j=xBar+1
thanks
function preMain() {
setStudyTitle("help efs");
setCursorLabelName("help efs");
setPriceStudy(true);
}
function main() {
var nBars = 2;
var vHighs;
var nBars1 = 7;
var vCloses1;
var i;
var j;
var nStateTotal = 0;
vCloses = getValue("Close", 0, -nBars);
vHighs = getValue("high", 0, -nBars);
vCloses1 = getValue("Close", 0, -nBars1);
vHighs1 = getValue("high", 0, -nBars1);
if(vCloses == null)
return;
if(vHighs1 == null)
return;
for(i = 0; i < nBars-1; i++) {
if(vHighs[i] > vHighs[i+1]) {
nStateTotal = nStateTotal + 1;
} else {
break;
}
}
for(j = 1; j < nBars1-1; j++) {
if(vCloses1[j] > vCloses1[j+4] &&
vCloses1[j+1] > vCloses1[j+5]) {
nStateTotal = nStateTotal + 1;
} else {
break;
}
}
if(nStateTotal == 0) {
return "";
} else if(nStateTotal == 1) {
return "m1";
} else if(nStateTotal == 2) {
drawTextRelative(0, high(), "m2",
Color.RGB(255,255,255), Color.RGB(0,0,0), Text.RIGHT,
"Arial", 10);
}
return;
}
in this program i need to know at which xBar ([0], [1], [2],
etc...) it finds the first condition (vHighs[i] > vHighs[i+1] so
that the next loop start not from j=1
but from j=xBar+1
thanks
function preMain() {
setStudyTitle("help efs");
setCursorLabelName("help efs");
setPriceStudy(true);
}
function main() {
var nBars = 2;
var vHighs;
var nBars1 = 7;
var vCloses1;
var i;
var j;
var nStateTotal = 0;
vCloses = getValue("Close", 0, -nBars);
vHighs = getValue("high", 0, -nBars);
vCloses1 = getValue("Close", 0, -nBars1);
vHighs1 = getValue("high", 0, -nBars1);
if(vCloses == null)
return;
if(vHighs1 == null)
return;
for(i = 0; i < nBars-1; i++) {
if(vHighs[i] > vHighs[i+1]) {
nStateTotal = nStateTotal + 1;
} else {
break;
}
}
for(j = 1; j < nBars1-1; j++) {
if(vCloses1[j] > vCloses1[j+4] &&
vCloses1[j+1] > vCloses1[j+5]) {
nStateTotal = nStateTotal + 1;
} else {
break;
}
}
if(nStateTotal == 0) {
return "";
} else if(nStateTotal == 1) {
return "m1";
} else if(nStateTotal == 2) {
drawTextRelative(0, high(), "m2",
Color.RGB(255,255,255), Color.RGB(0,0,0), Text.RIGHT,
"Arial", 10);
}
return;
}