Announcement

Collapse
No announcement yet.

Small 'doCover' Problem.

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

  • Small 'doCover' Problem.

    Hi I am stuck on a small detail with my backtest script, all of the Entry syntax works well, and the Strategy.doSell script works well as well, but the doCover, doesn't happen, is there anything glaringly obvious here:

    //Strategy starts here -->>
    if (vEnterLongTrade == true && vTrendMku == nCntr){
    Strategy.doLong("Enter Long", Strategy.CLOSE, Strategy.THISBAR);
    }
    if (vExitLongTrade == true && vTrendMku != nCntr && high() >= vTradeTarget){
    Strategy.doSell("Success Long", Strategy.LIMIT, Strategy.THISBAR, null, vTradeTarget);
    }
    if (vExitLongTrade == true && vTrendMku != nCntr && low() <= vStopLoss){
    Strategy.doSell("Fail Long", Strategy.STOP, Strategy.THISBAR, null, vStopLoss);
    }
    if (vEnterShortTrade == true && vTrendMkd == nCntr){
    Strategy.doShort("Enter Short", Strategy.CLOSE, Strategy.THISBAR);
    }
    if (vExitShortTrade == true && vTrendMkd != nCntr && low() <= vTradeTarget){
    Strategy.doCover("Success Short", Strategy.LIMIT, Strategy.THISBAR, null, vTradeTarget);
    }
    if (vExitShortTrade == true && vTrendMkd != nCntr && high() >= vStopLoss){
    Strategy.doCover("Fail Short", Strategy.STOP, Strategy.THISBAR, null, vStopLoss);
    }
    //Strategy ends here -->>

  • #2
    Hello rogerha,

    Without seeing the rest of your formula code it is difficult to say what the problem might be. There is something in your code logic that isn't allowing the if statements for the doCover calls to evaluate to true. Try placing a debugPrintln statement before the if statements and take a look at which variables inside the if statement is not evaluating to true as you're expecting. Check the spelling and case of each variable name and make sure you are using the correct logic for the conditions.

    debugPrintln("bar index: " + getCurrentBarIndex() + " vExitShortTrade = " + vExitShortTrade + " vTrendMkd = " + vTrendMkd + " nCntr = " + nCntr + " vTradeTarget = " + vTradeTarget);
    Jason K.
    Project Manager
    eSignal - an Interactive Data company

    EFS KnowledgeBase
    JavaScript for EFS Video Series
    EFS Beginner Tutorial Series
    EFS Glossary
    Custom EFS Development Policy

    New User Orientation

    Comment

    Working...
    X