Announcement

Collapse
No announcement yet.

help on knowledge base marketdepth funtions, please.

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

  • help on knowledge base marketdepth funtions, please.

    Hi,

    I couldn't get the example below from knowledge base to work:

    function preMain () {

    }

    var depthID = 0;

    function main()
    {
    var SourceList = MarketDepth.getSources();

    if (SourceList !=null)
    {
    depthID = MarketDepth.subscribe(SourceList[0]);

    debugPrintln("DepthbidSize: " + MarketDepth.bidSize( depthID, 0 ));
    debugPrintln("DepthaskSize: " + MarketDepth.askSize( depthID, 0 ));
    }


    MarketDepth.unsubscribe(DepthID);


    }


    SourceList comes out to be Null because MarketDepth.getSources() isn't giving a value. I subscribed to nasdaq total view and i'm getting data from esignal instead of other brokerage so am I suppose to get a value back when I call getsources()?. there's not enough explanation for these marketdepth functions.

    ultimately i'm trying to save to a txt file level II data, ie bid/ask size and price and market maker ID to file for offline analysis. i'm new and I thought this is the way to go. I figure if I get this working I can build on it.

    thanks for anyone's help.

  • #2
    firstnull
    Comment out (or delete) the following line of code from your script
    MarketDepth.unsubscribe(DepthID);
    as I believe the example is incorrect in this regard
    Once you do that it should work (it does at my end)
    Alex


    Originally posted by firstnull View Post
    Hi,

    I couldn't get the example below from knowledge base to work:

    function preMain () {

    }

    var depthID = 0;

    function main()
    {
    var SourceList = MarketDepth.getSources();

    if (SourceList !=null)
    {
    depthID = MarketDepth.subscribe(SourceList[0]);

    debugPrintln("DepthbidSize: " + MarketDepth.bidSize( depthID, 0 ));
    debugPrintln("DepthaskSize: " + MarketDepth.askSize( depthID, 0 ));
    }


    MarketDepth.unsubscribe(DepthID);


    }


    SourceList comes out to be Null because MarketDepth.getSources() isn't giving a value. I subscribed to nasdaq total view and i'm getting data from esignal instead of other brokerage so am I suppose to get a value back when I call getsources()?. there's not enough explanation for these marketdepth functions.

    ultimately i'm trying to save to a txt file level II data, ie bid/ask size and price and market maker ID to file for offline analysis. i'm new and I thought this is the way to go. I figure if I get this working I can build on it.

    thanks for anyone's help.

    Comment


    • #3
      Thanks, ACM, but that didn't work either. MarketDepth.getSources() still returns Null.

      Comment


      • #4
        firstnull
        As I said it is working at my end as you can see in the two screenshots enclosed below
        FWIW I slightly modified the debug line to print the bid depth count, the bid value and bid size at the specified depth ie 0 in the top screenshot and 1 in bottom (note that in the Formula Output it shows DepthaskSize instead of DepthbidSize only because I forgot to edit the string)
        Alex








        Originally posted by firstnull View Post
        Thanks, ACM, but that didn't work either. MarketDepth.getSources() still returns Null.

        Comment


        • #5
          Thanks, Alex. So to test this out I coded this as a study and reloaded the study after making the change you suggested during market hrs to be sure I have level 2 quotes but the formula output window still printed NUll.

          Comment


          • #6
            Hi Alex,

            After you wrote this study and you verify it, you added it to a chart right? and when you did that it started printing to the output screen? I did that process but it's not printing. am i missing a step somewhere?

            thanks

            Comment

            Working...
            X