Announcement

Collapse
No announcement yet.

main() ends prematurely cant find out why

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

  • main() ends prematurely cant find out why

    maybe someone here will see instantly what ive been looking for for a while now

    You need to open the debug window for that code. Upon right click on the panel where the study is loaded, the script detects that the right button was pressed, prints its bar coordinate and then it proceeds with the rest of the calculation
    The bug is that if i comment out if (rclick ==1) to exectue the whole calculation only upon click detection, the efs exits main() when it gets at the offsetSeries(t3 ... line
    I have no idea why
    Attached Files

  • #2
    Hello silvermotion,

    The first logic problem that I see is that the variable "rclick" is only being declared locally inside main(), which is inside a check for BARSTATE_CURRENTBAR. Any condition prior to that declaration will see an undefined variable. The second issue I see is that you have a condition that is checking the value of a variable, "click," which is not declared anywhere in the code. That one is currently commented out, so it may not be important for the time being.

    Not sure what you are trying to accomplish based on the code you posted, but I would first recommend declaring rclick and click (if that wasn't a typo) as global variables. If you assign them initially to a value of 0, your current formula will only see those variables with a value of 0. Currently you do not have any code logic that assigns those variables to any other value. Therefore, when uncommenting the condition that looks for rclick == 1 and a bar state of NEWBAR, the code block inside this condition never gets executed as that condition will always evaluate to false.

    The formula code is not actually exiting main prematurely. To verify this add the following debug statement just before the last return statement in main(). Hope this helps.

    function main() {
    .
    .
    .
    .

    debugPrintln("end of main");
    return;
    }
    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
      To add a bit more to Jason's reply. I believe you want to set rclick to 1 in your onRButtonDown() routine...but better yet in my view to declare a new function called T3Calc() or similar and have it executed directly from onRButtonDown() (when the button is first pushed) and main() (on each new tick).

      main() is only executed on a new tick (or new bar, if you have that option set)...and you may want to execute the T3 code when the user right clicks...in a slow market a tick may not come in right away to do that calc.

      Something to think about anyway.

      Garth
      Garth

      Comment

      Working...
      X