I have a situation where a Strategy.doLong statement will not execute. It does execute properly on other dates' data, but not on one particular day. All of the other statements under the doLong execute within an overall "if" statement, but the doLong will not. This is in Backtest mode, I do not know what it will do in realtime. The code is as follows:
if ( nFirstBarTrade == 2 ){
if (high(0) > nFirstBarHigh && CurHours == 9 && CurMinutes < 59 && nFirstBarTrade == 2 && Strategy.isInTrade() == false){
Strategy.doLong("Go Long", Strategy.STOP, Strategy.THISBAR, nLotSize, nFirstBarHigh+0.1);
nTradeEntryPrice = nFirstBarHigh+0.1;
nStopLevel = nFirstBarLow - nStopAmt;
nBreakeven = 0;
if (Strategy.isInTrade() == false){
Strategy.doLong("Go Long", Strategy.STOP, Strategy.THISBAR, nLotSize, nFirstBarHigh+0.1);
}
drawShapeRelative(0, low() -.1, Shape.UPARROW, "", Color.RGB(0,255,0), Shape.BOTTOM);
vLastAlert = 1;
nNewTrade = 1;
nFirstBarTrade = 3;
debugPrint("Buy" + " " + getHour() + ":" +getMinute() + ":" + getSecond() + ", " + getMonth() + "/" + getDay() + " inTrade=" +Strategy.isInTrade()+ ", Size=" + Strategy.getPositionSize() + ", HalfOff=" + nHalfOff + ", nFirstBarTrade=" + nFirstBarTrade + "Position=" + position +"\n");
}
Any ideas?
if ( nFirstBarTrade == 2 ){
if (high(0) > nFirstBarHigh && CurHours == 9 && CurMinutes < 59 && nFirstBarTrade == 2 && Strategy.isInTrade() == false){
Strategy.doLong("Go Long", Strategy.STOP, Strategy.THISBAR, nLotSize, nFirstBarHigh+0.1);
nTradeEntryPrice = nFirstBarHigh+0.1;
nStopLevel = nFirstBarLow - nStopAmt;
nBreakeven = 0;
if (Strategy.isInTrade() == false){
Strategy.doLong("Go Long", Strategy.STOP, Strategy.THISBAR, nLotSize, nFirstBarHigh+0.1);
}
drawShapeRelative(0, low() -.1, Shape.UPARROW, "", Color.RGB(0,255,0), Shape.BOTTOM);
vLastAlert = 1;
nNewTrade = 1;
nFirstBarTrade = 3;
debugPrint("Buy" + " " + getHour() + ":" +getMinute() + ":" + getSecond() + ", " + getMonth() + "/" + getDay() + " inTrade=" +Strategy.isInTrade()+ ", Size=" + Strategy.getPositionSize() + ", HalfOff=" + nHalfOff + ", nFirstBarTrade=" + nFirstBarTrade + "Position=" + position +"\n");
}
Any ideas?
Comment