Hi:
This is the program that i am getting "no syntex errors" and also "strategy is not defined" I don't understand why. Could you please let me know what the problem is.
Thank you very much
Sol Herskovitz
var buysel = 1;
var nstop = 0;
var ostop = 0;
var stopx = 0;
function preMain(){
setPriceStudy(true);
setStudyTitle("Range");
setCursorLabelName("Range",0);
}
function main(mult){
if(mult == null)
mult = 2;
var rng = 0;
var sb2 = 0;
var length = 21;
rng = 0;
sb2 = 1;
for(i = -length + 1; i < 0; i++)
rng += high(i) - low(i);
rng /= length;
rng *= mult;
if(buysel == 1)
nstop = low() - rng;
if(buysel == 2)
nstop = high() + rng;
if(buysel == 1 && nstop > ostop)
ostop = nstop;
if(buysel == 2 && nstop < ostop)
ostop = nstop;
stopx = 0;
if(buysel == 1 && low() < ostop){
buysel = 2;
nstop = high() + rng;
ostop = nstop;
strategy.dosell("EXIT LONG", STRATEGY.MARKET,STRATEGY.THISBAR);
strategy.doshort("GO SHORT", STRATEGY.MARKET, STRATEGY.THISBAR);
stopx = 1;
}
if(buysel == 2 && high() > ostop){
buysel = 1;
nstop = low() - rng;
ostop = nstop;
strategy.docover("EXIT SHORT", STRATEGY.MARKET, STRATEGY.THISBAR);
strategy.dolong("GO LONG", STRATEGY.MARKET, STRATEGY.THISBAR);
stopx = 1;
}
setBarThickness(2);
if(buysel == 1){
setBarFgColor(Color.red);
return ostop;
}
else{
setBarFgColor(Color.lime);
return ostop;
}
}
This is the program that i am getting "no syntex errors" and also "strategy is not defined" I don't understand why. Could you please let me know what the problem is.
Thank you very much
Sol Herskovitz
var buysel = 1;
var nstop = 0;
var ostop = 0;
var stopx = 0;
function preMain(){
setPriceStudy(true);
setStudyTitle("Range");
setCursorLabelName("Range",0);
}
function main(mult){
if(mult == null)
mult = 2;
var rng = 0;
var sb2 = 0;
var length = 21;
rng = 0;
sb2 = 1;
for(i = -length + 1; i < 0; i++)
rng += high(i) - low(i);
rng /= length;
rng *= mult;
if(buysel == 1)
nstop = low() - rng;
if(buysel == 2)
nstop = high() + rng;
if(buysel == 1 && nstop > ostop)
ostop = nstop;
if(buysel == 2 && nstop < ostop)
ostop = nstop;
stopx = 0;
if(buysel == 1 && low() < ostop){
buysel = 2;
nstop = high() + rng;
ostop = nstop;
strategy.dosell("EXIT LONG", STRATEGY.MARKET,STRATEGY.THISBAR);
strategy.doshort("GO SHORT", STRATEGY.MARKET, STRATEGY.THISBAR);
stopx = 1;
}
if(buysel == 2 && high() > ostop){
buysel = 1;
nstop = low() - rng;
ostop = nstop;
strategy.docover("EXIT SHORT", STRATEGY.MARKET, STRATEGY.THISBAR);
strategy.dolong("GO LONG", STRATEGY.MARKET, STRATEGY.THISBAR);
stopx = 1;
}
setBarThickness(2);
if(buysel == 1){
setBarFgColor(Color.red);
return ostop;
}
else{
setBarFgColor(Color.lime);
return ostop;
}
}
Comment