All,
I’ve been doing some work with position sizing. I have been using the standard:
var nLot = Math.round(Strategy.getPositionSize()/2);
I have found this code in a number examples on this forum.
I’m having a little problem with this code. I’ve been trying to simulate 2 contracts – i.e. setting the Lot size to 2 before the backtest begins. I was my strategy wasn’t exiting ½ the position when it was supposed to, so I did some debugging Printlns on this. The Lot size doesn’t appear to half if the number of lots is 4 or below? Has anyone else found this? Could someone from Esignal please comment?
Excerpt from code:
debugPrintln("Strategy.getPositionSize() = "+ Strategy.getPositionSize());
var nLot = Math.round(Strategy.getPositionSize()/2);
debugPrintln("nLot = "+nLot);
Strategy.doCover("Paid for Stop", Strategy.STOP, Strategy.THISBAR, nLot, paidstop_num);
Kind regards,
Dan
I’ve been doing some work with position sizing. I have been using the standard:
var nLot = Math.round(Strategy.getPositionSize()/2);
I have found this code in a number examples on this forum.
I’m having a little problem with this code. I’ve been trying to simulate 2 contracts – i.e. setting the Lot size to 2 before the backtest begins. I was my strategy wasn’t exiting ½ the position when it was supposed to, so I did some debugging Printlns on this. The Lot size doesn’t appear to half if the number of lots is 4 or below? Has anyone else found this? Could someone from Esignal please comment?
Excerpt from code:
debugPrintln("Strategy.getPositionSize() = "+ Strategy.getPositionSize());
var nLot = Math.round(Strategy.getPositionSize()/2);
debugPrintln("nLot = "+nLot);
Strategy.doCover("Paid for Stop", Strategy.STOP, Strategy.THISBAR, nLot, paidstop_num);
Kind regards,
Dan
Comment