I must be doing something wrong, I can't get any of my efs's to backtest properly.
The following code generates the correct debug outputs, but gives 0 results when backtesting.
if (vInLong == 1 && vClose > vValue1) {
if (Strategy.isLong() == true) {
//Strategy.doSell("Exit Long",Strategy.STOP,Strategy.THISBAR,Strategy.getD efaultLotSize(),close());
Strategy.doSell("Exit Long", Strategy.MARKET, Strategy.THISBAR, Strategy.DEFAULT, 0);
debugPrintln("Exit Long");
}
}
if (vInShort == 1 && vClose < vValue2) {
if (Strategy.isShort() == true) {
//Strategy.doCover("Exit Short",Strategy.STOP,Strategy.THISBAR,Strategy.get DefaultLotSize(),close());
Strategy.doCover("Exit Short", Strategy.MARKET, Strategy.THISBAR, Strategy.DEFAULT, 0);
debugPrintln("Exit Short");
}
}
if (vValue3 == 1){
if (Strategy.isInTrade() == false) {
//Strategy.doLong("Enter Long",Strategy.LIMIT,Strategy.THISBAR,Strategy.get DefaultLotSize(),close());
Strategy.doLong("Enter Long", Strategy.MARKET, Strategy.THISBAR, Strategy.DEFAULT, 0);
debugPrintln("Long");
}
}
else {
if (vClose >= vValue1 && vInShort == 0 && vGoingDown) {
if (Strategy.isInTrade() == false) {
//Strategy.doShort("Enter Short",Strategy.LIMIT,Strategy.THISBAR,Strategy.ge tDefaultLotSize(),close());
Strategy.doShort("Enter Short", Strategy.MARKET, Strategy.THISBAR, Strategy.DEFAULT, 0);
debugPrintln("Short");
}
}
}
The following code generates the correct debug outputs, but gives 0 results when backtesting.
if (vInLong == 1 && vClose > vValue1) {
if (Strategy.isLong() == true) {
//Strategy.doSell("Exit Long",Strategy.STOP,Strategy.THISBAR,Strategy.getD efaultLotSize(),close());
Strategy.doSell("Exit Long", Strategy.MARKET, Strategy.THISBAR, Strategy.DEFAULT, 0);
debugPrintln("Exit Long");
}
}
if (vInShort == 1 && vClose < vValue2) {
if (Strategy.isShort() == true) {
//Strategy.doCover("Exit Short",Strategy.STOP,Strategy.THISBAR,Strategy.get DefaultLotSize(),close());
Strategy.doCover("Exit Short", Strategy.MARKET, Strategy.THISBAR, Strategy.DEFAULT, 0);
debugPrintln("Exit Short");
}
}
if (vValue3 == 1){
if (Strategy.isInTrade() == false) {
//Strategy.doLong("Enter Long",Strategy.LIMIT,Strategy.THISBAR,Strategy.get DefaultLotSize(),close());
Strategy.doLong("Enter Long", Strategy.MARKET, Strategy.THISBAR, Strategy.DEFAULT, 0);
debugPrintln("Long");
}
}
else {
if (vClose >= vValue1 && vInShort == 0 && vGoingDown) {
if (Strategy.isInTrade() == false) {
//Strategy.doShort("Enter Short",Strategy.LIMIT,Strategy.THISBAR,Strategy.ge tDefaultLotSize(),close());
Strategy.doShort("Enter Short", Strategy.MARKET, Strategy.THISBAR, Strategy.DEFAULT, 0);
debugPrintln("Short");
}
}
}
Comment