Announcement

Collapse
No announcement yet.

How to get the current market value?

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

  • How to get the current market value?

    Hi Jason
    Thank you for your last reply. Here is more:

    26. In my efs (real time trading with IB) I have a button to start.
    Then, when I hit the button the code checks for close(-1), if it's above/below some value, I buy/sell at Market.
    The problem is that after hitting ON on the button, the trade is done only at the begining of the next candle, and in a 10 minute chart for ER2, that might be a long time.
    How can I get the current market value when the efs runs first time, and then trade at Market, in the same bar?

    27. The same problem I am having when Interrupting for Lunch.
    If it's between 12:00 and 13:00, I do a return, and then the first trade is done only at 13:10 on a 10 min chart.
    This I can fix by moving my time to 12:50, but for the efs start in the morning I have no solution.

    28. I understand that in a Tick chart (in real time) the efs runs at every tick. How often does the efs run on a emini minutes chart?

    Code example:
    function ONOFFButton()
    {
    if (TradingSystemONOFF) { TradingSystemONOFF = false; }
    }

    main(...) {
    if (TradingSystemONOFF) {
    //Buy Condition
    if ((close(-1) > study + crossOffset) && !StrategyisLong) {
    nNewTrade = 1; // New Trade Trigger
    nsignal = 1; // Buy Signal - Trade Type
    ...
    }
    if (nNewTrade == 1) { //Execute New Trade
    if (StrategyisInTrade == true) {
    ...
    }
    } else { //Enter New position, i.e. use One lotSize
    if ((nsignal > 0)) {
    IBtrade.Buy(getSymbol(), lotSize, IBBroker.MARKET);
    ...
    } // end if IN TRADE
    } // END EXECUTE NEW TRADE
    ...
    }
    Many thanks, Arie

  • #2
    Hello Arie,

    26, 27. Once you're at bar 0, close(0) will give you the current market value. You should be able to send a trade during the bar's interval. Are you using setComputeOnClose() or have the trade function inside a call for BARSTATE_NEWBAR?

    At any rate, your button function only changes the value of TradingSystemONOFF. It does not run your code in main() after you click the button. So if you are using setComputeOnClose(), main() won't be executed until the start of the next bar. One thing you might try is placing a call to main() in your button function to force an execution after a button click.

    function ONOFFButton()
    {
    if (TradingSystemONOFF) { TradingSystemONOFF = false; }
    if (TradingSystemONOFF) main(...);
    }

    28. There is a known bug (EDL case # 587) affecting the EFS execution of electronically traded symbols, ES and NQ. On minute intervals EFS is not executing on each trade. It executes on change of price or if previous trade was at bid and current trade was at ask or vise versa. The work-around is to use a tick-based interval. Use 60S in place of 1 minute interval and the EFS will execute on each trade.
    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
      Current Market value, Buttons

      Hi Jason
      Thanks for your help, trusting as usually.
      Here are some more questions:

      29. close(0) indeed returns the current market value, but I am
      still confused about the following differences in a real time
      emini chart of ticks or minutes:
      a- close(0) versus close()
      b- high(0) versus high()
      c - close(0) versus open(0) or high(0)

      30. Buttons a: My code for buttons works but I do not how, because of lack of proper esignal info on the subject. The code is roughly as follows:
      ---------------------
      function function ONOFFButton()
      {
      if (TradingSystemONOFF) { TradingSystemONOFF = false; }
      else { TradingSystemONOFF = true; }
      if (TradingSystemONOFF) {
      drawTextPixel(165,35, " System ON-ON "+ "
      @URL=EFS:ONOFFButton" , ....);
      ButtonEntry(); //do immediately the first trade
      } else {
      drawTextPixel(165,35, " System OFF-OFF"+ "
      @URL=EFS:ONOFFButton" ,....);
      }
      }
      -----------------------------
      Is the left mouse click calling ONOFFButton()?

      31. Buttons b: I have two buttons, one the above, System ON-ON..., and the 2nd is DrawButtons() (using drawTextPixel()) called from main().
      Is it possible to create more than 2 buttons?
      Many thanks
      Arie

      Comment


      • #4
        Hello Arie,

        29.
        a - close(0) vs. close()
        No difference. If a bar index is not specified, it uses 0 by default. It's a good habit to use the zeros however.

        b. - high(0) vs. high()
        Same as a.

        c. - close(0) versus open(0) or high(0)
        On a 1 minute bar chart they return their respective price that describes the bar. On the first trade of a new bar, they all return the same price. Once the price starts moving around, open(0) will always return the price of the first trade for the bar, high(0) will return the highest price for the bar, and close(0) will return the last or current price. On a raw tick chart (1T or T) we no longer have bars. There is only one trade per "bar" so open(0), high(0), low(0) and close(0) will always return the same price.

        30. Yes, the left mouse click is triggering the call to the function specified by the @URL=EFS:ONOFFButton string added to the end of the button text parameter.

        31. Sure, you can create as many as you want. Just use a unique tag name for each button, which is the last parameter in the drawText function.
        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