Below is the Up-Down.efs file that I found in this forum.
It plots two lines of Higher Highs and Lower Lows for the same length of time.
How do you change the program to be able to adjust the LOOKBACK value? I don't know if I am stating it correctly, but I am trying to plot a sum of the 10 day Higher Highs, and a sum of 12 day Lower Lows.
Thanks.
function preMain(){
setStudyTitle("Up-Down");
setCursorLabelName("Up",0);
setCursorLabelName("Dn",1);
setDefaultBarFgColor(Color.blue,0);
setDefaultBarFgColor(Color.red,1);
var fp1 = new FunctionParameter("Lookback", FunctionParameter.NUMBER);
fp1.setLowerLimit(1);
fp1.setDefault(100);
}
var vCounterUp=0;
var vCounterDn=0;
var aCounterUp=null;
var aCounterDn=null;
function main(Lookback){
if (aCounterUp==null)
aCounterUp=new Array(Lookback);
if (aCounterDn==null)
aCounterDn=new Array(Lookback);
if(getBarState()==BARSTATE_NEWBAR){
if(high(-1)>high(-2)&&low(-1)>low(-2)){
vCounterUp=1;
}else{
vCounterUp=0;
}
if(low(-1)<low(-2)&&high(-1)<high(-2)){
vCounterDn=1;
}else{
vCounterDn=0;
}
}
It plots two lines of Higher Highs and Lower Lows for the same length of time.
How do you change the program to be able to adjust the LOOKBACK value? I don't know if I am stating it correctly, but I am trying to plot a sum of the 10 day Higher Highs, and a sum of 12 day Lower Lows.
Thanks.
function preMain(){
setStudyTitle("Up-Down");
setCursorLabelName("Up",0);
setCursorLabelName("Dn",1);
setDefaultBarFgColor(Color.blue,0);
setDefaultBarFgColor(Color.red,1);
var fp1 = new FunctionParameter("Lookback", FunctionParameter.NUMBER);
fp1.setLowerLimit(1);
fp1.setDefault(100);
}
var vCounterUp=0;
var vCounterDn=0;
var aCounterUp=null;
var aCounterDn=null;
function main(Lookback){
if (aCounterUp==null)
aCounterUp=new Array(Lookback);
if (aCounterDn==null)
aCounterDn=new Array(Lookback);
if(getBarState()==BARSTATE_NEWBAR){
if(high(-1)>high(-2)&&low(-1)>low(-2)){
vCounterUp=1;
}else{
vCounterUp=0;
}
if(low(-1)<low(-2)&&high(-1)<high(-2)){
vCounterDn=1;
}else{
vCounterDn=0;
}
}
Comment