I am trying to filter stocks based on previous day's closing compared to previous week's range. Create an efs to work on the dashboard. It works if i use current candle close value but it fails when i use previous days close value. Can someone help me
function preMain() {
setStudyTitle("WeeklyBreak");
setCursorLabelName("WeeklyBreak", 0);
}
function main() {
if(close(0,inv("D")) > high(-1,inv("W"))){
setBarBgColor(Color.green)
return high(-1,inv("W"))
}
if(close(0,inv("D")) < low(-1,inv("W"))){
setBarBgColor(Color.red)
return low(-1,inv("W"))
}
}
This works fine highlighting the the stocks but the moment i change the close(0.inv("D")) to close(-1.inv("D")) it stops highlighting.
function preMain() {
setStudyTitle("WeeklyBreak");
setCursorLabelName("WeeklyBreak", 0);
}
function main() {
if(close(0,inv("D")) > high(-1,inv("W"))){
setBarBgColor(Color.green)
return high(-1,inv("W"))
}
if(close(0,inv("D")) < low(-1,inv("W"))){
setBarBgColor(Color.red)
return low(-1,inv("W"))
}
}
This works fine highlighting the the stocks but the moment i change the close(0.inv("D")) to close(-1.inv("D")) it stops highlighting.