I have a question about doing a trailing stop based on my position.
I am attempting the following code, but EFS keeps calculating the variable perc as 0. Also, is there anyway to "debug" the formula step by step to check the values of each variable?
//assuming price is populated from a previous run
var price;
var perc = null;
perc = close() - price;
perc = Math.abs(perc);
var percentage = null;
var percentage = (perc/price);
....
if(close() >= v && !Strategy.isLong())
{
Strategy.doLong("Crossing Up",Strategy.MARKET, Strategy.THISBAR);
price = close();
}
if(perc>0.02 && Strategy.isLong() == true)
Strategy.doSell("2% Target",Strategy.MARKET, Strategy.THISBAR);
EFS closes out every trade at the same price. Any help would be greatly appreciated,
Anthony
I am attempting the following code, but EFS keeps calculating the variable perc as 0. Also, is there anyway to "debug" the formula step by step to check the values of each variable?
//assuming price is populated from a previous run
var price;
var perc = null;
perc = close() - price;
perc = Math.abs(perc);
var percentage = null;
var percentage = (perc/price);
....
if(close() >= v && !Strategy.isLong())
{
Strategy.doLong("Crossing Up",Strategy.MARKET, Strategy.THISBAR);
price = close();
}
if(perc>0.02 && Strategy.isLong() == true)
Strategy.doSell("2% Target",Strategy.MARKET, Strategy.THISBAR);
EFS closes out every trade at the same price. Any help would be greatly appreciated,
Anthony
Comment