Announcement

Collapse
No announcement yet.

askForInput()

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

  • askForInput()

    When my script loads, askForInput() is correctly popping up and letting me change parameters, and those parameters are being correcly applied.

    My problem is that the entire script loads and may trigger a signal BEFORE askForInput() pops up. I was hoping the script wouldn't load and evaluate the current bar until askForInput() was done.
    My question - is there some way to force a script to "wait" until I click OK on askForInput()?

    For just triggering Alerts this isn't a problem, but for integrated trading it is. If I'm trading 4 markets with one script, I want to avoid 4 identical scripts with the only difference being exchange names and contract month/year.
    Good Trading,
    Yuri Shramenko

  • #2
    Hello Yuri,

    Regardless of where you make the call to askForInput(), the entire chart loads first and then displays the input window. What you need to do to prevent trade signals from firing during the loading process is add a Boolean parameter to your study that is set to false by default. Any of your trade signals will need to add this parameter to its conditions to prevent the trade from being executed until this parameter is changed to true. When your input window is displayed you will enter your other parameters and also set the Boolean trading parameter to true.
    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
      Jason, the idea of true/false coming up in askForInput sounded good. The below image shows the default coming up as "false". Worked good - no fired trades - BUT - when I changed to "true" and clicked OK - what I didn't know was that every bar in the chart would be re-evaluated.
      In under two seconds over 35 trades were opened and closed (I'm using market orders) - I was glad I was using my IB simulated account (losing over $1K in 2 seconds is a record!).

      This is very simple code:

      if (Trade)
      { Alert.addToList(getSymbol(), Msg, Color.white, Color.black);
      Alert.playSound("boing.wav");
      buyMarket(getSymbol(), 1, Exchange, YYMM); }

      Any sure-fire ways of just starting at the current bar ?
      Attached Files
      Good Trading,
      Yuri Shramenko

      Comment


      • #4
        Hello Yuri,

        Yes, add a check for the current bar index. Change your condition to the following.

        if (Trade && getCurrentBarIndex() == 0) {
        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