Announcement

Collapse
No announcement yet.

debugPrintln Problems at end of test

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

  • debugPrintln Problems at end of test

    Hi,

    I am trying to debug the following line at the end of a back text if there are no further bars of data (i.e. test is over) and the strategy is not currently in a trade. I use the code below;

    if((open(1) == null) && (Strategy.isInTrade != true)) {

    debugPrintln("</trades>");

    }

    It prints the line correctly at the end of the test however for some reason it also prints occasionally during the test too. Can anyone see think of any reason for this to occur or any solutions?

    Thanks in advance.

  • #2
    Hello thestranger,

    The .inInTrade() call needs the open and close parens. Without them the condition is looking for a property called isInTrade, which is slightly different. However, after adding the parens and testing this code snippet I didn't receive any executions on historical bars. On historical bars open(1) shouldn't return null. At any rate, what you can do to further debug this that might provide some more clues is to add the current bar index and the values of open(1) and .inInTrade() in the debugPrintln statement like below. Try this and see if this sheds any light on the issue.

    PHP Code:
    function main() { 

        if((
    open(1) == null) && (Strategy.isInTrade() != true)) {
            var 
    nStatus Strategy.isInTrade();
            var 
    nO      open(1);
            
    debugPrintln(getCurrentBarIndex() + "  </trades>  open(1)= " nO " -- isInTrade= " nStatus);
        
        }

        return 
    null;

    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


    • #3
      Thanks JasonK

      Adding the parens has worked. Simple error but just kept missing it. Must have been looking at the code too long.

      Comment


      • #4
        You're most welcome.
        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