Announcement

Collapse
No announcement yet.

Strategy.doLong will not execute

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Strategy.doLong will not execute

    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?

  • #2
    hmmerritt
    Other than for some redundant conditional statements the snippet of code you posted appears to be correct.
    However it is insufficient to be able to determine what could be preventing the strategy from executing.
    You will need to provide a complete functional example and details as to the symbol and interval used.
    Alex

    Comment


    • #3
      Thank you Alexis. Since it is intermittant, I'm not sure you can help. The symbol is AB #F, interval=133T. The redundant statement for the doLong was just an attempt to get it to execute further down in the "if" statement. Like I said, all of the other lines execute fine, and on another day's data, it all works fine.

      Comment


      • #4
        hmmerritt
        As I indicated in my previous reply the code sample you posted is insufficient to determine what could be causing the issue. You need to post the whole code for anyone to be able to assist
        Alex

        Comment

        Working...
        X