Trade FOREX with FXCM

  • Award-Winning Platform
  • 24/7 Customer Support
  • Trade Directly on Charts
  • Free $50K Practice Account
Register


Results 1 to 6 of 6

Thread: tick subscription using ExtSubscribe: Is this limited to the instrument of the chart?

  1. #1
    mstreck is offline Member
    Join Date
    Jan 2011
    Posts
    272

    tick subscription using ExtSubscribe: Is this limited to the instrument of the chart?

    Hello,

    I am having some issues with the proper set-up of tick and bar streams in a strategy.

    I was looking into helper.lua to try to understand if there is some limitations. I am subscribing to tick streams in Prepare():

    Code:
        ------------------------------------------------------------ Tick Stream Set-Up ---------------------------------------------------------------------
    
    
        -------------------------- Streams for Price Ticks ------------------------------
    	ExtSubscribe(TickStreamID + AskStreamOffset, StrategyInstrument, "t1", false, "tick");
        ExtSubscribe(TickStreamID + BidStreamOffset, StrategyInstrument, "t1", true, "tick");
    Then in ExtUpdate() I try to subscribe to the bar streams of all time frames but the issue is that ExtUpdate() never appears to get called in the debugger.

    Looking into ExtSubscribe the relevant lines are (since I do set StrategyInstrument which is not NIL, i.e. not the instrument of chart display):

    Code:
            sub.stream = core.host:execute("getHistory", id, instrument, period, 0, 0, bid);
            sub.tick = (period == "t1");
            sub.loaded = false;
            sub.lastSerial = -1;
            _gSubscription[id] = sub;
    What does sub.tick = (period == "t1");
    mean? Is there a limitation that tick streams have to have NIL as a parameter of ExtSubscribe?

    Thanks,
    Martin

  2. #2
    mstreck is offline Member
    Join Date
    Jan 2011
    Posts
    272
    One more question to tick streams: Does the index of [NOW] like in instance.ask[NOW] always return the latest tick price of the ask stream, or do I have to reference with 'period' in ExtUpdate() to reference the last tick?

    I saw [NOW] many times in examples.

    Thanks,
    Martin

  3. #3
    Natalya is offline Member
    Join Date
    Apr 2009
    Posts
    748
    The index [NOW] in instance.ask[NOW] returns the latest tick price of the ask stream.
    It is equivalent to:
    Code:
    instance.ask[instance.ask:size() - 1]

  4. #4
    mstreck is offline Member
    Join Date
    Jan 2011
    Posts
    272
    Thanks, Natalya.

    Could you also please tell me about the tick subscription. I changed the subscription to NIL as for the instrument, which appears to work fine. I can design like this, but I would like to know if it is posssible to use tick suscriptions with other instruments as well, in particular if this is possible and whether it does load then a certain history range of the tick stream of the instrument subscribed to.

    Thanks,
    Martin

  5. #5
    sibvic is offline Member
    Join Date
    Nov 2010
    Posts
    43
    Quote Originally Posted by mstreck View Post
    ... I would like to know if it is posssible to use tick suscriptions with other instruments as well...
    Yes, you can use subscribe to any instrument ticks.
    ExtSubscribe(1, nil, "t1", "Bid", "close");
    is the same as
    ExtSubscribe(1, [instrument of the strategy], "t1", "Bid", "close");
    Quote Originally Posted by mstreck View Post
    ...whether it does load then a certain history range of the tick stream of the instrument subscribed to.
    Yes, it will load default number of ticks from the history. (In case of instrument == nil there is no need to load tick history. It is already loaded in the instance.bid/instance.ask).

  6. #6
    mstreck is offline Member
    Join Date
    Jan 2011
    Posts
    272
    That is great, thank you for your help.

    Cheers,
    Martin

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Disclaimer: Trading foreign exchange on margin carries a high level of risk, and may not be suitable for all investors. The high degree of leverage can work against you as well as for you. Before deciding to trade foreign exchange you should carefully consider your investment objectives, level of experience, and risk appetite. The possibility exists that you could sustain a loss of some or all of your initial investment and therefore you should not invest money that you cannot afford to lose. You should be aware of all the risks associated with foreign exchange trading, and seek advice from an independent financial advisor if you have any doubts. Any opinions, news, research, analyses, prices, or other information contained on this website is provided as general market commentary and does not constitute investment advice. Forex Capital Markets LLC. will not accept liability for any loss or damage, including without limitation to, any loss of profit, which may arise directly or indirectly from use of or reliance on such information.